]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: Add zns specfic field for create ns
authorSteven Seungcheol Lee <sc108.lee@samsung.com>
Wed, 5 Apr 2023 04:10:42 +0000 (13:10 +0900)
committerDaniel Wagner <wagi@monom.org>
Thu, 13 Apr 2023 11:14:22 +0000 (13:14 +0200)
nvme_ns_mgmt_host_sw_specified_zns from TP4115 ZNS Namespace Management Enhancements 2022.03.15 Ratified

Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
Documentation/nvme-create-ns.txt
completions/bash-nvme-completion.sh
nvme.c

index e13aabdf57f317cdcc904a8d8d1c5d4ad8d557ed..5d1355d252a077ce9b6db5be0cda12413768be4e 100644 (file)
@@ -22,6 +22,10 @@ SYNOPSIS
                        [--timeout=<timeout> | -t <timeout>]
                        [--nsze-si=<nsze-si> | -S <nsze-si>]
                        [--ncap-si=<ncap-si> | -C <ncap-si>]
+                       [--azr | -z]
+                       [--rar=<rar> | -r <rar>]
+                       [--ror=<ror> | -o <ror>]
+                       [--rnumzrwa=<rnumzrwa> | -u <rnumzrwa>]
                        [--phndls=<placement-handle-list,> | -p <placement-handle-list,>]
 
 DESCRIPTION
@@ -98,6 +102,28 @@ OPTIONS
        The value SI suffixed is divided by the namespace LBA size to set as NCAP.
        If the value not suffixed it is set as same with the ncap option.
 
+-z::
+--azr::
+       Allocate ZRWA Resources.
+       If set to 1, then the namespace is to be created with the number of ZRWA
+       resource specified in the RNUMZRWA field of this data structure. If cleared
+       to 0, then no ZRWA resources are allocated to the namespace to be created.
+
+-r <rar>::
+--rar=<rar>::
+       Requested Active Resources. This field specifies the number of active
+       resources to be allocated to the created namespace.
+
+-o <ror>::
+--ror=<ror>::
+       Requested Open Resources. This field specifies the number of open resources
+       to be allocated to the created namespace.
+
+-u <rnumzrwa>::
+--rnumzrwa=<rnumzrwa>::
+       Requested Number of ZRWA Resources. This field specifies the number of ZRWA
+       resources to be allocated to the created namespace.
+
 -p <placement-handle-list,>::
 --phndls=<placement-handle-list,>::
        The comma separated list of Reclaim Unit Handle Identifier to be associated
index e7440185e858fca4f3f2262ad5ef39fbb96c7f38..f39ec6b2038c68fbc31f204767c18648363bbdca 100644 (file)
@@ -94,7 +94,8 @@ nvme_list_opts () {
                opts+=" --nsze= -s --ncap= -c --flbas= -f \
                        --dps= -d --nmic= -m --anagrp-id= -a --nvmset-id= -i \
                        --block-size= -b --timeout= -t --csi= -y --lbstm= -l \
-                       --nphndls= -n --nsze-si= -S --ncap-si= -C --phndls= -p"
+                       --nphndls= -n --nsze-si= -S --ncap-si= -C --azr -z --rar= -r \
+                       --ror= -o --rnumzrwa= -u --phndls= -p"
                        ;;
                "delete-ns")
                opts+=" -namespace-id= -n --timeout= -t"
diff --git a/nvme.c b/nvme.c
index 10f7d1890b31ac9b189d55dcf41bb0083bf45248..928cfce9098a2c439eb3606459834d5b4598a7db 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -2998,6 +2998,14 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin *
                "value not entered";
        const char *nsze_si = "size of ns (NSZE) in standard SI units";
        const char *ncap_si = "capacity of ns (NCAP) in standard SI units";
+       const char *azr = "Allocate ZRWA Resources (AZR) for "\
+               "Zoned Namespace Command Set";
+       const char *rar = "Requested Active Resources (RAR) for "\
+               "Zoned Namespace Command Set";
+       const char *ror = "Requested Open Resources (ROR) for "\
+               "Zoned Namespace Command Set";
+       const char *rnumzrwa = "Requested Number of ZRWA Resources (RNUMZRWA) for "\
+               "Zoned Namespace Command Set";
        const char *phndls = "Comma separated list of Placement Handle "\
                "Associated RUH";
 
@@ -3023,6 +3031,10 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin *
                __u16   nphndls;
                char    *nsze_si;
                char    *ncap_si;
+               bool    azr;
+               __u32   rar;
+               __u32   ror;
+               __u32   rnumzrwa;
                char    *phndls;
        };
 
@@ -3041,6 +3053,10 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin *
                .nphndls        = 0,
                .nsze_si        = NULL,
                .ncap_si        = NULL,
+               .azr            = false,
+               .rar            = 0,
+               .ror            = 0,
+               .rnumzrwa       = 0,
                .phndls         = "",
        };
 
@@ -3059,6 +3075,10 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin *
                OPT_SHRT("nphndls",          'n', &cfg.nphndls,  nphndls),
                OPT_STR("nsze-si",       'S', &cfg.nsze_si,  nsze_si),
                OPT_STR("ncap-si",       'C', &cfg.ncap_si,  ncap_si),
+               OPT_FLAG("azr",          'z', &cfg.azr,      azr),
+               OPT_UINT("rar",          'r', &cfg.rar,      rar),
+               OPT_UINT("ror",          'o', &cfg.ror,      ror),
+               OPT_UINT("rnumzrwa",     'u', &cfg.rnumzrwa, rnumzrwa),
                OPT_LIST("phndls",           'p', &cfg.phndls,   phndls),
                OPT_END()
        };
@@ -3119,6 +3139,13 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin *
        if (err)
                goto close_dev;
 
+       if (cfg.csi != NVME_CSI_ZNS &&
+               (cfg.azr || cfg.rar || cfg.ror|| cfg.rnumzrwa)) {
+               fprintf(stderr, "Invaild ZNS argument is given (CSI:%#x)\n", cfg.csi);
+               err = -EINVAL;
+               goto close_dev;
+       }
+
        struct nvme_ns_mgmt_host_sw_specified data = {
                .nsze = cpu_to_le64(cfg.nsze),
                .ncap = cpu_to_le64(cfg.ncap),
@@ -3128,6 +3155,10 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin *
                .anagrpid = cpu_to_le32(cfg.anagrpid),
                .nvmsetid = cpu_to_le16(cfg.nvmsetid),
                .lbstm = cpu_to_le64(cfg.lbstm),
+               .zns.znsco = cfg.azr,
+               .zns.rar = cpu_to_le32(cfg.rar),
+               .zns.ror = cpu_to_le32(cfg.ror),
+               .zns.rnumzrwa = cpu_to_le32(cfg.rnumzrwa),
                .nphndls = cpu_to_le16(cfg.nphndls),
        };