Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2235918imm; Thu, 18 Oct 2018 11:09:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV63JRaRspyjtCP3BxM8p6Xfz/xAoUpP+HxTLmE8mCexcknFi0UWfZvz9g1RYmUNr7TO1QmdT X-Received: by 2002:a63:e749:: with SMTP id j9-v6mr29149038pgk.246.1539886170536; Thu, 18 Oct 2018 11:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539886170; cv=none; d=google.com; s=arc-20160816; b=0kxYfoYEh+k9q8ALjU86fI6wH0kFXEDBIYIqjoWP2Tw0r/JaMBgpiM6aOe8VGV2gSj g4qvcGGfRg/J9ZLaBNZcexYl/OjBzydnpoRC3F7rEVKdoGFHSIGPjp7reiXO5k9khESy sL9oV+V3Ivg9LgPtQb2Yv8gryOSYM4nA/dDbhRaACNRcK8AuBebPkl0PN3hVNxD8H4z8 nbVvw5RQf/gQWLnO3wlcb9Pjv6RetKpgKSXPpGEeYZ8mJRGM2NrWQNxsTT+cGgFdK61b 832IFutLa7XLoowvqZvI9EBl4h20bVWUAZ6VF4SY1thIx3fQpOSkKctzz/16EgC1O8vv PUww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nKnOqyvHIM8X9WW3myBb7aQmSyg508K/vYEkqdx87C0=; b=DC8Z5AomcHDxX0cuwNIsZfq8thN7Fi6perDB0QIFyHvJp1lnX9OGDr1c69EAShqLPQ VlM4e4125cdCSwGwtjM9JXiMLEv6FVdNi8mEjiGrLh1+Yl9fDX+CJWV7cmAAX8Su8LKm SXGZcwgU9zGzkxWvQGYsR6YsMcvnGuFE83WFXs58K9iitMKu4McvSeZpmjETUIwtKubT m1YOxD2p4ZdJn7vcBUtcwUnQcTLD9aPGn66NQDaIu5qzVAR7L6u5uq7CFfOMD2XeUuSk bWbMz7dymos4zkurpPlhKIfXya9mA5ZUcGNNu2XYzsvB252CP+EGsL69x+RojBL+k2Zx VE/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0r4K5zPY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g34-v6si18719080pld.392.2018.10.18.11.09.15; Thu, 18 Oct 2018 11:09:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0r4K5zPY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730601AbeJSCJI (ORCPT + 99 others); Thu, 18 Oct 2018 22:09:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:58474 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729745AbeJSCJI (ORCPT ); Thu, 18 Oct 2018 22:09:08 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B6A41204FD; Thu, 18 Oct 2018 18:06:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539886020; bh=GCwUzgDy0cXbnCKaCwoJjBLUW0hBxwb2JIsqfDgJB6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0r4K5zPY70MQTq88ZOMTuaPr6I9ToJs1sibxeNosQt76DnaAw3Ti0yTVQIVODFL3W cRzi8lMGNji6dOZGp9s5qyWNghxc3Vbrd1ANhILvqtWe3HsDRHuPbyL1Psx/Vv7L4q SZZGUbdIkxZT76VUWCbKNH0U/MmqahV5Yop+mRR0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wang Jian , Dexuan Cui , Long Li , "K. Y. Srinivasan" Subject: [PATCH 4.4 48/48] HV: properly delay KVP packets when negotiation is in progress Date: Thu, 18 Oct 2018 19:55:23 +0200 Message-Id: <20181018175430.455023194@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181018175427.133690306@linuxfoundation.org> References: <20181018175427.133690306@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Long Li commit a3ade8cc474d848676278660e65f5af1e9e094d9 upstream. The host may send multiple negotiation packets (due to timeout) before the KVP user-mode daemon is connected. KVP user-mode daemon is connected. We need to defer processing those packets until the daemon is negotiated and connected. It's okay for guest to respond to all negotiation packets. In addition, the host may send multiple staged KVP requests as soon as negotiation is done. We need to properly process those packets using one tasklet for exclusive access to ring buffer. This patch is based on the work of Nick Meier . The above is the original changelog of a3ade8cc474d ("HV: properly delay KVP packets when negotiation is in progress" Here I re-worked the original patch because the mainline version can't work for the linux-4.4.y branch, on which channel->callback_event doesn't exist yet. In the mainline, channel->callback_event was added by: 631e63a9f346 ("vmbus: change to per channel tasklet"). Here we don't want to backport it to v4.4, as it requires extra supporting changes and fixes, which are unnecessary as to the KVP bug we're trying to resolve. NOTE: before this patch is used, we should cherry-pick the other related 3 patches from the mainline first: The background of this backport request is that: recently Wang Jian reported some KVP issues: https://github.com/LIS/lis-next/issues/593: e.g. the /var/lib/hyperv/.kvp_pool_* files can not be updated, and sometimes if the hv_kvp_daemon doesn't timely start, the host may not be able to query the VM's IP address via KVP. Reported-by: Wang Jian Tested-by: Wang Jian Signed-off-by: Dexuan Cui Signed-off-by: Long Li Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/hv/hv_kvp.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/drivers/hv/hv_kvp.c +++ b/drivers/hv/hv_kvp.c @@ -612,21 +612,22 @@ void hv_kvp_onchannelcallback(void *cont NEGO_IN_PROGRESS, NEGO_FINISHED} host_negotiatied = NEGO_NOT_STARTED; - if (host_negotiatied == NEGO_NOT_STARTED && - kvp_transaction.state < HVUTIL_READY) { + if (kvp_transaction.state < HVUTIL_READY) { /* * If userspace daemon is not connected and host is asking * us to negotiate we need to delay to not lose messages. * This is important for Failover IP setting. */ - host_negotiatied = NEGO_IN_PROGRESS; - schedule_delayed_work(&kvp_host_handshake_work, + if (host_negotiatied == NEGO_NOT_STARTED) { + host_negotiatied = NEGO_IN_PROGRESS; + schedule_delayed_work(&kvp_host_handshake_work, HV_UTIL_NEGO_TIMEOUT * HZ); + } return; } if (kvp_transaction.state > HVUTIL_READY) return; - +recheck: vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 4, &recvlen, &requestid); @@ -703,6 +704,8 @@ void hv_kvp_onchannelcallback(void *cont VM_PKT_DATA_INBAND, 0); host_negotiatied = NEGO_FINISHED; + + goto recheck; } }