summaryrefslogtreecommitdiffstats
path: root/drivers/block/nbd.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fb.com>2018-05-16 14:51:21 -0400
committerJens Axboe <axboe@kernel.dk>2018-05-16 12:54:12 -0600
commitfe1f9e6659ca6124f500a0f829202c7c902fab0c (patch)
tree4b7bfa4504ac3f2d352525cfbc688ebd2e255d08 /drivers/block/nbd.c
parent96d97e17828f97b321bd364c818819121f855650 (diff)
downloadlinux-fe1f9e6659ca6124f500a0f829202c7c902fab0c.tar.gz
linux-fe1f9e6659ca6124f500a0f829202c7c902fab0c.tar.bz2
linux-fe1f9e6659ca6124f500a0f829202c7c902fab0c.zip
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>
Diffstat (limited to 'drivers/block/nbd.c')
-rw-r--r--drivers/block/nbd.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 06725ce97593..24788bd10c8b 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -964,10 +964,6 @@ static void nbd_bdev_reset(struct block_device *bdev)
if (bdev->bd_openers > 1)
return;
bd_set_size(bdev, 0);
- if (max_part > 0) {
- blkdev_reread_part(bdev);
- bdev->bd_invalidated = 1;
- }
}
static void nbd_parse_flags(struct nbd_device *nbd)
@@ -1282,6 +1278,9 @@ static int nbd_open(struct block_device *bdev, fmode_t mode)
refcount_set(&nbd->config_refs, 1);
refcount_inc(&nbd->refs);
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);