aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Jensen <k.jensen@samsung.com>2021-03-08 09:09:35 +0100
committerKlaus Jensen <k.jensen@samsung.com>2021-03-18 12:34:52 +0100
commit397fbb5b32558dd2b5cd35cb4d25126879384079 (patch)
treebf053e66b006947aafb38b7fb8d80a00aa489b24
parent6a674bc295527c9acb1404b85be8d225b5bbac9d (diff)
hw/block/nvme: prefer runtime helpers instead of device parameters
In preparation for Format NVM support, use runtime helpers instead of the constant device parameters when getting lba size information etc. Signed-off-by: Klaus Jensen <k.jensen@samsung.com> Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com>
-rw-r--r--hw/block/nvme-ns.c6
-rw-r--r--hw/block/nvme-ns.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/hw/block/nvme-ns.c b/hw/block/nvme-ns.c
index 00e8f6af21..7e3cba55e4 100644
--- a/hw/block/nvme-ns.c
+++ b/hw/block/nvme-ns.c
@@ -110,11 +110,11 @@ lbaf_found:
/* support DULBE and I/O optimization fields */
id_ns->nsfeat |= (0x4 | 0x10);
- npdg = ns->blkconf.discard_granularity / ns->blkconf.logical_block_size;
+ npdg = ns->blkconf.discard_granularity / nvme_lsize(ns);
if (bdrv_get_info(blk_bs(ns->blkconf.blk), &bdi) >= 0 &&
bdi.cluster_size > ns->blkconf.discard_granularity) {
- npdg = bdi.cluster_size / ns->blkconf.logical_block_size;
+ npdg = bdi.cluster_size / nvme_lsize(ns);
}
id_ns->npda = id_ns->npdg = npdg - 1;
@@ -161,7 +161,7 @@ static int nvme_ns_init_blk(NvmeNamespace *ns, Error **errp)
static int nvme_ns_zoned_check_calc_geometry(NvmeNamespace *ns, Error **errp)
{
uint64_t zone_size, zone_cap;
- uint32_t lbasz = ns->blkconf.logical_block_size;
+ uint32_t lbasz = nvme_lsize(ns);
/* Make sure that the values of ZNS properties are sane */
if (ns->params.zone_size_bs) {
diff --git a/hw/block/nvme-ns.h b/hw/block/nvme-ns.h
index e2f53d9996..07e1688080 100644
--- a/hw/block/nvme-ns.h
+++ b/hw/block/nvme-ns.h
@@ -138,7 +138,7 @@ static inline bool nvme_ns_ext(NvmeNamespace *ns)
/* calculate the number of LBAs that the namespace can accomodate */
static inline uint64_t nvme_ns_nlbas(NvmeNamespace *ns)
{
- if (ns->params.ms) {
+ if (nvme_msize(ns)) {
return ns->size / (nvme_lsize(ns) + nvme_msize(ns));
}
return ns->size >> nvme_ns_lbads(ns);