diff options
author | Klaus Jensen <k.jensen@samsung.com> | 2021-04-14 21:40:40 +0200 |
---|---|---|
committer | Klaus Jensen <k.jensen@samsung.com> | 2021-05-17 09:18:59 +0200 |
commit | 72ea5c2c2067086ced90c7f5e4d98c93072a0fc2 (patch) | |
tree | 83709f04d57664759c7c2ac96d029cc1b1f88686 /hw | |
parent | 3ef73f9462a0c142dce80ce5b4ff8789b39f2f64 (diff) |
hw/block/nvme: streamline namespace array indexing
Streamline namespace array indexing such that both the subsystem and
controller namespaces arrays are 1-indexed.
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/block/nvme.c | 4 | ||||
-rw-r--r-- | hw/block/nvme.h | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 1db9a603f5..baf7b67145 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -4990,7 +4990,7 @@ static uint16_t nvme_ns_attachment(NvmeCtrl *n, NvmeRequest *req) return NVME_NS_NOT_ATTACHED | NVME_DNR; } - ctrl->namespaces[nsid - 1] = NULL; + ctrl->namespaces[nsid] = NULL; ns->attached--; nvme_update_dmrsl(ctrl); @@ -6163,7 +6163,7 @@ void nvme_attach_ns(NvmeCtrl *n, NvmeNamespace *ns) uint32_t nsid = ns->params.nsid; assert(nsid && nsid <= NVME_MAX_NAMESPACES); - n->namespaces[nsid - 1] = ns; + n->namespaces[nsid] = ns; ns->attached++; n->dmrsl = MIN_NON_ZERO(n->dmrsl, diff --git a/hw/block/nvme.h b/hw/block/nvme.h index 9349d1c33a..ac3f0a8867 100644 --- a/hw/block/nvme.h +++ b/hw/block/nvme.h @@ -438,7 +438,7 @@ typedef struct NvmeCtrl { NvmeSubsystem *subsys; NvmeNamespace namespace; - NvmeNamespace *namespaces[NVME_MAX_NAMESPACES]; + NvmeNamespace *namespaces[NVME_MAX_NAMESPACES + 1]; NvmeSQueue **sq; NvmeCQueue **cq; NvmeSQueue admin_sq; @@ -460,7 +460,7 @@ static inline NvmeNamespace *nvme_ns(NvmeCtrl *n, uint32_t nsid) return NULL; } - return n->namespaces[nsid - 1]; + return n->namespaces[nsid]; } static inline NvmeCQueue *nvme_cq(NvmeRequest *req) |