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

Submitted by Konstantin Khorenko on Oct. 31, 2019, 11:57 a.m.

Details

Message ID 201910311157.x9VBvSpQ016696@finist-ce7.sw.ru
State New
Series "nbd: fix how we set bd_invalidated"
Headers show

Commit Message

Konstantin Khorenko Oct. 31, 2019, 11:57 a.m.
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@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@fb.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    
    https://jira.sw.ru/browse/PSBM-98887
    
    (cherry picked from commit fe1f9e6659ca6124f500a0f829202c7c902fab0c)
    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 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);