lkml.org 
[lkml]   [2018]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] nbd:clear NBD_BOUND flag when NBD connection is closed
Date
From: Medad <medadyoung@gmail.com>

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 <medadyoung@gmail.com>
---
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
\
 
 \ /
  Last update: 2018-12-11 07:18    [W:0.037 / U:0.236 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site