From 3ef73f9462a0c142dce80ce5b4ff8789b39f2f64 Mon Sep 17 00:00:00 2001 From: Klaus Jensen Date: Tue, 13 Apr 2021 21:51:30 +0200 Subject: hw/block/nvme: add metadata offset helper Add an nvme_moff() helper. Signed-off-by: Klaus Jensen Reviewed-by: Keith Busch --- hw/block/nvme.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'hw/block/nvme.h') diff --git a/hw/block/nvme.h b/hw/block/nvme.h index dc065e57b5..9349d1c33a 100644 --- a/hw/block/nvme.h +++ b/hw/block/nvme.h @@ -107,7 +107,7 @@ typedef struct NvmeNamespace { BlockConf blkconf; int32_t bootindex; int64_t size; - int64_t mdata_offset; + int64_t moff; NvmeIdNs id_ns; NvmeLBAF lbaf; size_t lbasz; @@ -158,6 +158,11 @@ static inline size_t nvme_m2b(NvmeNamespace *ns, uint64_t lba) return ns->lbaf.ms * lba; } +static inline int64_t nvme_moff(NvmeNamespace *ns, uint64_t lba) +{ + return ns->moff + nvme_m2b(ns, lba); +} + static inline bool nvme_ns_ext(NvmeNamespace *ns) { return !!NVME_ID_NS_FLBAS_EXTENDED(ns->id_ns.flbas); -- cgit v1.2.3