[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 3/4] qcow2: add zoned emulation capability
From: |
Sam Li |
Subject: |
Re: [PATCH v2 3/4] qcow2: add zoned emulation capability |
Date: |
Tue, 29 Aug 2023 15:27:42 +0800 |
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
[PATCH v2 3/4] qcow2: add zoned emulation capability, Sam Li, 2023/08/14
[PATCH v2 4/4] iotests: test the zoned format feature for qcow2 file, Sam Li, 2023/08/14
Re: [PATCH v2 0/4] Add full zoned storage emulation to qcow2 driver, Klaus Jensen, 2023/08/16