qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/5] Add persistence to NVMe ZNS emulation
@ 2023-08-16  6:46 Sam Li
  2023-08-16  6:46 ` [RFC 1/5] hw/nvme: use blk_get_*() to access zone info in the block layer Sam Li
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Sam Li @ 2023-08-16  6:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Xu, stefanha, David Hildenbrand, Kevin Wolf,
	Markus Armbruster, Keith Busch, Hanna Reitz, dmitry.fomichev,
	Eric Blake, Klaus Jensen, Philippe Mathieu-Daudé, dlemoal,
	Paolo Bonzini, hare, qemu-block, Sam Li

ZNS emulation follows NVMe ZNS spec but the state of namespace
zones does not persist accross restarts of QEMU. This patch makes the
metadata of ZNS emulation persistent by using new block layer APIs and
the qcow2 img as backing file. It is the second part after the patches
- adding full zoned storage emulation to qcow2 driver.

The metadata of ZNS emulation divides into two parts, zone metadata and
zone descriptor extension data. The zone metadata is composed of zone
states, zone type, wp and zone attributes. The zone information can be
stored at an uint64_t wp to save space and easy access. The structure of
wp of each zone is as follows:
|| zone state (4)| zone type (1)| zone attr (8)| wp (51) ||

The zone descriptor extension data is relatively small comparing to the
overall size therefore we adopt the option that store zded of all zones
in an array regardless of the valid bit set.

To create a zns format qcow2 image file, use:
$ ./build/qemu-img create -f qcow2 zns.qcow2 -o size=768M
-o zone_size=64M -o zone_capacity=64M -o zone_nr_conv=0
-o max_append_sectors=512 -o max_open_zones=0 -o
max_active_zones=0 -o zoned_profile=zns

To attach this file as emulated zns drive in the command line of QEMU, use:
  -drive file=${znsimg},id=nvmezns0,format=qcow2,if=none \
  -device nvme-ns,drive=nvmezns0,bus=nvme0,nsid=1,uuid=xxx \

Sam Li (5):
  hw/nvme: use blk_get_*() to access zone info in the block layer
  qcow2: add zone device metadata with zd_extension
  hw/nvme: make the metadata of ZNS emulation persistent
  hw/nvme: refactor zone append writes using block layer APIs
  hw/nvme: make ZDED persistent

 block/block-backend.c             |   94 +++
 block/qcow2.c                     |  160 +++-
 block/qcow2.h                     |    3 +
 docs/interop/qcow2.txt            |    2 +
 hw/nvme/ctrl.c                    | 1256 ++++++++---------------------
 hw/nvme/ns.c                      |  163 +---
 hw/nvme/nvme.h                    |   95 +--
 include/block/block-common.h      |    9 +
 include/block/block_int-common.h  |    8 +
 include/sysemu/block-backend-io.h |   12 +
 include/sysemu/dma.h              |    3 +
 qapi/block-core.json              |    3 +
 softmmu/dma-helpers.c             |   17 +
 13 files changed, 686 insertions(+), 1139 deletions(-)

-- 
2.40.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-08-21 13:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-16  6:46 [RFC 0/5] Add persistence to NVMe ZNS emulation Sam Li
2023-08-16  6:46 ` [RFC 1/5] hw/nvme: use blk_get_*() to access zone info in the block layer Sam Li
2023-08-16  6:46 ` [RFC 2/5] qcow2: add zone device metadata with zd_extension Sam Li
2023-08-21 13:17   ` Markus Armbruster
2023-08-16  6:46 ` [RFC 3/5] hw/nvme: make the metadata of ZNS emulation persistent Sam Li

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).