Re: [PATCH 07/17] nbd: call blk_mark_disk_dead in nbd_clear_sock_ioctl
- To: Christoph Hellwig <hch@lst.de>, Wouter Verhelst <w@uter.be>
- Cc: Al Viro <viro@zeniv.linux.org.uk>, Christian Brauner <brauner@kernel.org>, Jens Axboe <axboe@kernel.dk>, Denis Efremov <efremov@linux.com>, Josef Bacik <josef@toxicpanda.com>, Stefan Haberland <sth@linux.ibm.com>, Jan Hoeppner <hoeppner@linux.ibm.com>, Heiko Carstens <hca@linux.ibm.com>, Vasily Gorbik <gor@linux.ibm.com>, Alexander Gordeev <agordeev@linux.ibm.com>, "Darrick J . Wong" <djwong@kernel.org>, Chris Mason <clm@fb.com>, David Sterba <dsterba@suse.com>, linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
- Subject: Re: [PATCH 07/17] nbd: call blk_mark_disk_dead in nbd_clear_sock_ioctl
- From: Samuel Holland <samuel.holland@sifive.com>
- Date: Mon, 2 Oct 2023 14:15:36 -0500
- Message-id: <[🔎] 3a5e1f6e-5fa9-46ea-8828-ca4679bf0c77@sifive.com>
- In-reply-to: <[🔎] 20231002062159.GB1140@lst.de>
- References: <20230811100828.1897174-1-hch@lst.de> <20230811100828.1897174-8-hch@lst.de> <79af9398-167f-440e-a493-390dc4ccbd85@sifive.com> <20230925074838.GA28522@lst.de> <[🔎] ZRmoHaSojk6ra5OU@pc220518.home.grep.be> <[🔎] 20231002062159.GB1140@lst.de>
On 2023-10-02 1:21 AM, Christoph Hellwig wrote:
> On Sun, Oct 01, 2023 at 07:10:53PM +0200, Wouter Verhelst wrote:
>>> So what are the semantics of clearing the socket?
>>>
>>> The <= 6.5 behavior of invalidating fs caches, but not actually marking
>>> the fs shutdown is pretty broken, especially if this expects to resurrect
>>> the device and thus the file system later on.
>>
>> nbd-client -d calls
>>
>> ioctl(nbd, NBD_DISCONNECT);
>> ioctl(nbd, NBD_CLEAR_SOCK);
>>
>> (error handling removed for clarity)
>>
>> where "nbd" is the file handle to the nbd device. This expects that the
>> device is cleared and that then the device can be reused for a different
>> connection, much like "losetup -d". Expecting that the next connection
>> would talk to the same file system is wrong.
>
> So a fs shutdown seems like a the right thing. So I'm a little confused
> on what actualy broke here.
I'm not too familiar with the block subsystem, but my understanding is that
blk_mark_disk_dead(nbd->disk) is permanent -- there is no way to un-mark a disk
as dead. So this makes the device (e.g. /dev/nbd0) permanently unusable after
the call to ioctl(nbd, NBD_CLEAR_SOCK).
Like Wouter said, the semantics should be similar to a loop device, where the
same block device can be reused after being disconnected. That was why I
suggested disk_force_media_change() as called from __loop_clr_fd(). The loop
driver doesn't call blk_mark_disk_dead() anywhere.
Regards,
Samuel
Reply to: