]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: use proper mask to get correct lbafu value
authorFrancis Pravin <francis.p@samsung.com>
Thu, 18 Jul 2024 10:05:44 +0000 (15:35 +0530)
committerDaniel Wagner <wagi@monom.org>
Thu, 18 Jul 2024 11:00:16 +0000 (13:00 +0200)
The NVME_NS_FLBAS_HIGHER/LOWER_MASK is used to get the format index
value from Formatted LBA Size (FLBAS) field of Identify Namespace
Data Structure. But, We are not getting the proper lbafu value while
using the same macro on user passed format index value.
So, use the proper mask to get the correct lbafu value.

Signed-off-by: Francis Pravin <francis.p@samsung.com>
Reviewed-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
nvme.c

diff --git a/nvme.c b/nvme.c
index 4b0e2313b420e9cb50bd7d2db96384dd7e37f858..eddd617ea1971f1747427ad55c967a16ade60576 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -6264,8 +6264,8 @@ static int format_cmd(int argc, char **argv, struct command *cmd, struct plugin
        struct nvme_format_nvm_args args = {
                .args_size      = sizeof(args),
                .nsid           = cfg.namespace_id,
-               .lbafu          = (cfg.lbaf & NVME_NS_FLBAS_HIGHER_MASK) >> 4,
-               .lbaf           = cfg.lbaf & NVME_NS_FLBAS_LOWER_MASK,
+               .lbafu          = (cfg.lbaf >> 4) & 0x3,
+               .lbaf           = cfg.lbaf & 0xf,
                .mset           = cfg.ms,
                .pi             = cfg.pi,
                .pil            = cfg.pil,