[PATCH] nvme-cli: fix the [data|mdata]_len param

Chaitanya Kulkarni chaitanyak at nvidia.com
Tue Sep 7 13:11:36 PDT 2021


From: Chaitanya Kulkarni <kch at nvidia.com>

Add missing user data buffer and metadata buffer size parameter for the
passthru I/O commands since driver code expects these values to be set
from the user space. Without this patch blktests/nvme/029 is failing.

Signed-off-by: Chaitanya Kulkarni <kch at nvidia.com>
---
Here is a test log :-

 # ./check tests/nvme/029
nvme/029 (test userspace IO via nvme-cli read/write interface) [failed]
    runtime  1.551s  ...  1.543s
    --- tests/nvme/029.out	2021-08-29 01:09:20.288901799 -0700
    +++ /mnt/data/blktests/results/nodev/nvme/029.out.bad	2021-09-07 13:08:08.011832111 -0700
    @@ -1,4 +1,10 @@
     Running nvme/029
     91fdba0d-f87b-4c25-b80f-db7be1418b9e
     uuid.91fdba0d-f87b-4c25-b80f-db7be1418b9e
    +FAIL 512
    +FAIL 513
    +FAIL 513
    +FAIL 511 1024
    ...
    (Run 'diff -u tests/nvme/029.out /mnt/data/blktests/results/nodev/nvme/029.out.bad' to see the entire diff)
root at dev blktests (master) # cd -
/root/data/nvme-cli
root at dev nvme-cli ((HEAD detached from v1.15)) # git am 0001-nvme-cli-fix-the-data-mdata-_len-param.patch
Applying: nvme-cli: fix the [data|mdata]_len param
root at dev nvme-cli ((HEAD detached from v1.15)) # makej install 
NVME_VERSION = 1.15.2.ge03e
    CC nvme-print.o
    CC nvme-ioctl.o
    CC nvme-rpmb.o
    CC nvme-lightnvm.o
    CC nvme-models.o
    CC plugin.o
    CC fabrics.o
    CC nvme-filters.o
    CC nvme-status.o
    CC nvme-topology.o
    CC plugins/intel/intel-nvme.o
    CC plugins/amzn/amzn-nvme.o
    CC plugins/lnvm/lnvm-nvme.o
    CC plugins/memblaze/memblaze-nvme.o
    CC plugins/wdc/wdc-nvme.o
    CC plugins/wdc/wdc-utils.o
    CC plugins/huawei/huawei-nvme.o
    CC plugins/netapp/netapp-nvme.o
    CC plugins/toshiba/toshiba-nvme.o
    CC plugins/micron/micron-nvme.o
    CC plugins/seagate/seagate-nvme.o
    CC plugins/virtium/virtium-nvme.o
    CC plugins/shannon/shannon-nvme.o
    CC plugins/dera/dera-nvme.o
    CC plugins/scaleflux/sfx-nvme.o
    CC plugins/transcend/transcend-nvme.o
    CC plugins/zns/zns.o
    CC plugins/nvidia/nvidia-nvme.o
    CC plugins/ymtc/ymtc-nvme.o
    CC util/argconfig.o
make -C Documentation install-no-build
    CC util/parser.o
    CC util/suffix.o
install -d /usr/share/bash-completion/completions
install -d /usr/share/zsh/site-functions
    CC util/cleanup.o
install -d /etc/nvme
install -d /usr/lib/systemd/system
    CC util/log.o
install -d /etc/udev/rules.d
install -m 644 -T ./completions/bash-nvme-completion.sh /usr/share/bash-completion/completions/nvme
    CC util/json.o
