Skip to content

Commit fe1f9e6

Browse files
Josef Bacikaxboe
authored andcommitted
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 <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 96d97e1 commit fe1f9e6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/block/nbd.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -964,10 +964,6 @@ static void nbd_bdev_reset(struct block_device *bdev)
964964
if (bdev->bd_openers > 1)
965965
return;
966966
bd_set_size(bdev, 0);
967-
if (max_part > 0) {
968-
blkdev_reread_part(bdev);
969-
bdev->bd_invalidated = 1;
970-
}
971967
}
972968

973969
static void nbd_parse_flags(struct nbd_device *nbd)
@@ -1282,6 +1278,9 @@ static int nbd_open(struct block_device *bdev, fmode_t mode)
12821278
refcount_set(&nbd->config_refs, 1);
12831279
refcount_inc(&nbd->refs);
12841280
mutex_unlock(&nbd->config_lock);
1281+
bdev->bd_invalidated = 1;
1282+
} else if (nbd_disconnected(nbd->config)) {
1283+
bdev->bd_invalidated = 1;
12851284
}
12861285
out:
12871286
mutex_unlock(&nbd_index_mutex);

0 commit comments

Comments
 (0)