From: lining <lining2020x@163.com>
To: Ming Lei <ming.lei@redhat.com>, Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Josef Bacik <josef@toxicpanda.com>,
Jan Kara <jack@suse.cz>,
yanhaishuang@cmss.chinamobile.com
Subject: Re: [PATCH] nbd: don't update block size after device is started
Date: Thu, 29 Oct 2020 11:13:05 +0800 [thread overview]
Message-ID: <4145dd3d-dc1b-9833-9be6-9550eb2fcd13@163.com> (raw)
In-Reply-To: <20201028072434.1922108-1-ming.lei@redhat.com>
Tested on Ubuntu 20.04.1 LTS with kernel 5.10.0-rc1+, it works fine.
Tested-by: lining <lining2020x@163.com>
在 2020/10/28 15:24, Ming Lei 写道:
> Mounted NBD device can be resized, one use case is rbd-nbd.
>
> Fix the issue by setting up default block size, then not touch it
> in nbd_size_update() any more. This kind of usage is aligned with loop
> which has same use case too.
>
> Reported-by: lining <lining2020x@163.com>
> Cc: Josef Bacik <josef@toxicpanda.com>
> Cc: Jan Kara <jack@suse.cz>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> drivers/block/nbd.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index 3c9485acdd81..e13ce0f75f80 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -296,7 +296,7 @@ static void nbd_size_clear(struct nbd_device *nbd)
> }
> }
>
> -static void nbd_size_update(struct nbd_device *nbd)
> +static void nbd_size_update(struct nbd_device *nbd, bool start)
> {
> struct nbd_config *config = nbd->config;
> struct block_device *bdev = bdget_disk(nbd->disk, 0);
> @@ -313,7 +313,8 @@ static void nbd_size_update(struct nbd_device *nbd)
> if (bdev) {
> if (bdev->bd_disk) {
> bd_set_nr_sectors(bdev, nr_sectors);
> - set_blocksize(bdev, config->blksize);
> + if (start)
> + set_blocksize(bdev, config->blksize);
> } else
> set_bit(GD_NEED_PART_SCAN, &nbd->disk->state);
> bdput(bdev);
> @@ -328,7 +329,7 @@ static void nbd_size_set(struct nbd_device *nbd, loff_t blocksize,
> config->blksize = blocksize;
> config->bytesize = blocksize * nr_blocks;
> if (nbd->task_recv != NULL)
> - nbd_size_update(nbd);
> + nbd_size_update(nbd, false);
> }
>
> static void nbd_complete_rq(struct request *req)
> @@ -1308,7 +1309,7 @@ static int nbd_start_device(struct nbd_device *nbd)
> args->index = i;
> queue_work(nbd->recv_workq, &args->work);
> }
> - nbd_size_update(nbd);
> + nbd_size_update(nbd, true);
> return error;
> }
>
>
next prev parent reply other threads:[~2020-10-29 7:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-28 7:24 [PATCH] nbd: don't update block size after device is started Ming Lei
2020-10-29 3:13 ` lining [this message]
2020-10-29 3:24 ` Jens Axboe
2020-10-29 7:51 ` Christoph Hellwig
2020-10-29 8:40 ` Ming Lei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4145dd3d-dc1b-9833-9be6-9550eb2fcd13@163.com \
--to=lining2020x@163.com \
--cc=axboe@kernel.dk \
--cc=jack@suse.cz \
--cc=josef@toxicpanda.com \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=yanhaishuang@cmss.chinamobile.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox