]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: Add dtype, dspec on write-zeroes, write-uncor
authorSteven Seungcheol Lee <sc108.lee@samsung.com>
Thu, 9 Feb 2023 04:18:46 +0000 (13:18 +0900)
committerDaniel Wagner <wagi@monom.org>
Thu, 13 Apr 2023 11:14:22 +0000 (13:14 +0200)
Based on TP4146 Flexible Data Placement 2022.11.30 Ratified

Reported-by: Youngjin Jung <yj4369.jung@samsung.com>
Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
Documentation/nvme-create-ns.txt
Documentation/nvme-write-uncor.txt
Documentation/nvme-write-zeroes.txt
completions/bash-nvme-completion.sh
nvme.c

index dfa56565850e9e0a06e610fb9862285403bce3a8..5035b1327b914af20c5220d056f4a777423236bd 100644 (file)
@@ -101,4 +101,4 @@ EXAMPLES
 
 NVME
 ----
-Part of the nvme-user suite
+Part of the nvme-user suite
\ No newline at end of file
index 38af31364c6c34ab7c2692b9c1212f779a2cb1dd..19415c227ebcd480d9f8632bbc5f0519873d9cb2 100644 (file)
@@ -11,7 +11,8 @@ SYNOPSIS
 'nvme-write-uncor' <device> [--start-block=<slba> | -s <slba>]
                        [--block-count=<nlb> | -c <nlb>]
                        [--namespace-id=<nsid> | -n <nsid>]
-                       [--force]
+                       [--dir-type=<dtype> | -T <dtype>]
+                       [--dir-spec=<dspec> | -S <dspec>]
 
 DESCRIPTION
 -----------
@@ -32,9 +33,13 @@ OPTIONS
 -n <nsid>::
        Namespace ID use in the command.
 
---force::
-    Ignore namespace is currently busy and performed the operation
-    even though.
+-T <dtype>::
+--dir-type=<dtype>::
+       Directive type
+
+-S <dspec>::
+--dir-spec=<dspec>::
+       Directive specific
 
 EXAMPLES
 --------
index cfcac36fe8c15c343472a6043ba30e95ae1d4ceb..7e936e5174613c207798ccd01f3f080cc04e8e26 100644 (file)
@@ -20,7 +20,8 @@ SYNOPSIS
                        [--namespace-id=<nsid> | -n <nsid>]
                        [--storage-tag<storage-tag> | -S <storage-tag>]
                        [--storage-tag-check<storage-tag-check> | -C <storage-tag-check>]
-                       [--force]
+                       [--dir-type=<dtype> | -T <dtype>]
+                       [--dir-spec=<dspec> | -D <dspec>]
 
 DESCRIPTION
 -----------
@@ -89,9 +90,13 @@ metadata is passes.
        This bit specifies the Storage Tag field shall be checked as part of end-to-end
        data protection processing.
 
---force::
-    Ignore namespace is currently busy and performed the operation
-    even though.
+-T <dtype>::
+--dir-type=<dtype>::
+       Directive type
+
+-D <dspec>::
+--dir-spec=<dspec>::
+       Directive specific
 
 EXAMPLES
 --------
index fae3ab40a8087d2a565885a546e02ce6be5bf3ac..2fc73e50ad91e002e8ebc539f8a6739e48c80a52 100644 (file)
@@ -318,11 +318,12 @@ nvme_list_opts () {
                        --block-count= -c --deac -d --limited-retry -l \
                        --force-unit-access -f --prinfo= -p --ref-tag= -r \
                        --app-tag-mask= -m --app-tag= -a \
-                       --storage-tag= -S --storage-tag-check -C"
+                       --storage-tag= -S --storage-tag-check -C \
+                       --dir-type= -T --dir-spec= -S"
                        ;;
                "write-uncor")
                opts+=" --namespace-id= -n --start-block= -s \
-                       --block-count= -c"
+                       --block-count= -c --dir-type= -T --dir-spec= -S"
                        ;;
                "verify")
                opts+=" --namespace-id= -n --start-block= -s \
diff --git a/nvme.c b/nvme.c
index 75c586997ba6737d0cc46a85aad9550e1b1a3d5d..ca1f0abacbf85e26cc0479170ae27b1a9f61b62f 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -6321,18 +6321,24 @@ static int write_uncor(int argc, char **argv, struct command *cmd, struct plugin
                __u32   namespace_id;
                __u64   start_block;
                __u16   block_count;
+               __u8    dtype;
+               __u16   dspec;
        };
 
        struct config cfg = {
                .namespace_id   = 0,
                .start_block    = 0,
                .block_count    = 0,
+               .dtype                  = 0,
+               .dspec                  = 0,
        };
 
        OPT_ARGS(opts) = {
                OPT_UINT("namespace-id",  'n', &cfg.namespace_id, namespace_desired),
                OPT_SUFFIX("start-block", 's', &cfg.start_block,  start_block),
                OPT_SHRT("block-count",   'c', &cfg.block_count,  block_count),
+               OPT_BYTE("dir-type",      'T', &cfg.dtype,        dtype),
+               OPT_SHRT("dir-spec",      'S', &cfg.dspec,        dspec_w_dtype),
                OPT_END()
        };
 
