Skip to contentSkip to conversation

hw/block/nvme: add missing mor/mar constraint checks

PATCH In review Klaus Jensen 2 participants 3 messages Jan 26, 2021 – Feb 8, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 hw/block/nvme: add missing mor/mar constraint checks

From: Klaus Jensen <[email protected]>

Firstly, if zoned.max_active is non-zero, zoned.max_open must be less than or equal to zoned.max_active.

Secondly, if only zones.max_active is set, we have to explicitly set zones.max_open or we end up with an invalid MAR/MOR configuration. This is an artifact of the parameters not being zeroes-based like in the spec.

---

v2:

* Jumped the gun on removing the check on zoned.max_open. It should still be done since the device might only have a constraint on open zones, not active.
* Instead, added an explicit set of zoned.max_open if only zoned.max_active is specifed.

 hw/block/nvme-ns.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
hw/block/nvme-ns.c +12 -0
index 62b25cf69bfa..df514287b58f 100644
@@ -153,6 +153,18 @@ static int nvme_ns_zoned_check_calc_geometry(NvmeNamespace *ns, Error **errp)
         return -1;
     }
 
+    if (ns->params.max_active_zones) {
+        if (ns->params.max_open_zones > ns->params.max_active_zones) {
+            error_setg(errp, "max_open_zones (%u) exceeds max_active_zones (%u)",
+                       ns->params.max_open_zones, ns->params.max_active_zones);
+            return -1;
+        }
+
+        if (!ns->params.max_open_zones) {
+            ns->params.max_open_zones = ns->params.max_active_zones;
+        }
+    }
+
     if (ns->params.zd_extension_size) {
         if (ns->params.zd_extension_size & 0x3f) {
             error_setg(errp,
Signature · 1 line
2.30.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 5 lines · Klaus Jensen

From: Klaus Jensen <[email protected]>

Firstly, if zoned.max_active is non-zero, zoned.max_open must be less than or equal to zoned.max_active.

Quoted 8 lines

Secondly, if only zones.max_active is set, we have to explicitly set zones.max_open or we end up with an invalid MAR/MOR configuration. This is an artifact of the parameters not being zeroes-based like in the spec.

Quoted 39 lines

---

v2:

  * Jumped the gun on removing the check on zoned.max_open. It should still be done since the device might only have a constraint on open zones, not active.
  * Instead, added an explicit set of zoned.max_open if only zoned.max_active is specifed.

 hw/block/nvme-ns.c | 12 ++++++++++++

 1 file changed, 12 insertions(+)
hw/block/nvme-ns.c +0 -0
index 62b25cf69bfa..df514287b58f 100644
@@ -153,6 +153,18 @@ static int nvme_ns_zoned_check_calc_geometry(NvmeNamespace *ns, Error **errp)
          return -1;
      }

hw/block/nvme-ns.c +12 -0
+    if (ns->params.max_active_zones) {
+        if (ns->params.max_open_zones > ns->params.max_active_zones) {
+            error_setg(errp, "max_open_zones (%u) exceeds max_active_zones (%u)",
+                       ns->params.max_open_zones, ns->params.max_active_zones);
+            return -1;
+        }
+
+        if (!ns->params.max_open_zones) {
+            ns->params.max_open_zones = ns->params.max_active_zones;
+        }
+    }
+

     if (ns->params.zd_extension_size) {
         if (ns->params.zd_extension_size & 0x3f) { error_setg(errp,

author Applied
#2 lore raw
Quoted 11 lines · Dmitry Fomichev
Quoted 10 lines · Klaus Jensen

From: Klaus Jensen <[email protected]>

Firstly, if zoned.max_active is non-zero, zoned.max_open must be less than or equal to zoned.max_active.

Secondly, if only zones.max_active is set, we have to explicitly set zones.max_open or we end up with an invalid MAR/MOR configuration. This is an artifact of the parameters not being zeroes-based like in the spec.

Quoted 6 lines
Quoted 3 lines

Thanks, applied!