Re: [PATCH 01/14] nbd: use the correct block_device in nbd_bdev_reset
- To: Christoph Hellwig <hch@lst.de>
- Cc: Jens Axboe <axboe@kernel.dk>, Josef Bacik <josef@toxicpanda.com>, Minchan Kim <minchan@kernel.org>, Nitin Gupta <ngupta@vflare.org>, Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>, Jan Kara <jack@suse.cz>, "Darrick J . Wong" <djwong@kernel.org>, Ming Lei <ming.lei@redhat.com>, Matteo Croce <mcroce@microsoft.com>, linux-block@vger.kernel.org, nbd@other.debian.org
- Subject: Re: [PATCH 01/14] nbd: use the correct block_device in nbd_bdev_reset
- From: Jan Kara <jack@suse.cz>
- Date: Fri, 25 Mar 2022 10:48:20 +0100
- Message-id: <[🔎] 20220325094820.jxyqgjxdx7ulgmo2@quack3.lan>
- In-reply-to: <[🔎] 20220325063929.1773899-2-hch@lst.de>
- References: <[🔎] 20220325063929.1773899-1-hch@lst.de> <[🔎] 20220325063929.1773899-2-hch@lst.de>
On Fri 25-03-22 07:39:16, Christoph Hellwig wrote:
> The bdev parameter to ->ioctl contains the block device that the ioctl
> is called on, which can be the partition. But the openers check in
> nbd_bdev_reset really needs to check use the whole device, so switch to
> using that.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> drivers/block/nbd.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index 5a1f98494dddf..2f29da41fbc80 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -1217,11 +1217,11 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)
> return -ENOSPC;
> }
>
> -static void nbd_bdev_reset(struct block_device *bdev)
> +static void nbd_bdev_reset(struct nbd_device *nbd)
> {
> - if (bdev->bd_openers > 1)
> + if (nbd->disk->part0->bd_openers > 1)
> return;
> - set_capacity(bdev->bd_disk, 0);
> + set_capacity(nbd->disk, 0);
> }
>
> static void nbd_parse_flags(struct nbd_device *nbd)
> @@ -1389,7 +1389,7 @@ static int nbd_start_device(struct nbd_device *nbd)
> return nbd_set_size(nbd, config->bytesize, nbd_blksize(config));
> }
>
> -static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *bdev)
> +static int nbd_start_device_ioctl(struct nbd_device *nbd)
> {
> struct nbd_config *config = nbd->config;
> int ret;
> @@ -1408,7 +1408,7 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *b
> flush_workqueue(nbd->recv_workq);
>
> mutex_lock(&nbd->config_lock);
> - nbd_bdev_reset(bdev);
> + nbd_bdev_reset(nbd);
> /* user requested, ignore socket errors */
> if (test_bit(NBD_RT_DISCONNECT_REQUESTED, &config->runtime_flags))
> ret = 0;
> @@ -1422,7 +1422,7 @@ static void nbd_clear_sock_ioctl(struct nbd_device *nbd,
> {
> sock_shutdown(nbd);
> __invalidate_device(bdev, true);
> - nbd_bdev_reset(bdev);
> + nbd_bdev_reset(nbd);
> if (test_and_clear_bit(NBD_RT_HAS_CONFIG_REF,
> &nbd->config->runtime_flags))
> nbd_config_put(nbd);
> @@ -1468,7 +1468,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
> config->flags = arg;
> return 0;
> case NBD_DO_IT:
> - return nbd_start_device_ioctl(nbd, bdev);
> + return nbd_start_device_ioctl(nbd);
> case NBD_CLEAR_QUE:
> /*
> * This is for compatibility only. The queue is always cleared
> --
> 2.30.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
Reply to: