Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp313351imu; Mon, 10 Dec 2018 22:37:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/XcBxJMGnvRdIjrcqVK79GS5pCUgpEEiEzktXQbF9ovo5mxPmWgaaOMHvkFCE5J6W6dZZVI X-Received: by 2002:a63:5252:: with SMTP id s18mr13528939pgl.326.1544510267221; Mon, 10 Dec 2018 22:37:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544510267; cv=none; d=google.com; s=arc-20160816; b=nCYFiSBl0yngPJrvnN44wT857a/USrlMj9h6fw+KgOaaWOQeOM4f+SLmqC81ehWd/N 2GOSULm94o39zKbJGxeAHaDzSPoB4Yv9KhnQzXrY2MimFvpNo15miKW/Z9y7JjdSXiV8 RLE1Wh/UJ+MIfgVsO0R2hp+00sWC/Cf3BOhoph2FeW2LafZMXJlO3K2S/HnBaJHP2Vo9 oV5wriDRQ/DBvGQ60YjMNthVDJfTkWGTmYqyUnI9BIroBYnz+CnlQYZoQRhErONUBt14 8KVKAkwSxDcyir05rQmJswa07iRSSZh9gcdNzbWJzyUgAUJHzni4ACZ/fXZ/0Tqq0M6/ yiXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=TlYVShGWQfqCikX7zIfo6dSj8lcXrBBDWQwIm/PzWAQ=; b=1HVnXvhLdgpxXSc8XAxtvigG1dFaCOdRtm6BFMz8l9tYzZiDg5A0IQBL2rTN0dPPZd 5CFkofZWJ6uNwFnHzoyjoiK6hnOSw7ynDQbPelOHfhlkzY4rYdezqidUs0Sak9BDA8eq DzdsN6m0SCeZXUKLZsD9rz0G2UThuXOUVrYtn2UvjUFHrK97V+1/AreVYeVsWXEbrVRY 1BC2ZbR1cox6kvp6cg1Yb9auQSDtwOABEFoB3P4QuQtKX5jfx1VLxWBtx0jhZHvPdubY utFd1+5Vn7/R0s975nheD6kq0E773qLJ0JYsAl+4DzaZ/390QF4zDv6NRhG6gflSPueZ lojw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="u55Is/qA"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5si10806091pgk.49.2018.12.10.22.37.32; Mon, 10 Dec 2018 22:37:47 -0800 (PST) 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=@gmail.com header.s=20161025 header.b="u55Is/qA"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728585AbeLKGRK (ORCPT + 99 others); Tue, 11 Dec 2018 01:17:10 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:46884 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727352AbeLKGRJ (ORCPT ); Tue, 11 Dec 2018 01:17:09 -0500 Received: by mail-pl1-f194.google.com with SMTP id t13so6423609ply.13; Mon, 10 Dec 2018 22:17:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=TlYVShGWQfqCikX7zIfo6dSj8lcXrBBDWQwIm/PzWAQ=; b=u55Is/qA0pSseLvGvzYgxvg44ykhaYLA1P4+SfTntUm/1jRq5p7qJiQ82p0EdWsWni cdvBxrnGCavkp5pqneI/M2ZusPoIRlDM5rLfqYNyRTCAXLOadKxh/huIBzcXV+RJRkqu WaRrwWxdL53tDisAlhgvyZC3eJvj4tR1M0xxQaJAlJ8N0mxjKisR6jiVAkywiRAAAXyh x63D8vDM1Ydvsgb86/tzzVtyLBnFYitf18eB7h2HHynwSTbA/65xpbvo0IyF1fQ63nv8 dpMDV3QxZTn0idAZcy07VA0/DG2cTvC3ZrQpNIGSavewgqms8TirjIKom8g+K/0xwIZs p/rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TlYVShGWQfqCikX7zIfo6dSj8lcXrBBDWQwIm/PzWAQ=; b=m/f2KiVNnDXd3jv0IZRlpdIuWYqChCpuImIXmRHyqmt3+yru9W4IJOzncGVFTlTYI8 xC9hi5x5R6T4eNSlJyCF9Wh9TQ48Fi3J1VS7MfnpQEU586kicsPjFFcwbdqF8RA4W9Q1 os6cJtcoPWX4MNVOPPcXBkn2XfmFBklBmkN55s7NOSGel8IjzDvBoROxuJHX4JPnHERt GW4v0JnMC6i9dYxtMvLUX3uqDFgfp+LLDezjXuNYE4IDoxtX6iOhKBSiBVWMnxI+yY3L 8yDlVLi6pCHw1XFs2Vxvq/5Oe3tywst+0bKoVCmob/yHKwz89xTh+W6g0UFqAkq+rtbZ xtwQ== X-Gm-Message-State: AA+aEWYLuLVIzzBwKxQ9UsZJxKMmlA3heL0bq5nnU6XcpShk11zChhEm ZCdjZxp2V2DkjvkDxdiTfMI= X-Received: by 2002:a17:902:722:: with SMTP id 31mr14992831pli.271.1544509029167; Mon, 10 Dec 2018 22:17:09 -0800 (PST) Received: from localhost.localdomain (27-52-137-213.adsl.fetnet.net. [27.52.137.213]) by smtp.gmail.com with ESMTPSA id e16sm16246045pfn.46.2018.12.10.22.17.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Dec 2018 22:17:08 -0800 (PST) From: medadyoung@gmail.com To: jbacik@fb.com, axboe@kernel.dk Cc: linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, Medad Subject: [PATCH] nbd:clear NBD_BOUND flag when NBD connection is closed Date: Tue, 11 Dec 2018 14:17:03 +0800 Message-Id: <1544509023-18923-1-git-send-email-medadyoung@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Medad If we do NOT clear NBD_BOUND flag when NBD connection is closed, then the original NBD device could not be used again. Signed-off-by: Medad --- drivers/block/nbd.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 64278f4..5c88490 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -277,10 +277,14 @@ static void sock_shutdown(struct nbd_device *nbd) struct nbd_config *config = nbd->config; int i; - if (config->num_connections == 0) + if (config->num_connections == 0) { + clear_bit(NBD_BOUND, &config->runtime_flags); return; - if (test_and_set_bit(NBD_DISCONNECTED, &config->runtime_flags)) + } + if (test_and_set_bit(NBD_DISCONNECTED, &config->runtime_flags)) { + clear_bit(NBD_BOUND, &config->runtime_flags); return; + } for (i = 0; i < config->num_connections; i++) { struct nbd_sock *nsock = config->socks[i]; @@ -944,7 +948,7 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg) sockfd_put(old); clear_bit(NBD_DISCONNECTED, &config->runtime_flags); - + clear_bit(NBD_BOUND, &config->runtime_flags); /* We take the tx_mutex in an error path in the recv_work, so we * need to queue_work outside of the tx_mutex. */ @@ -1020,6 +1024,7 @@ static int nbd_disconnect(struct nbd_device *nbd) dev_info(disk_to_dev(nbd->disk), "NBD_DISCONNECT\n"); set_bit(NBD_DISCONNECT_REQUESTED, &config->runtime_flags); send_disconnects(nbd); + clear_bit(NBD_BOUND, &config->runtime_flags); return 0; } -- 2.7.4