[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
- [PATCH v7 27/48] nvme: refactor dma read/write, (continued)
- [PATCH v7 27/48] nvme: refactor dma read/write, Klaus Jensen, 2020/04/15
- [PATCH v7 23/48] nvme: memset preallocated requests structures, Klaus Jensen, 2020/04/15
- [PATCH v7 31/48] nvme: refactor request bounds checking, Klaus Jensen, 2020/04/15
- [PATCH v7 33/48] nvme: be consistent about zeros vs zeroes, Klaus Jensen, 2020/04/15
- [PATCH v7 40/48] nvme: handle dma errors, Klaus Jensen, 2020/04/15
- [PATCH v7 26/48] nvme: remove redundant has_sg member, Klaus Jensen, 2020/04/15
- [PATCH v7 30/48] nvme: verify validity of prp lists in the cmb, Klaus Jensen, 2020/04/15
- [PATCH v7 35/48] nvme: remove NvmeCmd parameter, Klaus Jensen, 2020/04/15
- [PATCH v7 36/48] nvme: allow multiple aios per command, Klaus Jensen, 2020/04/15
- [PATCH v7 37/48] nvme: add nvme_check_rw helper,
Klaus Jensen <=
- [PATCH v7 39/48] pci: pass along the return value of dma_memory_rw, Klaus Jensen, 2020/04/15
- [PATCH v7 28/48] nvme: pass request along for tracing, Klaus Jensen, 2020/04/15
- [PATCH v7 44/48] nvme: refactor identify active namespace id list, Klaus Jensen, 2020/04/15
- [PATCH v7 41/48] nvme: harden cmb access, Klaus Jensen, 2020/04/15
- [PATCH v7 43/48] nvme: add support for sgl bit bucket descriptor, Klaus Jensen, 2020/04/15
- [PATCH v7 47/48] nvme: change controller pci id, Klaus Jensen, 2020/04/15
- [PATCH v7 46/48] pci: allocate pci id for nvme, Klaus Jensen, 2020/04/15
- [PATCH v7 48/48] nvme: make lba data size configurable, Klaus Jensen, 2020/04/15