[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 09/14] hw/block/nvme: Support Zoned Namespace Command Set
From: |
Klaus Jensen |
Subject: |
Re: [PATCH v4 09/14] hw/block/nvme: Support Zoned Namespace Command Set |
Date: |
Fri, 25 Sep 2020 20:24:25 +0200 |
On Sep 24 03:20, Dmitry Fomichev wrote:
> The emulation code has been changed to advertise NVM Command Set when
> "zoned" device property is not set (default) and Zoned Namespace
> Command Set otherwise.
>
> Handlers for three new NVMe commands introduced in Zoned Namespace
> Command Set specification are added, namely for Zone Management
> Receive, Zone Management Send and Zone Append.
>
> Device initialization code has been extended to create a proper
> configuration for zoned operation using device properties.
>
> Read/Write command handler is modified to only allow writes at the
> write pointer if the namespace is zoned. For Zone Append command,
> writes implicitly happen at the write pointer and the starting write
> pointer value is returned as the result of the command. Write Zeroes
> handler is modified to add zoned checks that are identical to those
> done as a part of Write flow.
>
> The code to support for Zone Descriptor Extensions is not included in
> this commit and ZDES 0 is always reported. A later commit in this
> series will add ZDE support.
>
> This commit doesn't yet include checks for active and open zone
> limits. It is assumed that there are no limits on either active or
> open zones.
>
> Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
> Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
> Signed-off-by: Ajay Joshi <ajay.joshi@wdc.com>
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> Signed-off-by: Matias Bjorling <matias.bjorling@wdc.com>
> Signed-off-by: Aravind Ramesh <aravind.ramesh@wdc.com>
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> Signed-off-by: Adam Manzanares <adam.manzanares@wdc.com>
> Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
> ---
> block/nvme.c | 2 +-
> hw/block/nvme.c | 1057 ++++++++++++++++++++++++++++++++++++++++--
> include/block/nvme.h | 6 +-
> 3 files changed, 1026 insertions(+), 39 deletions(-)
>
> diff --git a/block/nvme.c b/block/nvme.c
> index 05485fdd11..7a513c9a17 100644
> --- a/block/nvme.c
> +++ b/block/nvme.c
> @@ -682,11 +1005,77 @@ static uint16_t nvme_rw(NvmeCtrl *n, NvmeRequest *req)
> return status;
> }
>
> + if (n->params.zoned) {
> + zone_idx = nvme_zone_idx(n, slba);
> + assert(zone_idx < n->num_zones);
> + zone = &ns->zone_array[zone_idx];
> +
> + if (is_write) {
> + status = nvme_check_zone_write(zone, slba, nlb);
> + if (status != NVME_SUCCESS) {
> + trace_pci_nvme_err_zone_write_not_ok(slba, nlb, status);
> + return status | NVME_DNR;
> + }
> +
> + assert(nvme_wp_is_valid(zone));
> + if (append) {
> + if (unlikely(slba != zone->d.zslba)) {
> + trace_pci_nvme_err_append_not_at_start(slba,
> zone->d.zslba);
> + return NVME_ZONE_INVALID_WRITE | NVME_DNR;
> + }
> + if (data_size > (n->page_size << n->zasl)) {
> + trace_pci_nvme_err_append_too_large(slba, nlb, n->zasl);
> + return NVME_INVALID_FIELD | NVME_DNR;
> + }
> + slba = zone->w_ptr;
> + } else if (unlikely(slba != zone->w_ptr)) {
> + trace_pci_nvme_err_write_not_at_wp(slba, zone->d.zslba,
> + zone->w_ptr);
> + return NVME_ZONE_INVALID_WRITE | NVME_DNR;
> + }
> + req->fill_ofs = -1LL;
> + } else {
> + status = nvme_check_zone_read(n, zone, slba, nlb,
> + n->params.cross_zone_read);
> + if (status != NVME_SUCCESS) {
> + trace_pci_nvme_err_zone_read_not_ok(slba, nlb, status);
> + return status | NVME_DNR;
> + }
> +
> + if (slba + nlb > zone->w_ptr) {
> + /*
> + * All or some data is read above the WP. Need to
> + * fill out the buffer area that has no backing data
> + * with a predefined data pattern (zeros by default)
> + */
> + if (slba >= zone->w_ptr) {
> + req->fill_ofs = 0;
> + } else {
> + req->fill_ofs = ((zone->w_ptr - slba) << data_shift);
> + }
If Read Across Zone Boundaries is enabled and the read in zone A
includes LBAs above the write pointer, but crossing into a full zone
(zone B), then you are gonna overwrite the valid data in zone B with the
fill pattern.
signature.asc
Description: PGP signature
- Re: [PATCH v4 06/14] hw/block/nvme: Add support for active/inactive namespaces, (continued)
[PATCH v4 07/14] hw/block/nvme: Make Zoned NS Command Set definitions, Dmitry Fomichev, 2020/09/23
[PATCH v4 05/14] hw/block/nvme: Add support for Namespace Types, Dmitry Fomichev, 2020/09/23
[PATCH v4 08/14] hw/block/nvme: Define Zoned NS Command Set trace events, Dmitry Fomichev, 2020/09/23
[PATCH v4 10/14] hw/block/nvme: Introduce max active and open zone limits, Dmitry Fomichev, 2020/09/23
[PATCH v4 12/14] hw/block/nvme: Add injection of Offline/Read-Only zones, Dmitry Fomichev, 2020/09/23
[PATCH v4 09/14] hw/block/nvme: Support Zoned Namespace Command Set, Dmitry Fomichev, 2020/09/23
- Re: [PATCH v4 09/14] hw/block/nvme: Support Zoned Namespace Command Set,
Klaus Jensen <=
[PATCH v4 11/14] hw/block/nvme: Support Zone Descriptor Extensions, Dmitry Fomichev, 2020/09/23
[PATCH v4 13/14] hw/block/nvme: Use zone metadata file for persistence, Dmitry Fomichev, 2020/09/23
[PATCH v4 14/14] hw/block/nvme: Document zoned parameters in usage text, Dmitry Fomichev, 2020/09/23
Re: [PATCH v4 00/14] hw/block/nvme: Support Namespace Types and Zoned Namespace Command Set, Klaus Jensen, 2020/09/24
- RE: [PATCH v4 00/14] hw/block/nvme: Support Namespace Types and Zoned Namespace Command Set, Dmitry Fomichev, 2020/09/27
- Re: [PATCH v4 00/14] hw/block/nvme: Support Namespace Types and Zoned Namespace Command Set, Klaus Jensen, 2020/09/28
- Re: [PATCH v4 00/14] hw/block/nvme: Support Namespace Types and Zoned Namespace Command Set, Keith Busch, 2020/09/28
- Re: [PATCH v4 00/14] hw/block/nvme: Support Namespace Types and Zoned Namespace Command Set, Damien Le Moal, 2020/09/28
- Re: [PATCH v4 00/14] hw/block/nvme: Support Namespace Types and Zoned Namespace Command Set, Klaus Jensen, 2020/09/29
- Re: [PATCH v4 00/14] hw/block/nvme: Support Namespace Types and Zoned Namespace Command Set, Damien Le Moal, 2020/09/29