qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Sam Li <faithilikerun@gmail.com>
To: Hannes Reinecke <hare@suse.de>
Cc: qemu-devel <qemu-devel@nongnu.org>,
	 Damien Le Moal <damien.lemoal@opensource.wdc.com>,
	Markus Armbruster <armbru@redhat.com>,
	 Dmitry Fomichev <dmitry.fomichev@wdc.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	 Hanna Reitz <hreitz@redhat.com>,
	qemu block <qemu-block@nongnu.org>,
	 Eric Blake <eblake@redhat.com>, Kevin Wolf <kwolf@redhat.com>,
	Fam Zheng <fam@euphon.net>
Subject: Re: [RFC v4 1/9] block: add block layer APIs resembling Linux ZonedBlockDevice ioctls.
Date: Tue, 12 Jul 2022 14:17:21 +0800	[thread overview]
Message-ID: <CAAAx-8Lk_aBd0SFSULszrRgA82Ecz3XMPayFQBcC0T=oBx_RaA@mail.gmail.com> (raw)
In-Reply-To: <f864ff9b-c8ed-2336-f5a8-d4819475dc0b@suse.de>

Hannes Reinecke <hare@suse.de> 于2022年7月12日周二 14:10写道:
>
> On 7/12/22 04:13, Sam Li wrote:
> > By adding zone management operations in BlockDriver, storage
> > controller emulation can use the new block layer APIs including
> > zone_report and zone_mgmt(open, close, finish, reset).
> >
> > Signed-off-by: Sam Li <faithilikerun@gmail.com>
> > ---
> >   block/block-backend.c            |  41 ++++++
> >   block/coroutines.h               |   5 +
> >   block/file-posix.c               | 236 +++++++++++++++++++++++++++++++
> >   include/block/block-common.h     |  43 +++++-
> >   include/block/block_int-common.h |  20 +++
> >   5 files changed, 344 insertions(+), 1 deletion(-)
> >
> > diff --git a/block/block-backend.c b/block/block-backend.c
> > index f425b00793..0a05247ae4 100644
> > --- a/block/block-backend.c
> > +++ b/block/block-backend.c
> > @@ -1806,6 +1806,47 @@ int blk_flush(BlockBackend *blk)
> >       return ret;
> >   }
> >
> > +/*
> > + * Send a zone_report command.
> > + * offset can be any number within the zone size. No alignment for offset.
> > + * nr_zones represents IN maximum and OUT actual.
> > + */
> > +int coroutine_fn blk_co_zone_report(BlockBackend *blk, int64_t offset,
> > +                                    int64_t *nr_zones,
> > +                                    BlockZoneDescriptor *zones)
> > +{
> > +    int ret;
> > +    IO_CODE();
> > +
> > +    blk_inc_in_flight(blk); /* increase before waiting */
> > +    blk_wait_while_drained(blk);
> > +    ret = bdrv_co_zone_report(blk->root->bs, offset, nr_zones, zones);
> > +    blk_dec_in_flight(blk);
> > +    return ret;
> > +}
> > +
> > +/*
> > + * Send a zone_management command.
> > + * Offset is the start of a zone and len is aligned to zones.
> > + */
> > +int coroutine_fn blk_co_zone_mgmt(BlockBackend *blk, enum zone_op op,
> > +        int64_t offset, int64_t len)
> > +{
> > +    int ret;
> > +    IO_CODE();
> > +
> > +    blk_inc_in_flight(blk);
> > +    blk_wait_while_drained(blk);
> > +    ret = blk_check_byte_request(blk, offset, len);
> > +    if (ret < 0) {
> > +        return ret;
> > +    }
> > +
> > +    ret = bdrv_co_zone_mgmt(blk->root->bs, op, offset, len);
> > +    blk_dec_in_flight(blk);
> > +    return ret;
> > +}
> > +
> >   void blk_drain(BlockBackend *blk)
> >   {
> >       BlockDriverState *bs = blk_bs(blk);
> > diff --git a/block/coroutines.h b/block/coroutines.h
> > index 830ecaa733..19aa96cc56 100644
> > --- a/block/coroutines.h
> > +++ b/block/coroutines.h
> > @@ -80,6 +80,11 @@ int coroutine_fn
> >   blk_co_do_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes);
> >
> >   int coroutine_fn blk_co_do_flush(BlockBackend *blk);
> > +int coroutine_fn blk_co_zone_report(BlockBackend *blk, int64_t offset,
> > +                                    int64_t *nr_zones,
> > +                                    BlockZoneDescriptor *zones);
> > +int coroutine_fn blk_co_zone_mgmt(BlockBackend *blk, enum zone_op op,
> > +                                  int64_t offset, int64_t len);
> >
> >
> >   /*
> > diff --git a/block/file-posix.c b/block/file-posix.c
> > index 48cd096624..e7523ae2ed 100644
> > --- a/block/file-posix.c
> > +++ b/block/file-posix.c
> > @@ -67,6 +67,7 @@
> >   #include <sys/param.h>
> >   #include <sys/syscall.h>
> >   #include <sys/vfs.h>
> > +#include <linux/blkzoned.h>
> >   #include <linux/cdrom.h>
> >   #include <linux/fd.h>
> >   #include <linux/fs.h>
> > @@ -216,6 +217,13 @@ typedef struct RawPosixAIOData {
> >               PreallocMode prealloc;
> >               Error **errp;
> >           } truncate;
> > +        struct {
> > +            int64_t *nr_zones;
>
> Why is this a pointer?
> I'd rather use a number here, seeing that it's the number
> of zones in the *zones array ...

I see. The pointer is a little redundant. Will change it.

> But the remainder looks good.

Thanks for reviewing!


  reply	other threads:[~2022-07-12  6:33 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-12  2:13 [RFC v4 0/9] Add support for zoned device Sam Li
2022-07-12  2:13 ` [RFC v4 1/9] block: add block layer APIs resembling Linux ZonedBlockDevice ioctls Sam Li
2022-07-12  6:10   ` Hannes Reinecke
2022-07-12  6:17     ` Sam Li [this message]
2022-07-12  7:35   ` Damien Le Moal
2022-07-13  0:54     ` Sam Li
2022-07-12 15:49   ` Stefan Hajnoczi
2022-07-12 22:12     ` Damien Le Moal
2022-07-13  6:22       ` Stefan Hajnoczi
2022-07-13  0:51     ` Sam Li
2022-07-13  6:19       ` Stefan Hajnoczi
2022-07-12  2:13 ` [RFC v4 2/9] qemu-io: add zoned block device operations Sam Li
2022-07-12  6:14   ` Hannes Reinecke
2022-07-12  7:44   ` Damien Le Moal
2022-07-27 14:13   ` Stefan Hajnoczi
2022-07-28  1:57     ` Damien Le Moal
2022-07-12  2:13 ` [RFC v4 3/9] file-posix: introduce get_sysfs_long_val for a block queue of sysfs attribute Sam Li
2022-07-12  6:16   ` Hannes Reinecke
2022-07-12  7:37   ` Damien Le Moal
2022-07-12  2:13 ` [RFC v4 4/9] file-posix: introduce get_sysfs_str_val for device zoned model Sam Li
2022-07-12  6:17   ` Hannes Reinecke
2022-07-12  6:35     ` Damien Le Moal
2022-07-12  7:42   ` Damien Le Moal
2022-07-12  2:13 ` [RFC v4 5/9] qemu-iotests: test new zone operations Sam Li
2022-07-27 14:34   ` Stefan Hajnoczi
2022-07-27 14:59     ` Ming Lei
2022-07-27 15:12       ` Stefan Hajnoczi
2022-07-12  2:13 ` [RFC v4 6/9] raw-format: add " Sam Li
2022-07-27 14:39   ` Stefan Hajnoczi
2022-07-12  2:13 ` [RFC v4 7/9] config: add check to block layer Sam Li
2022-07-27 14:50   ` Stefan Hajnoczi
2022-07-12  2:13 ` [RFC v4 8/9] include: add support for zoned block devices Sam Li
2022-07-27 14:52   ` Stefan Hajnoczi
2022-07-12  2:13 ` [RFC v4 9/9] qapi: add support for zoned host device Sam Li
2022-07-12  7:48   ` Damien Le Moal
2022-07-27 14:53   ` Stefan Hajnoczi
2022-07-12  5:47 ` [RFC v4 0/9] Add support for zoned device Markus Armbruster
2022-07-12  5:59   ` Sam Li
2022-07-18 10:53     ` Markus Armbruster
2022-07-27 14:55 ` Stefan Hajnoczi
2022-07-27 15:06 ` Stefan Hajnoczi
2022-07-27 15:14   ` Sam Li

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='CAAAx-8Lk_aBd0SFSULszrRgA82Ecz3XMPayFQBcC0T=oBx_RaA@mail.gmail.com' \
    --to=faithilikerun@gmail.com \
    --cc=armbru@redhat.com \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=dmitry.fomichev@wdc.com \
    --cc=eblake@redhat.com \
    --cc=fam@euphon.net \
    --cc=hare@suse.de \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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;
as well as URLs for NNTP newsgroup(s).