From: Ming Lei <ming.lei@redhat.com>
To: Niklas Cassel <Niklas.Cassel@wdc.com>
Cc: Jens Axboe <axboe@kernel.dk>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
Damien Le Moal <dlemoal@kernel.org>,
Andreas Hindborg <a.hindborg@samsung.com>,
ming.lei@redhat.com
Subject: Re: [PATCH V2] ublk: zoned: support REQ_OP_ZONE_RESET_ALL
Date: Thu, 10 Aug 2023 22:00:14 +0800 [thread overview]
Message-ID: <ZNTtbpNCiXPvRlvI@fedora> (raw)
In-Reply-To: <ZNThwMBAqqVUGtek@x1-carbon>
On Thu, Aug 10, 2023 at 01:10:30PM +0000, Niklas Cassel wrote:
> On Thu, Aug 10, 2023 at 08:43:26PM +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: Niklas Cassel <Niklas.Cassel@wdc.com>
> > Cc: Damien Le Moal <dlemoal@kernel.org>
> > Cc: Andreas Hindborg <a.hindborg@samsung.com>
> > Signed-off-by: Ming Lei <ming.lei@redhat.com>
> > ---
> > V2:
> > - update comment as reported by Niklas
> >
> > drivers/block/ublk_drv.c | 7 +++++--
> > include/uapi/linux/ublk_cmd.h | 1 +
> > 2 files changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> > index b60394fe7be6..3650ef209344 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,9 +408,8 @@ 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 */
> > + /* We do not support drv_out */
> > return BLK_STS_NOTSUPP;
> > default:
> > return BLK_STS_IOERR;
> > 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
>
> For some reason, it seems like the UBLK_IO_OP_ZONE_* values
> are identical to the REQ_OP_ZONE_* values in enum req_op:
Yeah.
I think that is zoned interface abstraction, which should be
generic enough to use linux's definition for ublk's UAPI in 1:1.
The same mapping can be found in virtio-blk zoned spec.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blk_types.h?h=v6.5-rc5#n371
>
> I don't see any obvious advantage of keeping them the same,
Not sure I follow your idea, and can you share your exact suggestion?
UBLK_IO_OP_ZONE_* is part of ublk UAPI, but REQ_OP_ZONE_* is just kernel
internal definition which may be changed time by time, so we can't use
REQ_OP_ZONE_* directly.
Here you can think of UBLK_IO_OP_ZONE_* as interface between driver and
hardware, so UBLK_IO_OP_ZONE_* has to be defined independently.
> but if you want to keep this pattern, then perhaps you want
> to define UBLK_IO_OP_ZONE_RESET_ALL to 17.
Why do you think that 17 is better than 14?
I'd rather use 14 to fill the hole, meantime the two ZONE_RESET OPs
can be kept together.
Thanks,
Ming
next prev parent reply other threads:[~2023-08-10 14:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-10 12:43 [PATCH V2] ublk: zoned: support REQ_OP_ZONE_RESET_ALL Ming Lei
2023-08-10 13:10 ` Niklas Cassel
2023-08-10 14:00 ` Ming Lei [this message]
2023-08-10 14:22 ` Niklas Cassel
2023-08-10 14:47 ` Ming Lei
2023-08-10 15:09 ` Niklas Cassel
2023-08-14 2:01 ` Ming Lei
2023-08-21 2:16 ` Ming Lei
2023-08-21 2:25 ` Jens Axboe
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=ZNTtbpNCiXPvRlvI@fedora \
--to=ming.lei@redhat.com \
--cc=Niklas.Cassel@wdc.com \
--cc=a.hindborg@samsung.com \
--cc=axboe@kernel.dk \
--cc=dlemoal@kernel.org \
--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