aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Fomichev <dmitry.fomichev@wdc.com>2020-09-28 11:35:15 +0900
committerKlaus Jensen <k.jensen@samsung.com>2020-10-27 11:29:25 +0100
commitb865cabf735be793789ad2c7eac97f47a1325966 (patch)
tree84ac848c732d0a339cb3f46a86b82443f32dfff8
parentdcd1496132704ca16fc857a40370a6b9209341ae (diff)
downloadqemu-b865cabf735be793789ad2c7eac97f47a1325966.zip
qemu-b865cabf735be793789ad2c7eac97f47a1325966.tar.gz
qemu-b865cabf735be793789ad2c7eac97f47a1325966.tar.bz2
hw/block/nvme: report actual LBA data shift in LBAF
Calculate the data shift value to report based on the set value of logical_block_size device property. In the process, use a local variable to calculate the LBA format index instead of the hardcoded value 0. This makes the code more readable and it will make it easier to add support for multiple LBA formats in the future. Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com> Signed-off-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
-rw-r--r--hw/block/nvme-ns.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/block/nvme-ns.c b/hw/block/nvme-ns.c
index 2ba0263..31c80cd 100644
--- a/hw/block/nvme-ns.c
+++ b/hw/block/nvme-ns.c
@@ -31,12 +31,13 @@
static void nvme_ns_init(NvmeNamespace *ns)
{
NvmeIdNs *id_ns = &ns->id_ns;
+ int lba_index = NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas);
if (blk_get_flags(ns->blkconf.blk) & BDRV_O_UNMAP) {
ns->id_ns.dlfeat = 0x9;
}
- id_ns->lbaf[0].ds = BDRV_SECTOR_BITS;
+ id_ns->lbaf[lba_index].ds = 31 - clz32(ns->blkconf.logical_block_size);
id_ns->nsze = cpu_to_le64(nvme_ns_nlbas(ns));