qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v7 37/48] nvme: add nvme_check_rw helper


From: Klaus Jensen
Subject: [PATCH v7 37/48] nvme: add nvme_check_rw helper
Date: Wed, 15 Apr 2020 07:51:29 +0200

From: Klaus Jensen <address@hidden>

Signed-off-by: Klaus Jensen <address@hidden>
---
 hw/block/nvme.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index c123be10fd0d..ffc49985321b 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -651,6 +651,25 @@ static inline uint16_t nvme_check_bounds(NvmeCtrl *n, 
uint64_t slba,
     return NVME_SUCCESS;
 }
 
+static uint16_t nvme_check_rw(NvmeCtrl *n, NvmeRequest *req)
+{
+    NvmeNamespace *ns = req->ns;
+    size_t len = req->nlb << nvme_ns_lbads(ns);
+    uint16_t status;
+
+    status = nvme_check_mdts(n, len, req);
+    if (status) {
+        return status;
+    }
+
+    status = nvme_check_bounds(n, req->slba, req->nlb, req);
+    if (status) {
+        return status;
+    }
+
+    return NVME_SUCCESS;
+}
+
 static void nvme_rw_cb(NvmeRequest *req, void *opaque)
 {
     NvmeSQueue *sq = req->sq;
@@ -810,12 +829,7 @@ static uint16_t nvme_rw(NvmeCtrl *n, NvmeRequest *req)
     trace_nvme_dev_rw(nvme_req_is_write(req) ? "write" : "read", req->nlb,
                       req->nlb << nvme_ns_lbads(req->ns), req->slba);
 
-    status = nvme_check_mdts(n, len, req);
-    if (status) {
-        goto invalid;
-    }
-
-    status = nvme_check_bounds(n, req->slba, req->nlb, req);
+    status = nvme_check_rw(n, req);
     if (status) {
         goto invalid;
     }
-- 
2.26.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]