]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Add lbstm option to create-ns
authorBrandon Paupore <brandon.paupore@wdc.com>
Tue, 22 Mar 2022 14:14:46 +0000 (09:14 -0500)
committerDaniel Wagner <dwagner@suse.de>
Fri, 25 Mar 2022 14:43:24 +0000 (15:43 +0100)
Signed-off-by: Brandon Paupore <brandon.paupore@wdc.com>
Documentation/nvme-create-ns.1
Documentation/nvme-create-ns.html
Documentation/nvme-create-ns.txt
nvme.c

index 802d02087ee233ad9ed9d0eff7035cb9f784966f..c972eb74b50d9646a5f1fefeb19d9dcdded87fd3 100644 (file)
@@ -40,6 +40,7 @@ nvme-create-ns \- Send NVMe Namespace management command to create namespace, re
                         [\-\-anagrp\-id=<anagrpid> | \-a <anagrpid>]
                         [\-\-nvmset\-id=<nvmsetid> | \-i <nvmsetid>]
                         [\-\-csi=<command_set_identifier> | \-y <command_set_identifier>]
+                        [\-\-lbstm=<lbstm> | \-l <lbstm>]
                         [\-\-block\-size=<block\-size> | \-b <block\-size>]
                         [\-\-timeout=<timeout> | \-t <timeout>]
 DESCRIPTION
@@ -96,6 +97,11 @@ This field specifies the identifier of the NVM Set\&.
 This field specifies the identifier of command set\&. if not issued, NVM Command Set will be selected\&.
 .RE
 .PP
+\-l <lbstm>, \-\-lbstm=<lbstm>
+.RS 4
+Logical Block Storage Tag Mask for end-to-end protection\&.
+.RE
+.PP
 \-b, \-\-block\-size
 .RS 4
 Target block size the new namespace should be formatted as\&. Potential FLBAS values will be values will be scanned and the lowest numbered will be selected for the create\-ns operation\&. Conflicts with \-\-flbas argument\&.
index 976b0bc340cf6b6e8ec7b727efea6c55d03a7c48..ef1dbfb8969834a5d02f6b91ef36c312d54e3661 100644 (file)
@@ -757,6 +757,7 @@ nvme-create-ns(1) Manual Page
                         [--anagrp-id=&lt;anagrpid&gt; | -a &lt;anagrpid&gt;]\r
                         [--nvmset-id=&lt;nvmsetid&gt; | -i &lt;nvmsetid&gt;]\r
                         [--csi=&lt;command_set_identifier&gt; | -y &lt;command_set_identifier&gt;]\r
+                        [--lbstm=&lt;lbstm&gt; | -l &lt;lbstm&gt;]\r
                         [--block-size=&lt;block-size&gt; | -b &lt;block-size&gt;]\r
                         [--timeout=&lt;timeout&gt; | -t &lt;timeout&gt;]\r
 DESCRIPTION</pre>\r
@@ -866,6 +867,17 @@ OPTIONS</code></pre>
 </p>\r
 </dd>\r
 <dt class="hdlist1">\r
+-l &lt;lbstm&gt;\r
+</dt>\r
+<dt class="hdlist1">\r
+--lbstm=&lt;lbstm&gt;\r
+</dt>\r
+<dd>\r
+<p>\r
+        Logical Block Storage Tag Mask for end-to-end protection.\r
+</p>\r
+</dd>\r
+<dt class="hdlist1">\r
 -b\r
 </dt>\r
 <dt class="hdlist1">\r
index 09c0c7898d47e1d3a5784905991fd6529f53c0a4..7fd64f4ec9184ed58612b421cf1d6eb29663568f 100644 (file)
@@ -16,6 +16,7 @@ SYNOPSIS
                        [--anagrp-id=<anagrpid> | -a <anagrpid>]
                        [--nvmset-id=<nvmsetid> | -i <nvmsetid>]
                        [--csi=<command_set_identifier> | -y <command_set_identifier>]
+                       [--lbstm=<lbstm> | -l <lbstm>]
                        [--block-size=<block-size> | -b <block-size>]
                        [--timeout=<timeout> | -t <timeout>]
 DESCRIPTION
@@ -64,6 +65,10 @@ OPTIONS
        This field specifies the identifier of command set.
        if not issued, NVM Command Set will be selected.
 
+-l <lbstm>::
+--lbstm=<lbstm>::
+       Logical Block Storage Tag Mask for end-to-end protection.
+
 -b::
 --block-size::
        Target block size the new namespace should be formatted as. Potential FLBAS
diff --git a/nvme.c b/nvme.c
index 7615fb2ff42fc15d24f85bcc40e4a511427fb485..bb5177282c636d681f5711c53d429358acc3f24a 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -2304,6 +2304,7 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin *
        const char *anagrpid = "ANA Group Identifier (ANAGRPID)";
        const char *nvmsetid = "NVM Set Identifier (NVMSETID)";
        const char *csi = "command set identifier (CSI)";
+       const char *lbstm = "logical block storage tag mask (LBSTM)";
        const char *timeout = "timeout value, in milliseconds";
        const char *bs = "target block size, specify only if \'FLBAS\' "\
                "value not entered";
@@ -2323,6 +2324,7 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin *
                __u64   bs;
                __u32   timeout;
                __u8    csi;
+               __u64   lbstm;
        };
 
        struct config cfg = {
@@ -2336,6 +2338,7 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin *
                .bs             = 0x00,
                .timeout        = 120000,
                .csi            = 0,
+               .lbstm          = 0,
        };
 
        OPT_ARGS(opts) = {
@@ -2349,6 +2352,7 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin *
                OPT_SUFFIX("block-size", 'b', &cfg.bs,       bs),
                OPT_UINT("timeout",      't', &cfg.timeout,  timeout),
                OPT_BYTE("csi",          'y', &cfg.csi,      csi),
+               OPT_SUFFIX("lbstm",      'l', &cfg.lbstm,    lbstm),
                OPT_END()
        };
 
@@ -2400,9 +2404,18 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin *
                goto close_fd;
        }
 
-       nvme_init_id_ns(&ns, cfg.nsze, cfg.ncap, cfg.flbas, cfg.dps, cfg.nmic,
-                        cfg.anagrpid, cfg.nvmsetid);
-       err = nvme_ns_mgmt_create(fd, &ns, &nsid, cfg.timeout, cfg.csi);
+       struct nvme_id_ns ns2 = {
+               .nsze = cpu_to_le64(cfg.nsze),
+               .ncap = cpu_to_le64(cfg.ncap),
+               .flbas = cfg.flbas,
+               .dps = cfg.dps,
+               .nmic = cfg.nmic,
+               .anagrpid = cpu_to_le32(cfg.anagrpid),
+               .nvmsetid = cpu_to_le16(cfg.nvmsetid),
+               .lbstm = cpu_to_le64(cfg.lbstm),
+       };
+
+       err = nvme_ns_mgmt_create(fd, &ns2, &nsid, cfg.timeout, cfg.csi);
        if (!err)
                printf("%s: Success, created nsid:%d\n", cmd->name, nsid);
        else if (err > 0)