[Devel] [PATCH RHEL7 COMMIT] nbd: invalidate bdev after size update

Konstantin Khorenko khorenko at virtuozzo.com
Tue Nov 5 11:06:19 MSK 2019


The commit is pushed to "branch-rh7-3.10.0-1062.4.1.vz7.115.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1062.4.1.vz7.115.7
------>
commit 76d191c1b822ed972a884fd61f2987d71d063b55
Author: Andrey Ryabinin <aryabinin at virtuozzo.com>
Date:   Tue Nov 5 11:06:18 2019 +0300

    nbd: invalidate bdev after size update
    
    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);



More information about the Devel mailing list