Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2233151imm; Thu, 18 Oct 2018 11:06:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV61agdiRAjt4wROnb2G8wLPlXj8SmY6I7zB8KwG1bohRDzQ1WNyUjtUy6nvBBv8eG9VD12x4 X-Received: by 2002:a17:902:68:: with SMTP id 95-v6mr11266736pla.57.1539886014923; Thu, 18 Oct 2018 11:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539886014; cv=none; d=google.com; s=arc-20160816; b=ILN6NSASO4SoSYggPG+cIxeqHJQHD+RA68FV2Yx8IRyb9evYiZxdUmwaUziSRqzkF8 NvDJro+o4LL6F0r/CoFQQ1KFJAf8p0SsgVZx0Oopon1DBdtyNPyNC8rlpw7vLZgW1OtC 4AJn05vXiofULAH1TO3TLsdjBrkinrlwGOWH+h07EHdzmDtqSNbOIxoqBXUfLK78BlpY 1v9ZVvk+EYD+T9CNTVmaKcAFATRWRYGNkjiXzBbd3c57JBJytE8bX/1G/KjR1aumqFBg GwpHqFpLZ3c0t/W8fulA3VsBn38vwDYVWeSjxvI3yOSoeKc0BCGcgE7J0577THsfqmTu rpuw== 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=BvCBb9MsILk+MoIJPMgPYRoH5DK+//gbOaXeXmnPT78=; b=v0hKMYHdUTDaD9eD1sh2tp199bok8T9vVn/4pAhMpg/V9NdJVUNz4LmRBF+GX4jCHc 4GxisjIv1ZM31AObxzjBwfbQVU8euEAzNcatl3Mrb1NPxh9F/r/gGLIB8Um9U/rwTcGb 7MO+IoF5ppLc3g+PVflIoXOi0rup7QuUZEDM3R0wRia8NgE8sJYD8u+kkmWNEq8DO9CO YuZjU+yMsdne//6Tn+Yi3uSK4gdTiqLbOFn3cHbYmViODy/y3BcQWSNjD0HjmWRr7TIb owy4di2ehvI3+G7T47phRl6u8TzeoZeG6mCEH9ctQmXdfHO3c/Q9+2cD3G7WqltvnyDh t0Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FNWJziAi; 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 n12-v6si19610818pgl.136.2018.10.18.11.06.39; Thu, 18 Oct 2018 11:06:54 -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=FNWJziAi; 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 S1730061AbeJSCGV (ORCPT + 99 others); Thu, 18 Oct 2018 22:06:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:54654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728416AbeJSCGV (ORCPT ); Thu, 18 Oct 2018 22:06:21 -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 BDCC8214AB; Thu, 18 Oct 2018 18:04:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539885853; bh=ze6KmlzeIGKkpqoBEfWzoNHc2p9HS7bxs4Y2eQBnsT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FNWJziAiKCp7UV1opuOtzT0F/g3fqcb/KRi9r/WARU6LufVzaAIQD3ndoPcI/JLco 0zEQUaQWyOApf9OUF+KYN0BAGxB+QZNaPSp5Zk9WulBlY5laMKvj54h2XqbwmZv8Pw vom9NO5mtBcdrHXHymbhsECMS84e1tdaOqYHIrAk= 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.9 35/35] HV: properly delay KVP packets when negotiation is in progress Date: Thu, 18 Oct 2018 19:55:04 +0200 Message-Id: <20181018175427.755458013@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181018175422.506152522@linuxfoundation.org> References: <20181018175422.506152522@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.9-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 @@ -616,21 +616,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); @@ -707,6 +708,8 @@ void hv_kvp_onchannelcallback(void *cont VM_PKT_DATA_INBAND, 0); host_negotiatied = NEGO_FINISHED; + + goto recheck; } }