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

Submitted by Andrey Ryabinin on Nov. 1, 2019, 7:12 p.m.

Details

Message ID 20191101191218.31833-8-aryabinin@virtuozzo.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Andrey Ryabinin Nov. 1, 2019, 7:12 p.m.
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@virtuozzo.com>
---
 drivers/block/nbd.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

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);