From ca0339d8e5b3cf486c09d79627374f14f851d57f Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Mon, 28 Jun 2021 14:12:44 +0200 Subject: [PATCH] nvme_cuse: Return ENOTTY in case unsupported ioctl is sent to a device Latest nvme-cli (>= 1.13) fails to issue commands towards SPDK's cuse ctrl device, e.g.: $ nvme get-feature /dev/spdk/nvme0 -f 1 -s 1 -l 100 nvme_cuse.c: 654:cuse_ctrlr_ioctl: *ERROR*: Unsupported IOCTL 0x4E40. get-namespace-id: Invalid argument The reason is because nvme-cli now also sends NVME_IOCTL_ID to the target device to determine if it's indeed a controller or a ns. In case kernel returns ENOTTY then nvme-cli considers the device to be a controller. Since cuse_ctrlr_ioctl() returns EINVAL in such a case the nvme-cli fails. To avoid this simply replace EINVAL with ENOTTY for the ioctls that may be not supported by ctrl or ns device. nvme-cli commit in question: https://github.com/linux-nvme/nvme-cli/commit/fa2b91da7439b776a7eb01af9e2b23ac1373c027 Signed-off-by: Michal Berger Change-Id: I29003864bc2a5c1a8906d6d01beba3d6f4e31b0e Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8531 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Krzysztof Karas Reviewed-by: Tomasz Zawadzki Reviewed-by: Shuhei Matsumoto --- lib/nvme/nvme_cuse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/nvme/nvme_cuse.c b/lib/nvme/nvme_cuse.c index 9c3198ee5..d2effe8bd 100644 --- a/lib/nvme/nvme_cuse.c +++ b/lib/nvme/nvme_cuse.c @@ -652,7 +652,7 @@ cuse_ctrlr_ioctl(fuse_req_t req, int cmd, void *arg, default: SPDK_ERRLOG("Unsupported IOCTL 0x%X.\n", cmd); - fuse_reply_err(req, EINVAL); + fuse_reply_err(req, ENOTTY); } } @@ -711,7 +711,7 @@ cuse_ns_ioctl(fuse_req_t req, int cmd, void *arg, default: SPDK_ERRLOG("Unsupported IOCTL 0x%X.\n", cmd); - fuse_reply_err(req, EINVAL); + fuse_reply_err(req, ENOTTY); } }