@@ -6348,12 +6354,20 @@ static int write_uncor(int argc, char **argv, struct command *cmd, struct plugin
                }
        }
 
+       if (cfg.dtype > 0xf) {
+               fprintf(stderr, "Invalid directive type, %x\n", cfg.dtype);
+               err = -EINVAL;
+               goto close_dev;
+       }
+
        struct nvme_io_args args = {
                .args_size      = sizeof(args),
                .fd             = dev_fd(dev),
                .nsid           = cfg.namespace_id,
                .slba           = cfg.start_block,
                .nlb            = cfg.block_count,
+               .control        = cfg.dtype << 4,
+               .dspec          = cfg.dspec,
                .timeout        = NVME_DEFAULT_IOCTL_TIMEOUT,
                .result         = NULL,
        };
@@ -6423,6 +6437,7 @@ static int write_zeroes(int argc, char **argv, struct command *cmd, struct plugi
                __u32   namespace_id;
                __u64   start_block;
                __u16   block_count;
+               __u8    dtype;
                bool    deac;
                bool    limited_retry;
                bool    force_unit_access;
@@ -6432,27 +6447,31 @@ static int write_zeroes(int argc, char **argv, struct command *cmd, struct plugi
                __u16   app_tag;
                __u64   storage_tag;
                bool    storage_tag_check;
+               __u16   dspec;
        };
 
        struct config cfg = {
                .namespace_id           = 0,
                .start_block            = 0,
                .block_count            = 0,
-               .deac                   = false,
+               .dtype                          = 0,
+               .deac                           = false,
                .limited_retry          = false,
                .force_unit_access      = false,
-               .prinfo                 = 0,
-               .ref_tag                = 0,
+               .prinfo                         = 0,
+               .ref_tag                        = 0,
                .app_tag_mask           = 0,
-               .app_tag                = 0,
+               .app_tag                        = 0,
                .storage_tag            = 0,
                .storage_tag_check      = false,
+               .dspec                          = 0,
        };
 
        OPT_ARGS(opts) = {
                OPT_UINT("namespace-id",      'n', &cfg.namespace_id,      namespace_desired),
                OPT_SUFFIX("start-block",     's', &cfg.start_block,       start_block),
                OPT_SHRT("block-count",       'c', &cfg.block_count,       block_count),
+               OPT_BYTE("dir-type",          'T', &cfg.dtype,             dtype),
                OPT_FLAG("deac",              'd', &cfg.deac,              deac),
                OPT_FLAG("limited-retry",     'l', &cfg.limited_retry,     limited_retry),
                OPT_FLAG("force-unit-access", 'f', &cfg.force_unit_access, force_unit_access),
@@ -6462,6 +6481,7 @@ static int write_zeroes(int argc, char **argv, struct command *cmd, struct plugi
                OPT_SHRT("app-tag",           'a', &cfg.app_tag,           app_tag),
                OPT_SUFFIX("storage-tag",     'S', &cfg.storage_tag,       storage_tag),
                OPT_FLAG("storage-tag-check", 'C', &cfg.storage_tag_check, storage_tag_check),
+               OPT_SHRT("dir-spec",          'D', &cfg.dspec,             dspec_w_dtype),
                OPT_END()
        };
 
@@ -6474,6 +6494,12 @@ static int write_zeroes(int argc, char **argv, struct command *cmd, struct plugi
                goto close_dev;
        }
 
+       if (cfg.dtype > 0xf) {
+               fprintf(stderr, "Invalid directive type, %x\n", cfg.dtype);
+               err = -EINVAL;
+               goto close_dev;
+       }
+
        control |= (cfg.prinfo << 10);
        if (cfg.limited_retry)
                control |= NVME_IO_LR;
@@ -6483,6 +6509,7 @@ static int write_zeroes(int argc, char **argv, struct command *cmd, struct plugi
                control |= NVME_IO_DEAC;
        if (cfg.storage_tag_check)
                control |= NVME_IO_STC;
+       control |= (cfg.dtype << 4);
        if (!cfg.namespace_id) {
                err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id);
                if (err < 0) {
@@ -6515,7 +6542,7 @@ static int write_zeroes(int argc, char **argv, struct command *cmd, struct plugi
 
        struct nvme_io_args args = {
                .args_size      = sizeof(args),
-               .fd             = dev_fd(dev),
+               .fd                     = dev_fd(dev),
                .nsid           = cfg.namespace_id,
                .slba           = cfg.start_block,
                .nlb            = cfg.block_count,
@@ -6526,6 +6553,7 @@ static int write_zeroes(int argc, char **argv, struct command *cmd, struct plugi
                .sts            = sts,
                .pif            = pif,
                .storage_tag    = cfg.storage_tag,
+               .dspec          = cfg.dspec,
                .timeout        = NVME_DEFAULT_IOCTL_TIMEOUT,
                .result         = NULL,
        };