From: Sam Li <faithilikerun@gmail.com>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
qemu-devel@nongnu.org, hare@suse.de,
Hanna Reitz <hreitz@redhat.com>,
dmitry.fomichev@wdc.com, qemu-block@nongnu.org,
Kevin Wolf <kwolf@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Eric Blake <eblake@redhat.com>
Subject: Re: [PATCH v2 3/4] qcow2: add zoned emulation capability
Date: Tue, 29 Aug 2023 14:27:20 +0800 [thread overview]
Message-ID: <CAAAx-8J3TUanrC+-tpTO+xYYXH031S2AeirNAkdDE7wtGrT63g@mail.gmail.com> (raw)
In-Reply-To: <4c167bfe-2b93-358d-8e13-9e4fc1016766@kernel.org>
Damien Le Moal <dlemoal@kernel.org> 于2023年8月29日周二 14:06写道:
>
> On 8/28/23 20:55, Sam Li wrote:
> >>> + /* close one implicitly open zones to make it available */
> >>> + for (int i = s->zoned_header.zone_nr_conv;
> >>> + i < bs->bl.nr_zones; ++i) {
> >>> + uint64_t *wp = &s->wps->wp[i];
> >>> + if (qcow2_get_zs(*wp) == BLK_ZS_IOPEN) {
> >>> + ret = qcow2_write_wp_at(bs, wp, i, BLK_ZS_CLOSED);
> >>
> >> I'm wondering if it's correct to store the zone state persistently in
> >> the qcow2 file. If the guest or QEMU crashes, then zones will be left in
> >> states like EOPEN. Since the guest software will have forgotten about
> >> explicitly opened zones, the guest would need to recover zone states.
> >> I'm not sure if existing software is designed to do that.
> >>
> >> Damien: Should the zone state be persistent?
>
> Yes and no. Yes you need to preserve/maintain zone states but not as is.
> With a real drive, if you power cycle the device, you get the following states
> changes:
>
> Before | After power cycle
> ----------------+-------------------
> EMPTY | EMPTY
> FULL | FULL
> IMP. OPEN | CLOSED
> EXP. OPEN | CLOSED
> CLOSED | CLOSED
> READ=ONLY | READ-ONLY
> OFFLINE | OFFLINE
>
> So any open (implicit or explicit) zone will show up as closed after power
> cycle. That is, the number of "active" zones does not change.
> For the qcow2 emulation, as long as you do not also emulate read-only and
> offline zones, you actually do not need to save the zone state in the zone
> metadata. On startup, you can infer the state from the zone write pointer:
>
> zone wp == zone start -> EMPTY
> zone wp >= zone capacity -> FULL
> zone wp > zone start -> CLOSED
>
> And make sure that all closed zones are counted as the initial number of active
> zones. The initial number of open zones will always be 0.
>
> So it is easy :)
Thanks for the explanations!
Read-only and offline are device internal events. Does qcow2 emulation
need to emulate that?
Current NVMe ZNS emulation in QEMU has a nvme_offline_zone() function.
Does it suggest keeping the offline state persistent?
https://github.com/qemu/qemu/blob/master/hw/nvme/ctrl.c#L3740
Sam
next prev parent reply other threads:[~2023-08-29 6:28 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-14 8:57 [PATCH v2 0/4] Add full zoned storage emulation to qcow2 driver Sam Li
2023-08-14 8:57 ` [PATCH v2 1/4] docs/qcow2: add the zoned format feature Sam Li
2023-08-14 8:58 ` [PATCH v2 2/4] qcow2: add configurations for zoned format extension Sam Li
2023-08-16 19:31 ` Stefan Hajnoczi
2023-08-21 13:13 ` Markus Armbruster
2023-08-28 9:05 ` Sam Li
2023-08-21 13:31 ` Stefan Hajnoczi
2023-08-28 9:22 ` Sam Li
2023-08-28 10:12 ` Damien Le Moal
2023-08-28 10:18 ` Sam Li
2023-08-28 10:22 ` Damien Le Moal
2023-08-28 10:40 ` Sam Li
2023-08-28 14:42 ` Sam Li
2023-08-14 8:58 ` [PATCH v2 3/4] qcow2: add zoned emulation capability Sam Li
2023-08-16 21:07 ` Stefan Hajnoczi
2023-08-22 19:48 ` Stefan Hajnoczi
2023-08-28 11:55 ` Sam Li
2023-08-29 6:06 ` Damien Le Moal
2023-08-29 6:27 ` Sam Li [this message]
2023-08-29 7:14 ` Damien Le Moal
2023-08-29 7:27 ` Sam Li
2023-08-14 8:58 ` [PATCH v2 4/4] iotests: test the zoned format feature for qcow2 file Sam Li
2023-08-22 19:50 ` Stefan Hajnoczi
2023-08-16 7:37 ` [PATCH v2 0/4] Add full zoned storage emulation to qcow2 driver Klaus Jensen
2023-08-16 8:14 ` Sam Li
2023-08-16 18:03 ` Stefan Hajnoczi
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-8J3TUanrC+-tpTO+xYYXH031S2AeirNAkdDE7wtGrT63g@mail.gmail.com \
--to=faithilikerun@gmail.com \
--cc=armbru@redhat.com \
--cc=dlemoal@kernel.org \
--cc=dmitry.fomichev@wdc.com \
--cc=eblake@redhat.com \
--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).