From: Ming Lei <ming.lei@redhat.com>
To: Jared Holzman <jholzman@nvidia.com>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>
Subject: Re: [PATCH v2] ublk: Add UBLK_U_CMD_UPDATE_SIZE
Date: Fri, 11 Apr 2025 16:02:11 +0800 [thread overview]
Message-ID: <Z_jMg4NSBe6ONzpH@fedora> (raw)
In-Reply-To: <d90ff20a-b324-49b8-bc63-7d7a35afd1f6@nvidia.com>
On Thu, Apr 10, 2025 at 03:29:38PM +0300, Jared Holzman wrote:
> Currently ublk only allows the size of the ublkb block device to be
> set via UBLK_CMD_SET_PARAMS before UBLK_CMD_START_DEV is triggered.
>
> This does not provide support for extendable user-space block devices
> without having to stop and restart the underlying ublkb block device
> causing IO interruption.
>
> This patch adds a new ublk command UBLK_U_CMD_UPDATE_SIZE to allow the
> ublk block device to be resized on-the-fly.
>
> Feature flag UBLK_F_UPDATE_SIZE is also added to indicate support for this
> command.
>
> Signed-off-by: Omri Mann <omri@nvidia.com>
> ---
> drivers/block/ublk_drv.c | 23 ++++++++++++++++++++++-
> include/uapi/linux/ublk_cmd.h | 7 +++++++
> 2 files changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> index 2fd05c1bd30b..acf8aa6c4452 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -64,7 +64,8 @@
> | UBLK_F_CMD_IOCTL_ENCODE \
> | UBLK_F_USER_COPY \
> | UBLK_F_ZONED \
> - | UBLK_F_USER_RECOVERY_FAIL_IO)
> + | UBLK_F_USER_RECOVERY_FAIL_IO \
> + | UBLK_F_UPDATE_SIZE)
>
> #define UBLK_F_ALL_RECOVERY_FLAGS (UBLK_F_USER_RECOVERY \
> | UBLK_F_USER_RECOVERY_REISSUE \
> @@ -3052,6 +3053,22 @@ static int ublk_ctrl_get_features(struct io_uring_cmd
> *cmd)
> return 0;
> }
>
> +static int ublk_ctrl_set_size(struct ublk_device *ub,
> + struct io_uring_cmd *cmd)
> +{
> + const struct ublksrv_ctrl_cmd *header = io_uring_sqe_cmd(cmd->sqe);
> + struct ublk_param_basic *p = &ub->params.basic;
> + size_t new_size = (int)header->data[0];
> + int ret = 0;
> +
> + p->dev_sectors = new_size;
The above line need to be protected by ub->mutex.
thanks,
Ming
prev parent reply other threads:[~2025-04-11 8:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 12:29 [PATCH v2] ublk: Add UBLK_U_CMD_UPDATE_SIZE Jared Holzman
2025-04-10 13:28 ` Jens Axboe
2025-04-11 8:02 ` Ming Lei [this message]
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=Z_jMg4NSBe6ONzpH@fedora \
--to=ming.lei@redhat.com \
--cc=jholzman@nvidia.com \
--cc=linux-block@vger.kernel.org \
/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