engines/nvme: support for 64 LBA formats
authorAnkit Kumar <ankit.kumar@samsung.com>
Mon, 15 May 2023 11:03:39 +0000 (16:33 +0530)
committerVincent Fu <vincent.fu@samsung.com>
Mon, 15 May 2023 12:41:30 +0000 (08:41 -0400)
The NVM command set specification 1.0c supports 64 LBA formats.
The 0-based nlbaf field specifies the number of LBA formats.
The flbas field is used to calculate the current LBA format, in which
bit 0-3 indicates lsb and bit 5-6 indicates msb of the format index.

Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
engines/nvme.c
engines/nvme.h

index fd2161f363bf5ddcda6fe45501bfcc8e79898a7d..96a5f0648f927803708575e3b255927c9c8a62bf 100644 (file)
@@ -99,6 +99,7 @@ int fio_nvme_get_info(struct fio_file *f, __u32 *nsid, __u32 *lba_sz,
        struct nvme_id_ns ns;
        int namespace_id;
        int fd, err;
+       __u32 format_idx;
 
        if (f->filetype != FIO_TYPE_CHAR) {
                log_err("ioengine io_uring_cmd only works with nvme ns "
@@ -131,7 +132,18 @@ int fio_nvme_get_info(struct fio_file *f, __u32 *nsid, __u32 *lba_sz,
        }
 
        *nsid = namespace_id;
-       *lba_sz = 1 << ns.lbaf[(ns.flbas & 0x0f)].ds;
+
+       /*
+        * 16 or 64 as maximum number of supported LBA formats.
+        * From flbas bit 0-3 indicates lsb and bit 5-6 indicates msb
+        * of the format index used to format the namespace.
+        */
+       if (ns.nlbaf < 16)
+               format_idx = ns.flbas & 0xf;
+       else
+               format_idx = (ns.flbas & 0xf) + (((ns.flbas >> 5) & 0x3) << 4);
+
+       *lba_sz = 1 << ns.lbaf[format_idx].ds;
        *nlba = ns.nsze;
 
        close(fd);
index 408594d5509326b606c981cebbeea3e055eaeaf0..9d6288c86c65bee2af78676cae10ecd70b1447c6 100644 (file)
@@ -134,8 +134,7 @@ struct nvme_id_ns {
        __le16                  endgid;
        __u8                    nguid[16];
        __u8                    eui64[8];
-       struct nvme_lbaf        lbaf[16];
-       __u8                    rsvd192[192];
+       struct nvme_lbaf        lbaf[64];
        __u8                    vs[3712];
 };