[Devel] [PATCH RHEL7 COMMIT] ms/nbd: fix how we set bd_invalidated

Konstantin Khorenko khorenko at virtuozzo.com
Thu Oct 31 14:57:30 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.5
------>
commit 28dd5b48572fb7d21d3b0171c406eed4d22bc72e
Author: Josef Bacik <jbacik at fb.com>
Date:   Thu Oct 31 14:57:28 2019 +0300

    ms/nbd: fix how we set bd_invalidated
    
    bd_invalidated is kind of a pain wrt partitions as it really only
    triggers the partition rescan if it is set after bd_ops->open() runs, so
    setting it when we reset the device isn't useful.  We also sporadically
    would still have partitions left over in some disconnect cases, so fix
    this by always setting bd_invalidated on open if there's no
    configuration or if we've had a disconnect action happen, that way the
    partition table gets invalidated and rescanned properly.
    
    Signed-off-by: Josef Bacik <jbacik at fb.com>
    Signed-off-by: Jens Axboe <axboe at kernel.dk>
    
    https://jira.sw.ru/browse/PSBM-98887
    
    (cherry picked from commit fe1f9e6659ca6124f500a0f829202c7c902fab0c)
    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 3fa813de94e4..5beae4e63401 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -820,10 +820,6 @@ static void nbd_bdev_reset(struct block_device *bdev)
 		return;
 	set_device_ro(bdev, false);
 	bdev->bd_inode->i_size = 0;
-	if (max_part > 0) {
-		blkdev_reread_part(bdev);
-		bdev->bd_invalidated = 1;
-	}
 }
 
 static void nbd_parse_flags(struct nbd_device *nbd, struct block_device *bdev)
@@ -1102,6 +1098,9 @@ static int nbd_open(struct block_device *bdev, fmode_t mode)
 		}
 		refcount_set(&nbd->config_refs, 1);
 		mutex_unlock(&nbd->config_lock);
+		bdev->bd_invalidated = 1;
+	} else if (nbd_disconnected(nbd->config)) {
+		bdev->bd_invalidated = 1;
 	}
 out:
 	mutex_unlock(&nbd_index_mutex);



More information about the Devel mailing list