[Devel] [PATCH rh7] nbd: fix how we set bd_invalidated
Andrey Ryabinin
aryabinin at virtuozzo.com
Thu Oct 31 14:54:56 MSK 2019
On 10/31/19 2:54 PM, Andrey Ryabinin wrote:
> From: Josef Bacik <jbacik at fb.com>
>
> 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-98994
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 726b940b0fe6..f110cb1c82f1 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