install -m 644 -T ./completions/_nvme /usr/share/zsh/site-functions/_nvme
install -d /usr/lib/dracut/dracut.conf.d
touch /etc/nvme/hostnqn
install -m 644 ./nvmf-autoconnect/systemd/* /usr/lib/systemd/system
install -m 644 ./nvmf-autoconnect/udev-rules/* /etc/udev/rules.d
touch /etc/nvme/hostid
install -m 644 70-nvmf-autoconnect.conf /usr/lib/dracut/dracut.conf.d
if [ ! -f /etc/nvme/discovery.conf ]; then \
	install -m 644 -T ./etc/discovery.conf.in /etc/nvme/discovery.conf; \
fi
if [ ! -s /etc/nvme/hostnqn ]; then \
	echo `/usr/sbin/nvme gen-hostnqn` > /etc/nvme/hostnqn; \
fi
if [ ! -s /etc/nvme/hostid ]; then \
	uuidgen > /etc/nvme/hostid; \
fi
make[1]: Entering directory '/mnt/data/nvme-cli/Documentation'
install -d -m 755 /usr/local/share/man/man1
install -m 644 nvme-admin-passthru.1 nvme-ana-log.1 nvme-attach-ns.1 nvme-capacity-mgmt.1 nvme-changed-ns-list-log.1 nvme-compare.1 nvme-connect-all.1 nvme-connect.1 nvme-copy.1 nvme-create-ns.1 nvme-delete-ns.1 nvme-dera-stat.1 nvme-detach-ns.1 nvme-device-self-test.1 nvme-dir-receive.1 nvme-dir-send.1 nvme-disconnect-all.1 nvme-disconnect.1 nvme-discover.1 nvme-dsm.1 nvme-effects-log.1 nvme-endurance-event-agg-log.1 nvme-endurance-log.1 nvme-error-log.1 nvme-flush.1 nvme-format.1 nvme-fw-commit.1 nvme-fw-download.1 nvme-fw-log.1 nvme-gen-hostnqn.1 nvme-get-feature.1 nvme-get-lba-status.1 nvme-get-log.1 nvme-get-ns-id.1 nvme-get-property.1 nvme-help.1 nvme-huawei-id-ctrl.1 nvme-huawei-list.1 nvme-id-ctrl.1 nvme-id-domain.1 nvme-id-iocs.1 nvme-id-ns.1 nvme-id-nvmset.1 nvme-intel-id-ctrl.1 nvme-intel-internal-log.1 nvme-intel-lat-stats.1 nvme-intel-market-name.1 nvme-intel-smart-log-add.1 nvme-intel-temp-stats.1 nvme-io-passthru.1 nvme-lba-status-log.1 nvme-list-ctrl.1 nvme-list-ns.1 nvme-list-subsys.1 nvme-list.1 nvme-lnvm-create.1 nvme-lnvm-diag-bbtbl.1 nvme-lnvm-diag-set-bbtbl.1 nvme-lnvm-factory.1 nvme-lnvm-id-ns.1 nvme-lnvm-info.1 nvme-lnvm-init.1 nvme-lnvm-list.1 nvme-lnvm-remove.1 nvme-micron-clear-pcie-errors.1 nvme-micron-internal-log.1 nvme-micron-nand-stats.1 nvme-micron-pcie-stats.1 nvme-micron-selective-download.1 nvme-micron-smart-add-log.1 nvme-micron-temperature-stats.1 nvme-netapp-ontapdevices.1 nvme-netapp-smdevices.1 nvme-ns-descs.1 nvme-ns-rescan.1 nvme-nvm-id-ctrl.1 nvme-persistent-event-log.1 nvme-predictable-lat-log.1 nvme-pred-lat-event-agg-log.1 nvme-primary-ctrl-caps.1 nvme-read.1 nvme-reset.1 nvme-resv-acquire.1 nvme-resv-notif-log.1 nvme-resv-register.1 nvme-resv-release.1 nvme-resv-report.1 nvme-rpmb.1 nvme-sanitize-log.1 nvme-sanitize.1 nvme-security-recv.1 nvme-security-send.1 nvme-self-test-log.1 nvme-set-feature.1 nvme-set-property.1 nvme-show-hostnqn.1 nvme-show-regs.1 nvme-smart-log.1 nvme-subsystem-reset.1 nvme-telemetry-log.1 nvme-toshiba-clear-pcie-correctable-errors.1 nvme-toshiba-vs-internal-log.1 nvme-toshiba-vs-smart-add-log.1 nvme-transcend-badblock.1 nvme-transcend-healthvalue.1 nvme-verify.1 nvme-virtium-save-smart-to-vtview-log.1 nvme-virtium-show-identify.1 nvme-wdc-capabilities.1 nvme-wdc-cap-diag.1 nvme-wdc-clear-assert-dump.1 nvme-wdc-clear-fw-activate-history.1 nvme-wdc-clear-pcie-correctable-errors.1 nvme-wdc-cloud-SSD-plugin-version.1 nvme-wdc-drive-essentials.1 nvme-wdc-drive-log.1 nvme-wdc-drive-resize.1 nvme-wdc-enc-get-log.1 nvme-wdc-get-crash-dump.1 nvme-wdc-get-drive-status.1 nvme-wdc-get-pfail-dump.1 nvme-wdc-id-ctrl.1 nvme-wdc-log-page-directory.1 nvme-wdc-namespace-resize.1 nvme-wdc-purge-monitor.1 nvme-wdc-purge.1 nvme-wdc-vs-drive-info.1 nvme-wdc-vs-error-reason-identifier.1 nvme-wdc-vs-fw-activate-history.1 nvme-wdc-vs-internal-log.1 nvme-wdc-vs-nand-stats.1 nvme-wdc-vs-smart-add-log.1 nvme-wdc-vs-telemetry-controller-option.1 nvme-wdc-vs-temperature-stats.1 nvme-write.1 nvme-write-uncor.1 nvme-write-zeroes.1 nvme-zns-changed-zone-list.1 nvme-zns-close-zone.1 nvme-zns-finish-zone.1 nvme-zns-id-ctrl.1 nvme-zns-id-ns.1 nvme-zns-offline-zone.1 nvme-zns-open-zone.1 nvme-zns-report-zones.1 nvme-zns-reset-zone.1 nvme-zns-set-zone-desc.1 nvme-zns-zone-append.1 nvme-zns-zone-mgmt-recv.1 nvme-zns-zone-mgmt-send.1 nvme.1 /usr/local/share/man/man1
make[1]: Leaving directory '/mnt/data/nvme-cli/Documentation'
    CC nvme
rm -f /usr/local/sbin/nvme
install -d /usr/sbin
install -m 755 nvme /usr/sbin
root at dev nvme-cli ((HEAD detached from v1.15)) # cd -
/root/data/blktests
root at dev blktests (master) # ./check tests/nvme/029
nvme/029 (test userspace IO via nvme-cli read/write interface) [passed]
    runtime  1.543s  ...  1.559s
---
 nvme-ioctl.c | 5 ++++-
 nvme-ioctl.h | 5 +++--
 nvme.c       | 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/nvme-ioctl.c b/nvme-ioctl.c
index c511808..08ea160 100644
--- a/nvme-ioctl.c
+++ b/nvme-ioctl.c
@@ -126,7 +126,8 @@ int nvme_passthru(int fd, unsigned long ioctl_cmd, __u8 opcode,
 
 int nvme_io(int fd, __u8 opcode, __u32 nsid, __u64 slba, __u16 nblocks,
 		__u16 control, __u32 dsmgmt, __u32 reftag, __u16 apptag,
-		__u16 appmask, __u64 storage_tag, void *data, void *metadata)
+		__u16 appmask, __u64 storage_tag, void *data, __u32 buffer_size,
+		void *metadata, __u32 mbuffer_size)
 {
 	struct nvme_passthru_cmd cmd = {
 		.opcode		= opcode,
@@ -141,6 +142,8 @@ int nvme_io(int fd, __u8 opcode, __u32 nsid, __u64 slba, __u16 nblocks,
 		.cdw13		= dsmgmt,
 		.cdw14		= reftag,
 		.cdw15		= apptag | (appmask << 16),
+		.data_len	= buffer_size,
+		.metadata_len	= mbuffer_size,
 	};
 
 	return nvme_submit_io_passthru(fd, &cmd);
diff --git a/nvme-ioctl.h b/nvme-ioctl.h
index 2e24b83..b3fbde2 100644
--- a/nvme-ioctl.h
+++ b/nvme-ioctl.h
@@ -26,8 +26,9 @@ int nvme_passthru(int fd, unsigned long ioctl_cmd, __u8 opcode, __u8 flags,
 
 /* NVME_SUBMIT_IO */
 int nvme_io(int fd, __u8 opcode, __u32 nsid, __u64 slba, __u16 nblocks,
-	      __u16 control, __u32 dsmgmt, __u32 reftag, __u16 apptag,
-	      __u16 appmask, __u64 storage_tag, void *data, void *metadata);
+		__u16 control, __u32 dsmgmt, __u32 reftag, __u16 apptag,
+		__u16 appmask, __u64 storage_tag, void *data, __u32 buffer_size,
+		void *metadata, __u32 mbuffer_size);
 
 /* NVME_IO_CMD */
 int nvme_passthru_io(int fd, __u8 opcode, __u8 flags, __u16 rsvd,
diff --git a/nvme.c b/nvme.c
index c10932f..01ec5a2 100644
--- a/nvme.c
+++ b/nvme.c
@@ -5244,7 +5244,7 @@ static int submit_io(int opcode, char *command, const char *desc,
 	gettimeofday(&start_time, NULL);
 	err = nvme_io(fd, opcode, cfg.namespace_id, cfg.start_block, cfg.block_count,
 			 control, dsmgmt, cfg.ref_tag, cfg.app_tag, cfg.app_tag_mask,
-			 cfg.storage_tag, buffer, mbuffer);
+			 cfg.storage_tag, buffer, buffer_size, mbuffer, mbuffer_size);
 	gettimeofday(&end_time, NULL);
 	if (cfg.latency)
 		printf(" latency: %s: %llu us\n",
-- 
2.29.0




More information about the Linux-nvme mailing list