[Devel] [PATCH rh7 8/8] nbd: invalidate bdev after size update

Andrey Ryabinin aryabinin at virtuozzo.com
Fri Nov 1 22:12:18 MSK 2019


Per my very limited understanding of this stuff we shouldn't set
bd_invalidated before updating size of bdev. AFAIU if we open device
in between bd_invalidated set and before size updated this will trigger
the rescan of partition which will see the zero size. Set bd_invalidated
only after nbd_size_update(nbd). nbd_size_update() actually does it itself
sometimes, so it might be not necessary, but let's do it anyway. I'm just
trying to mimic upstream here. Similar change was introduced by
commit e46c7287b1c2 ("nbd: add a basic netlink interface").

https://jira.sw.ru/browse/PSBM-99102
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 drivers/block/nbd.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 0eedb74183dc..79de456643cf 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -944,8 +944,6 @@ static int nbd_start_device(struct nbd_device *nbd, struct block_device *bdev)
 		return -EINVAL;
 	}
 
-	if (max_part)
-		bdev->bd_invalidated = 1;
 	blk_mq_update_nr_hw_queues(&nbd->tag_set, config->num_connections);
 	nbd->task_recv = current;
 	mutex_unlock(&nbd->config_lock);
@@ -959,8 +957,6 @@ static int nbd_start_device(struct nbd_device *nbd, struct block_device *bdev)
 	}
 
 	set_bit(NBD_HAS_PID_FILE, &config->runtime_flags);
-	if (max_part)
-		bdev->bd_invalidated = 1;
 
 	nbd_dev_dbg_init(nbd);
 	for (i = 0; i < num_connections; i++) {
@@ -979,6 +975,9 @@ static int nbd_start_device(struct nbd_device *nbd, struct block_device *bdev)
 		args->index = i;
 		queue_work(recv_workqueue, &args->work);
 		nbd_size_update(nbd);
+		if (max_part)
+			bdev->bd_invalidated = 1;
+
 	}
 	error = wait_event_interruptible(config->recv_wq,
 					 atomic_read(&config->recv_threads) == 0);
-- 
2.23.0



More information about the Devel mailing list