diff mbox series

[for-6.0,6/7] hw/block/nvme: update dmsrl limit on namespace detachment

Message ID 20210324200907.408996-7-its@irrelevant.dk
State New
Headers show
Series hw/block/nvme: misc fixes | expand

Commit Message

Klaus Jensen March 24, 2021, 8:09 p.m. UTC
From: Klaus Jensen <k.jensen@samsung.com>

The Non-MDTS DMSRL limit must be recomputed when namespaces are
detached.

Fixes: 645ce1a70cb6 ("hw/block/nvme: support namespace attachment command")
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
 hw/block/nvme.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Gollu Appalanaidu March 30, 2021, 11:50 a.m. UTC | #1
On Wed, Mar 24, 2021 at 09:09:06PM +0100, Klaus Jensen wrote:
>From: Klaus Jensen <k.jensen@samsung.com>
>
>The Non-MDTS DMSRL limit must be recomputed when namespaces are
>detached.
>
>Fixes: 645ce1a70cb6 ("hw/block/nvme: support namespace attachment command")
>Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
>---
> hw/block/nvme.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
>diff --git a/hw/block/nvme.c b/hw/block/nvme.c
>index 403c8381a498..e84e43b2692d 100644
>--- a/hw/block/nvme.c
>+++ b/hw/block/nvme.c
>@@ -4876,6 +4876,21 @@ static uint16_t nvme_aer(NvmeCtrl *n, NvmeRequest *req)
>     return NVME_NO_COMPLETE;
> }
>
>+static void __nvme_update_dmrsl(NvmeCtrl *n)
>+{
>+    int nsid;
>+
>+    for (nsid = 1; nsid <= NVME_MAX_NAMESPACES; nsid++) {
>+        NvmeNamespace *ns = nvme_ns(n, nsid);
>+        if (!ns) {
>+            continue;
>+        }
>+
>+        n->dmrsl = MIN_NON_ZERO(n->dmrsl,
>+                                BDRV_REQUEST_MAX_BYTES / nvme_l2b(ns, 1));
>+    }
>+}
>+

Looks good to me!

> static void __nvme_select_ns_iocs(NvmeCtrl *n, NvmeNamespace *ns);
> static uint16_t nvme_ns_attachment(NvmeCtrl *n, NvmeRequest *req)
> {
>@@ -4925,6 +4940,8 @@ static uint16_t nvme_ns_attachment(NvmeCtrl *n, NvmeRequest *req)
>             }
>
>             nvme_ns_detach(ctrl, ns);
>+
>+            __nvme_update_dmrsl(ctrl);
>         }
>
>         /*
>-- 
>2.31.0
>
>

Reviwed-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
diff mbox series

Patch

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 403c8381a498..e84e43b2692d 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -4876,6 +4876,21 @@  static uint16_t nvme_aer(NvmeCtrl *n, NvmeRequest *req)
     return NVME_NO_COMPLETE;
 }
 
+static void __nvme_update_dmrsl(NvmeCtrl *n)
+{
+    int nsid;
+
+    for (nsid = 1; nsid <= NVME_MAX_NAMESPACES; nsid++) {
+        NvmeNamespace *ns = nvme_ns(n, nsid);
+        if (!ns) {
+            continue;
+        }
+
+        n->dmrsl = MIN_NON_ZERO(n->dmrsl,
+                                BDRV_REQUEST_MAX_BYTES / nvme_l2b(ns, 1));
+    }
+}
+
 static void __nvme_select_ns_iocs(NvmeCtrl *n, NvmeNamespace *ns);
 static uint16_t nvme_ns_attachment(NvmeCtrl *n, NvmeRequest *req)
 {
@@ -4925,6 +4940,8 @@  static uint16_t nvme_ns_attachment(NvmeCtrl *n, NvmeRequest *req)
             }
 
             nvme_ns_detach(ctrl, ns);
+
+            __nvme_update_dmrsl(ctrl);
         }
 
         /*