[Devel] [PATCH rh7 7/8] nbd: use bd_set_size when updating disk size
Andrey Ryabinin
aryabinin at virtuozzo.com
Fri Nov 1 22:12:17 MSK 2019
From: Josef Bacik <jbacik at fb.com>
When we stopped relying on the bdev everywhere I broke updating the
block device size on the fly, which ceph relies on. We can't just do
set_capacity, we also have to do bd_set_size so things like parted will
notice the device size change.
Fixes: 29eaadc ("nbd: stop using the bdev everywhere")
cc: stable at vger.kernel.org
Signed-off-by: Josef Bacik <jbacik at fb.com>
Signed-off-by: Jens Axboe <axboe at kernel.dk>
https://jira.sw.ru/browse/PSBM-99102
(cherry picked from commit 9e2b19675d1338d2a38e99194756f2db44a081df)
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
drivers/block/nbd.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index a0ebd61c19d8..0eedb74183dc 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -196,9 +196,18 @@ static void nbd_size_clear(struct nbd_device *nbd)
static void nbd_size_update(struct nbd_device *nbd)
{
struct nbd_config *config = nbd->config;
+ struct block_device *bdev = bdget_disk(nbd->disk, 0);
+
blk_queue_logical_block_size(nbd->disk->queue, config->blksize);
blk_queue_physical_block_size(nbd->disk->queue, config->blksize);
set_capacity(nbd->disk, config->bytesize >> 9);
+ if (bdev) {
+ if (bdev->bd_disk)
+ bd_set_size(bdev, config->bytesize);
+ else
+ bdev->bd_invalidated = 1;
+ bdput(bdev);
+ }
kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE);
}
@@ -952,7 +961,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;
- bd_set_size(bdev, config->bytesize);
nbd_dev_dbg_init(nbd);
for (i = 0; i < num_connections; i++) {
--
2.23.0
More information about the Devel
mailing list