qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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 15:27:42 +0800	[thread overview]
Message-ID: <CAAAx-8La8Pfb6hUrJGyZZe=Yik694mFDmq_NyEUgY40tdZeG6w@mail.gmail.com> (raw)
In-Reply-To: <1bedb9e9-63f5-9986-ce07-808c8892a1ea@kernel.org>

Damien Le Moal <dlemoal@kernel.org> 于2023年8月29日周二 15:14写道:
>
> On 8/29/23 15:27, Sam Li wrote:
> > 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
>
> The offline state is useful for testing only. If a zone goes offline, it
> generally means that the device is dying...
> At least for now, I do not think it is needed for qcow2. That can always be
> added later.

Ok. Then the wps of zoned metadata structure would be almost like
zoned emulation in file-posix. Current wp design can still preserve as
is. Though, it will be only in memory then.

This change will be reflected in v4 (newest v3 for now).

Sam


  reply	other threads:[~2023-08-29  7:29 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
2023-08-29  7:14           ` Damien Le Moal
2023-08-29  7:27             ` Sam Li [this message]
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-8La8Pfb6hUrJGyZZe=Yik694mFDmq_NyEUgY40tdZeG6w@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).