Commit ca0339d8 authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

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: default avatarMichal Berger <michalx.berger@intel.com>
Change-Id: I29003864bc2a5c1a8906d6d01beba3d6f4e31b0e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8531


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent aa303d87
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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);
	}
}