[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 21/56] hw/block/nvme: conditionally enable DULBE for zoned namespa
From: |
Klaus Jensen |
Subject: |
[PULL 21/56] hw/block/nvme: conditionally enable DULBE for zoned namespaces |
Date: |
Tue, 9 Feb 2021 08:30:26 +0100 |
From: Klaus Jensen <k.jensen@samsung.com>
The device uses the BDRV_BLOCK_ZERO flag to determine the "deallocated"
status of logical blocks. Since the zoned namespaces command set
specification defines that logical blocks SHALL be marked as deallocated
when the zone is in the Empty or Offline states, DULBE can only be
supported if the zone size is a multiple of the calculated deallocation
granularity (reported in NPDG) which depends on the underlying block
device cluster size (if applicable) or the configured
discard_granularity.
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
hw/block/nvme-ns.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/hw/block/nvme-ns.c b/hw/block/nvme-ns.c
index 838b15c064f5..9be170abb78d 100644
--- a/hw/block/nvme-ns.c
+++ b/hw/block/nvme-ns.c
@@ -16,6 +16,7 @@
#include "qemu/units.h"
#include "qemu/cutils.h"
#include "qemu/log.h"
+#include "qemu/error-report.h"
#include "hw/block/block.h"
#include "hw/pci/pci.h"
#include "sysemu/sysemu.h"
@@ -227,6 +228,22 @@ static void nvme_ns_init_zoned(NvmeCtrl *n, NvmeNamespace
*ns, int lba_index)
ns->id_ns.ncap = ns->id_ns.nsze;
ns->id_ns.nuse = ns->id_ns.ncap;
+ /*
+ * The device uses the BDRV_BLOCK_ZERO flag to determine the "deallocated"
+ * status of logical blocks. Since the spec defines that logical blocks
+ * SHALL be deallocated when then zone is in the Empty or Offline states,
+ * we can only support DULBE if the zone size is a multiple of the
+ * calculated NPDG.
+ */
+ if (ns->zone_size % (ns->id_ns.npdg + 1)) {
+ warn_report("the zone size (%"PRIu64" blocks) is not a multiple of "
+ "the calculated deallocation granularity (%d blocks); "
+ "DULBE support disabled",
+ ns->zone_size, ns->id_ns.npdg + 1);
+
+ ns->id_ns.nsfeat &= ~0x4;
+ }
+
ns->id_ns_zoned = id_ns_z;
}
--
2.30.0
- [PULL 06/56] hw/block/nvme: add compare command, (continued)
- [PULL 06/56] hw/block/nvme: add compare command, Klaus Jensen, 2021/02/09
- [PULL 08/56] hw/block/nvme: Process controller reset and shutdown differently, Klaus Jensen, 2021/02/09
- [PULL 09/56] hw/block/nvme: Generate namespace UUIDs, Klaus Jensen, 2021/02/09
- [PULL 10/56] hw/block/nvme: Separate read and write handlers, Klaus Jensen, 2021/02/09
- [PULL 11/56] hw/block/nvme: Combine nvme_write_zeroes() and nvme_write(), Klaus Jensen, 2021/02/09
- [PULL 12/56] hw/block/nvme: Add Commands Supported and Effects log, Klaus Jensen, 2021/02/09
- [PULL 07/56] hw/block/nvme: fix bad clearing of CAP, Klaus Jensen, 2021/02/09
- [PULL 14/56] hw/block/nvme: Support allocated CNS command variants, Klaus Jensen, 2021/02/09
- [PULL 13/56] hw/block/nvme: Add support for Namespace Types, Klaus Jensen, 2021/02/09
- [PULL 15/56] nvme: Make ZNS-related definitions, Klaus Jensen, 2021/02/09
- [PULL 21/56] hw/block/nvme: conditionally enable DULBE for zoned namespaces,
Klaus Jensen <=
- [PULL 18/56] hw/block/nvme: Support Zone Descriptor Extensions, Klaus Jensen, 2021/02/09
- [PULL 19/56] hw/block/nvme: Document zoned parameters in usage text, Klaus Jensen, 2021/02/09
- [PULL 16/56] hw/block/nvme: Support Zoned Namespace Command Set, Klaus Jensen, 2021/02/09
- [PULL 24/56] hw/block/nvme: enum style fix, Klaus Jensen, 2021/02/09
- [PULL 39/56] hw/block/nvme: fix 64 bit register hi/lo split writes, Klaus Jensen, 2021/02/09
- [PULL 22/56] hw/block/nvme: fix shutdown/reset logic, Klaus Jensen, 2021/02/09
- [PULL 17/56] hw/block/nvme: Introduce max active and open zone limits, Klaus Jensen, 2021/02/09
- [PULL 20/56] hw/block/nvme: fix for non-msix machines, Klaus Jensen, 2021/02/09
- [PULL 23/56] hw/block/nvme: merge implicitly/explicitly opened processing masks, Klaus Jensen, 2021/02/09
- [PULL 28/56] hw/block/nvme: Correct error status for unaligned ZA, Klaus Jensen, 2021/02/09