nbd: don't call blk_mark_disk_dead nbd_clear_sock_ioctl
Subsystems (2)
PATCH 1/1 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.
--- drivers/block/nbd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/nbd.c +2 -1
@@ -1436,8 +1436,9 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd)static void nbd_clear_sock_ioctl (struct nbd_device *nbd) { -blk_mark_disk_dead (nbd->disk);nbd_clear_sock (nbd); +disk_force_media_change (nbd->disk); +nbd_bdev_reset (nbd);if (test_and_clear_bit (NBD_RT_HAS_CONFIG_REF , &nbd->config->runtime_flags))nbd_config_put (nbd);
Signature · 1 line
2.39.2
Quoted 11 lines · Christoph Hellwig
blk_mark_disk_deadis the proper interface to shut down a block device, but it also makes the disk unusable forever.
nbd_clear_sock_ioctlon 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 usedisk_force_media_changeandnbd_bdev_resetto go back to a behavior of the old__invalidate_devicecall, with the added benefit of incrementing the device generation as there is no guarantee the old content comes back when the device is reconnected.
Quoted 7 lines
Reported-by Samuel Holland <[email protected]>Reported-by Shinichiro Kawasaki <[email protected]>Fixes 0c1c9a27ce90 ("nbd: call blk_mark_disk_dead in nbd_clear_sock_ioctl")Signed-off-by Christoph Hellwig <[email protected]>--- drivers/block/nbd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Thanks for the fix!
Quoted 11 lines · Christoph Hellwig
blk_mark_disk_deadis the proper interface to shut down a block device, but it also makes the disk unusable forever.
nbd_clear_sock_ioctlon 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 usedisk_force_media_changeandnbd_bdev_resetto go back to a behavior of the old__invalidate_devicecall, with the added benefit of incrementing the device generation as there is no guarantee the old content comes back when the device is reconnected.
Quoted 1 line
[...]
Applied, thanks!
[1/1] nbd: don't call blk_mark_disk_dead nbd_clear_sock_ioctl
commit: 07a1141ff170ff5d4f9c4fbb0453727ab48096e5
Best regards,
Signature · 1 line
Jens Axboe
Quoted 11 lines · Christoph Hellwig
blk_mark_disk_deadis the proper interface to shut down a block device, but it also makes the disk unusable forever.
nbd_clear_sock_ioctlon 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 usedisk_force_media_changeandnbd_bdev_resetto go back to a behavior of the old__invalidate_devicecall, with the added benefit of incrementing the device generation as there is no guarantee the old content comes back when the device is reconnected.
Quoted 4 lines
Reported-by Samuel Holland <[email protected]>Reported-by Shinichiro Kawasaki <[email protected]>Fixes 0c1c9a27ce90 ("nbd: call blk_mark_disk_dead in nbd_clear_sock_ioctl")Signed-off-by Christoph Hellwig <[email protected]>
I also confirmed this patch fixes the issue that Samuel and I reported. Thanks!