Skip to content

Commit 07a1141

Browse files
Christoph Hellwigaxboe
authored andcommitted
nbd: don't call blk_mark_disk_dead nbd_clear_sock_ioctl
blk_mark_disk_dead is the proper interface to shut down a block device, but it also makes the disk unusable forever. nbd_clear_sock_ioctl on the other hand wants to shut down the file system, but allow the block device to be used again when when connected to another socket. Switch nbd to use disk_force_media_change and nbd_bdev_reset to go back to a behavior of the old __invalidate_device call, with the added benefit of incrementing the device generation as there is no guarantee the old content comes back when the device is reconnected. Reported-by: Samuel Holland <samuel.holland@sifive.com> Reported-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com> Fixes: 0c1c9a2 ("nbd: call blk_mark_disk_dead in nbd_clear_sock_ioctl") Signed-off-by: Christoph Hellwig <hch@lst.de> Tested-by: Samuel Holland <samuel.holland@sifive.com> Link: https://lore.kernel.org/r/20231003153106.1331363-1-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent e680a14 commit 07a1141

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/block/nbd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1436,8 +1436,9 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd)
14361436

14371437
static void nbd_clear_sock_ioctl(struct nbd_device *nbd)
14381438
{
1439-
blk_mark_disk_dead(nbd->disk);
14401439
nbd_clear_sock(nbd);
1440+
disk_force_media_change(nbd->disk);
1441+
nbd_bdev_reset(nbd);
14411442
if (test_and_clear_bit(NBD_RT_HAS_CONFIG_REF,
14421443
&nbd->config->runtime_flags))
14431444
nbd_config_put(nbd);

0 commit comments

Comments
 (0)