From: Steven Seungcheol Lee Date: Thu, 9 Feb 2023 04:18:46 +0000 (+0900) Subject: nvme: Add dtype, dspec on write-zeroes, write-uncor X-Git-Tag: v2.5~174 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=30dda2c8b3cf1b6e438a7dfcf03973d3fd127321;p=users%2Fsagi%2Fnvme-cli.git nvme: Add dtype, dspec on write-zeroes, write-uncor Based on TP4146 Flexible Data Placement 2022.11.30 Ratified Reported-by: Youngjin Jung Signed-off-by: Steven Seungcheol Lee --- diff --git a/Documentation/nvme-create-ns.txt b/Documentation/nvme-create-ns.txt index dfa56565..5035b132 100644 --- a/Documentation/nvme-create-ns.txt +++ b/Documentation/nvme-create-ns.txt @@ -101,4 +101,4 @@ EXAMPLES NVME ---- -Part of the nvme-user suite +Part of the nvme-user suite \ No newline at end of file diff --git a/Documentation/nvme-write-uncor.txt b/Documentation/nvme-write-uncor.txt index 38af3136..19415c22 100644 --- a/Documentation/nvme-write-uncor.txt +++ b/Documentation/nvme-write-uncor.txt @@ -11,7 +11,8 @@ SYNOPSIS 'nvme-write-uncor' [--start-block= | -s ] [--block-count= | -c ] [--namespace-id= | -n ] - [--force] + [--dir-type= | -T ] + [--dir-spec= | -S ] DESCRIPTION ----------- @@ -32,9 +33,13 @@ OPTIONS -n :: Namespace ID use in the command. ---force:: - Ignore namespace is currently busy and performed the operation - even though. +-T :: +--dir-type=:: + Directive type + +-S :: +--dir-spec=:: + Directive specific EXAMPLES -------- diff --git a/Documentation/nvme-write-zeroes.txt b/Documentation/nvme-write-zeroes.txt index cfcac36f..7e936e51 100644 --- a/Documentation/nvme-write-zeroes.txt +++ b/Documentation/nvme-write-zeroes.txt @@ -20,7 +20,8 @@ SYNOPSIS [--namespace-id= | -n ] [--storage-tag | -S ] [--storage-tag-check | -C ] - [--force] + [--dir-type= | -T ] + [--dir-spec= | -D ] 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 :: +--dir-type=:: + Directive type + +-D :: +--dir-spec=:: + Directive specific EXAMPLES -------- diff --git a/completions/bash-nvme-completion.sh b/completions/bash-nvme-completion.sh index fae3ab40..2fc73e50 100644 --- a/completions/bash-nvme-completion.sh +++ b/completions/bash-nvme-completion.sh @@ -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 75c58699..ca1f0aba 100644 --- 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, };