* [PATCH] ublk: zoned: support REQ_OP_ZONE_RESET_ALL
@ 2023-08-10 9:20 Ming Lei
2023-08-10 11:51 ` Niklas Cassel
0 siblings, 1 reply; 3+ messages in thread
From: Ming Lei @ 2023-08-10 9:20 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Ming Lei, Damien Le Moal, Andreas Hindborg
There isn't any reason to not support REQ_OP_ZONE_RESET_ALL given everything
is actually handled in userspace, not mention it is pretty easy to support
RESET_ALL.
So enable REQ_OP_ZONE_RESET_ALL and let userspace handle it.
Verified by 'tools/zbc_reset_zone -all /dev/ublkb0' in libzbc[1] with
libublk-rs based ublk-zoned target prototype[2], follows command line
for creating ublk-zoned:
cargo run --example zoned -- add -1 1024 # add $dev_id $DEV_SIZE
[1] https://github.com/westerndigitalcorporation/libzbc
[2] https://github.com/ming1/libublk-rs/tree/zoned.v2
Cc: Damien Le Moal <dlemoal@kernel.org>
Cc: Andreas Hindborg <a.hindborg@samsung.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
drivers/block/ublk_drv.c | 5 ++++-
include/uapi/linux/ublk_cmd.h | 1 +
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 109a5b17537d..939e4584485b 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -251,6 +251,7 @@ static int ublk_dev_param_zoned_apply(struct ublk_device *ub)
const struct ublk_param_zoned *p = &ub->params.zoned;
disk_set_zoned(ub->ub_disk, BLK_ZONED_HM);
+ blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, ub->ub_disk->queue);
blk_queue_required_elevator_features(ub->ub_disk->queue,
ELEVATOR_F_ZBD_SEQ_WRITE);
disk_set_max_active_zones(ub->ub_disk, p->max_active_zones);
@@ -393,6 +394,9 @@ static blk_status_t ublk_setup_iod_zoned(struct ublk_queue *ubq,
case REQ_OP_ZONE_APPEND:
ublk_op = UBLK_IO_OP_ZONE_APPEND;
break;
+ case REQ_OP_ZONE_RESET_ALL:
+ ublk_op = UBLK_IO_OP_ZONE_RESET_ALL;
+ break;
case REQ_OP_DRV_IN:
ublk_op = pdu->operation;
switch (ublk_op) {
@@ -404,7 +408,6 @@ static blk_status_t ublk_setup_iod_zoned(struct ublk_queue *ubq,
default:
return BLK_STS_IOERR;
}
- case REQ_OP_ZONE_RESET_ALL:
case REQ_OP_DRV_OUT:
/* We do not support reset_all and drv_out */
return BLK_STS_NOTSUPP;
diff --git a/include/uapi/linux/ublk_cmd.h b/include/uapi/linux/ublk_cmd.h
index 2685e53e4752..b9cfc5c96268 100644
--- a/include/uapi/linux/ublk_cmd.h
+++ b/include/uapi/linux/ublk_cmd.h
@@ -245,6 +245,7 @@ struct ublksrv_ctrl_dev_info {
#define UBLK_IO_OP_ZONE_CLOSE 11
#define UBLK_IO_OP_ZONE_FINISH 12
#define UBLK_IO_OP_ZONE_APPEND 13
+#define UBLK_IO_OP_ZONE_RESET_ALL 14
#define UBLK_IO_OP_ZONE_RESET 15
/*
* Construct a zone report. The report request is carried in `struct
--
2.40.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ublk: zoned: support REQ_OP_ZONE_RESET_ALL
2023-08-10 9:20 [PATCH] ublk: zoned: support REQ_OP_ZONE_RESET_ALL Ming Lei
@ 2023-08-10 11:51 ` Niklas Cassel
2023-08-10 12:15 ` Ming Lei
0 siblings, 1 reply; 3+ messages in thread
From: Niklas Cassel @ 2023-08-10 11:51 UTC (permalink / raw)
To: Ming Lei; +Cc: Jens Axboe, linux-block, Damien Le Moal, Andreas Hindborg
Hello Ming,
On Thu, Aug 10, 2023 at 05:20:57PM +0800, Ming Lei wrote:
> There isn't any reason to not support REQ_OP_ZONE_RESET_ALL given everything
> is actually handled in userspace, not mention it is pretty easy to support
> RESET_ALL.
>
> So enable REQ_OP_ZONE_RESET_ALL and let userspace handle it.
>
> Verified by 'tools/zbc_reset_zone -all /dev/ublkb0' in libzbc[1] with
> libublk-rs based ublk-zoned target prototype[2], follows command line
> for creating ublk-zoned:
>
> cargo run --example zoned -- add -1 1024 # add $dev_id $DEV_SIZE
>
> [1] https://github.com/westerndigitalcorporation/libzbc
> [2] https://github.com/ming1/libublk-rs/tree/zoned.v2
>
> Cc: Damien Le Moal <dlemoal@kernel.org>
> Cc: Andreas Hindborg <a.hindborg@samsung.com>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> drivers/block/ublk_drv.c | 5 ++++-
> include/uapi/linux/ublk_cmd.h | 1 +
> 2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> index 109a5b17537d..939e4584485b 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -251,6 +251,7 @@ static int ublk_dev_param_zoned_apply(struct ublk_device *ub)
> const struct ublk_param_zoned *p = &ub->params.zoned;
>
> disk_set_zoned(ub->ub_disk, BLK_ZONED_HM);
> + blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, ub->ub_disk->queue);
> blk_queue_required_elevator_features(ub->ub_disk->queue,
> ELEVATOR_F_ZBD_SEQ_WRITE);
> disk_set_max_active_zones(ub->ub_disk, p->max_active_zones);
> @@ -393,6 +394,9 @@ static blk_status_t ublk_setup_iod_zoned(struct ublk_queue *ubq,
> case REQ_OP_ZONE_APPEND:
> ublk_op = UBLK_IO_OP_ZONE_APPEND;
> break;
> + case REQ_OP_ZONE_RESET_ALL:
> + ublk_op = UBLK_IO_OP_ZONE_RESET_ALL;
> + break;
> case REQ_OP_DRV_IN:
> ublk_op = pdu->operation;
> switch (ublk_op) {
> @@ -404,7 +408,6 @@ static blk_status_t ublk_setup_iod_zoned(struct ublk_queue *ubq,
> default:
> return BLK_STS_IOERR;
> }
> - case REQ_OP_ZONE_RESET_ALL:
> case REQ_OP_DRV_OUT:
> /* We do not support reset_all and drv_out */
I think that you should also drop reset_all from this comment.
Kind regards,
Niklas
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ublk: zoned: support REQ_OP_ZONE_RESET_ALL
2023-08-10 11:51 ` Niklas Cassel
@ 2023-08-10 12:15 ` Ming Lei
0 siblings, 0 replies; 3+ messages in thread
From: Ming Lei @ 2023-08-10 12:15 UTC (permalink / raw)
To: Niklas Cassel; +Cc: Jens Axboe, linux-block, Damien Le Moal, Andreas Hindborg
On Thu, Aug 10, 2023 at 11:51:38AM +0000, Niklas Cassel wrote:
> Hello Ming,
>
> On Thu, Aug 10, 2023 at 05:20:57PM +0800, Ming Lei wrote:
> > There isn't any reason to not support REQ_OP_ZONE_RESET_ALL given everything
> > is actually handled in userspace, not mention it is pretty easy to support
> > RESET_ALL.
> >
> > So enable REQ_OP_ZONE_RESET_ALL and let userspace handle it.
> >
> > Verified by 'tools/zbc_reset_zone -all /dev/ublkb0' in libzbc[1] with
> > libublk-rs based ublk-zoned target prototype[2], follows command line
> > for creating ublk-zoned:
> >
> > cargo run --example zoned -- add -1 1024 # add $dev_id $DEV_SIZE
> >
> > [1] https://github.com/westerndigitalcorporation/libzbc
> > [2] https://github.com/ming1/libublk-rs/tree/zoned.v2
> >
> > Cc: Damien Le Moal <dlemoal@kernel.org>
> > Cc: Andreas Hindborg <a.hindborg@samsung.com>
> > Signed-off-by: Ming Lei <ming.lei@redhat.com>
> > ---
> > drivers/block/ublk_drv.c | 5 ++++-
> > include/uapi/linux/ublk_cmd.h | 1 +
> > 2 files changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> > index 109a5b17537d..939e4584485b 100644
> > --- a/drivers/block/ublk_drv.c
> > +++ b/drivers/block/ublk_drv.c
> > @@ -251,6 +251,7 @@ static int ublk_dev_param_zoned_apply(struct ublk_device *ub)
> > const struct ublk_param_zoned *p = &ub->params.zoned;
> >
> > disk_set_zoned(ub->ub_disk, BLK_ZONED_HM);
> > + blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, ub->ub_disk->queue);
> > blk_queue_required_elevator_features(ub->ub_disk->queue,
> > ELEVATOR_F_ZBD_SEQ_WRITE);
> > disk_set_max_active_zones(ub->ub_disk, p->max_active_zones);
> > @@ -393,6 +394,9 @@ static blk_status_t ublk_setup_iod_zoned(struct ublk_queue *ubq,
> > case REQ_OP_ZONE_APPEND:
> > ublk_op = UBLK_IO_OP_ZONE_APPEND;
> > break;
> > + case REQ_OP_ZONE_RESET_ALL:
> > + ublk_op = UBLK_IO_OP_ZONE_RESET_ALL;
> > + break;
> > case REQ_OP_DRV_IN:
> > ublk_op = pdu->operation;
> > switch (ublk_op) {
> > @@ -404,7 +408,6 @@ static blk_status_t ublk_setup_iod_zoned(struct ublk_queue *ubq,
> > default:
> > return BLK_STS_IOERR;
> > }
> > - case REQ_OP_ZONE_RESET_ALL:
> > case REQ_OP_DRV_OUT:
> > /* We do not support reset_all and drv_out */
>
> I think that you should also drop reset_all from this comment.
Good catch, will do it in v2.
Thanks,
Ming
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-10 12:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-10 9:20 [PATCH] ublk: zoned: support REQ_OP_ZONE_RESET_ALL Ming Lei
2023-08-10 11:51 ` Niklas Cassel
2023-08-10 12:15 ` Ming Lei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).