From patchwork Tue Dec 12 15:42:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 847535 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3yx3zV33dSz9s83; Wed, 13 Dec 2017 02:44:38 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1eOmjR-0003Nh-O8; Tue, 12 Dec 2017 15:44:33 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1eOmjP-0003N0-TF for kernel-team@lists.ubuntu.com; Tue, 12 Dec 2017 15:44:31 +0000 Received: from mail-qt0-f198.google.com ([209.85.216.198]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1eOmhs-0005qF-Ku for kernel-team@lists.ubuntu.com; Tue, 12 Dec 2017 15:42:56 +0000 Received: by mail-qt0-f198.google.com with SMTP id a19so26635703qtb.22 for ; Tue, 12 Dec 2017 07:42:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=mJqy+o2CZnxKptWnEXvtefSFyvOVTaU8Ff7e41FiHdY=; b=Siv8gWLKBnX7EO6J/6oUqGyXAKUEyHeWf2ngQZmdzQBmZixUsl4/tbL+Jn/jsIpxDE /TM/pMPIavDhJoYOe50pBlYj10+ajOHS7r/ZlqjZIJS5lf6YkoU7e6gr4ZxZ/h37udFE Xs80IeFT/ZZMzml+aUWaysHYvt/ONyXbxrmVVQwYmqcHLYPMbzC/5vGkh1/O9RVSWURv VFIGmx+KNFJrgG6nZNVX0OnU8SfboSGRyHIFRgtiQOpls0gbQ91dUVquxYcFeI9DDBkz AXs1A7HN5mG/yjNnydnXYhyofYGVr44WJ8+I/QmgwpEScFoFh7HALf4aN7NSYTUYjtzU vc8w== X-Gm-Message-State: AKGB3mJ2eLeHxh4fy6098HoZG9shahwhhsNPttzShglcnNkG6t+hlvKh FhnWihtqf8BWhG461XQ6XFJUFpp/6MJLlYxifMnyntO1GeEvt/faB6w8nY035RzRJ/A/usccFGL eEXroU1fDYneaCe/rsXRAt+R7x6dIVoTvKF8drMQ9 X-Received: by 10.200.22.91 with SMTP id x27mr5971041qtk.226.1513093375378; Tue, 12 Dec 2017 07:42:55 -0800 (PST) X-Google-Smtp-Source: ACJfBot3+30zBqYu2rvEKbLte1zvlbaw2uRCCMmqyqFbrcl3ck6eDPml5/QHVeTyS6ogl7OLi4BuvA== X-Received: by 10.200.22.91 with SMTP id x27mr5971020qtk.226.1513093375065; Tue, 12 Dec 2017 07:42:55 -0800 (PST) Received: from localhost.localdomain ([187.10.21.12]) by smtp.gmail.com with ESMTPSA id d6sm6095265qte.4.2017.12.12.07.42.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Dec 2017 07:42:53 -0800 (PST) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [azure 4.13][PATCH 15/19] Drivers: hv: vmbus: Fix a rescind issue Date: Tue, 12 Dec 2017 13:42:04 -0200 Message-Id: <1513093328-10999-16-git-send-email-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513093328-10999-1-git-send-email-marcelo.cerri@canonical.com> References: <1513093328-10999-1-git-send-email-marcelo.cerri@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: K. Y. Srinivasan BugLink: http://bugs.launchpad.net/bugs/1736283 The current rescind processing code will not correctly handle the case where the host immediately rescinds a channel that has been offerred. In this case, we could be blocked in the open call and since the channel is rescinded, the host will not respond and we could be blocked forever in the vmbus open call.i Fix this problem. Signed-off-by: K. Y. Srinivasan Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman (cherry picked from linux-next commit 7fa32e5ec28b1609abc0b797b58267f725fc3964) Signed-off-by: Dexuan Cui Signed-off-by: Marcelo Henrique Cerri --- drivers/hv/channel.c | 10 ++++++++-- drivers/hv/channel_mgmt.c | 7 ++++--- include/linux/hyperv.h | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c index 82bbd9561050..2e2f5d02af80 100644 --- a/drivers/hv/channel.c +++ b/drivers/hv/channel.c @@ -655,22 +655,28 @@ void vmbus_close(struct vmbus_channel *channel) */ return; } - mutex_lock(&vmbus_connection.channel_mutex); /* * Close all the sub-channels first and then close the * primary channel. */ list_for_each_safe(cur, tmp, &channel->sc_list) { cur_channel = list_entry(cur, struct vmbus_channel, sc_list); - vmbus_close_internal(cur_channel); if (cur_channel->rescind) { + wait_for_completion(&cur_channel->rescind_event); + mutex_lock(&vmbus_connection.channel_mutex); + vmbus_close_internal(cur_channel); hv_process_channel_removal( cur_channel->offermsg.child_relid); + } else { + mutex_lock(&vmbus_connection.channel_mutex); + vmbus_close_internal(cur_channel); } + mutex_unlock(&vmbus_connection.channel_mutex); } /* * Now close the primary. */ + mutex_lock(&vmbus_connection.channel_mutex); vmbus_close_internal(channel); mutex_unlock(&vmbus_connection.channel_mutex); } diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 19f374ce3658..fd5faa37d3cf 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -333,6 +333,7 @@ static struct vmbus_channel *alloc_channel(void) return NULL; spin_lock_init(&channel->lock); + init_completion(&channel->rescind_event); INIT_LIST_HEAD(&channel->sc_list); INIT_LIST_HEAD(&channel->percpu_list); @@ -894,6 +895,7 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) /* * Now wait for offer handling to complete. */ + vmbus_rescind_cleanup(channel); while (READ_ONCE(channel->probe_done) == false) { /* * We wait here until any channel offer is currently @@ -909,7 +911,6 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) if (channel->device_obj) { if (channel->chn_rescind_callback) { channel->chn_rescind_callback(channel); - vmbus_rescind_cleanup(channel); return; } /* @@ -918,7 +919,6 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) */ dev = get_device(&channel->device_obj->device); if (dev) { - vmbus_rescind_cleanup(channel); vmbus_device_unregister(channel->device_obj); put_device(dev); } @@ -932,13 +932,14 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) * 2. Then close the primary channel. */ mutex_lock(&vmbus_connection.channel_mutex); - vmbus_rescind_cleanup(channel); if (channel->state == CHANNEL_OPEN_STATE) { /* * The channel is currently not open; * it is safe for us to cleanup the channel. */ hv_process_channel_removal(rescind->child_relid); + } else { + complete(&channel->rescind_event); } mutex_unlock(&vmbus_connection.channel_mutex); } diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index f9088f52273d..822c7a3a4efc 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -720,6 +720,7 @@ struct vmbus_channel { u8 monitor_bit; bool rescind; /* got rescind msg */ + struct completion rescind_event; u32 ringbuffer_gpadlhandle;