libnvme/ioctl: limit to use NVME_IOCTL_IO64_CMD only for block dev#3121
libnvme/ioctl: limit to use NVME_IOCTL_IO64_CMD only for block dev#3121igaw merged 1 commit intolinux-nvme:masterfrom
Conversation
|
|
|
For the nvmeX char dev |
9c53033 to
387688b
Compare
|
Rebased and changed the patch to introduce |
Since currently only NVME_IOCTL_ADMIN64_CMD checked for ioctrl64. But NVME_IOCTL_IO64_CMD not checked as same. Also currently NVME_IOCTL_IO64_CMD not supported for the char dev. Therefore introduce the ioctl_io64 flag to use NVME_IOCTL_IO64_CMD. Signed-off-by: Tokunori Ikegami <[email protected]> [wagi: renamed ioctl64 to ioctl_admin64] Signed-off-by: Daniel Wagner <[email protected]>
|
Just documenting what I've done to figure out what's the problem. The commit 65e68edce0db ("nvme: allow 64-bit results in passthru commands") introduced the 64bit version of admin and the io ioctl.
# strace -o /tmp/trace nvme read -s 4096 -z 0x1000 /dev/ng0n1
# root@localhost:~# grep IOCTL /tmp/trace
ioctl(3, NVME_IOCTL_ADMIN64_CMD, 0x7fff87090700) = 16641
ioctl(3, NVME_IOCTL_ID, 0) = 1
ioctl(3, NVME_IOCTL_ADMIN64_CMD, 0x7fff87090880) = 0
ioctl(3, NVME_IOCTL_ADMIN64_CMD, 0x7fff87090880) = 0
ioctl(3, NVME_IOCTL_ADMIN64_CMD, 0x7fff87090740) = 0
ioctl(3, NVME_IOCTL_ADMIN64_CMD, 0x7fff87090740) = 0
ioctl(3, NVME_IOCTL_IO64_CMD, 0x7fff87090880) = 0
# root@localhost:~# strace -o /tmp/trace nvme read -s 4096 -z 0x1000 /dev/nvme0
get-namespace-id: Inappropriate ioctl for deviceI think this behaves correctly, but the error message could be better.
# root@localhost:~# strace -o /tmp/trace nvme read -s 4096 -n 1 -z 0x1000 /dev/nvme0
submit-io: Inappropriate ioctl for device
#root@localhost:~# grep ioctl /tmp/trace
ioctl(3, NVME_IOCTL_ADMIN64_CMD, 0x7fff54712120) = 16641
ioctl(3, NVME_IOCTL_ADMIN64_CMD, 0x7fff547122a0) = 0
ioctl(3, NVME_IOCTL_ADMIN64_CMD, 0x7fff547122a0) = 0
ioctl(3, NVME_IOCTL_ADMIN64_CMD, 0x7fff54712160) = 0
ioctl(3, NVME_IOCTL_ADMIN64_CMD, 0x7fff54712160) = 0
ioctl(3, NVME_IOCTL_IO64_CMD, 0x7fff547122a0) = -1 ENOTTY (Inappropriate ioctl for device)
write(2, "submit-io: Inappropriate ioctl f"..., 41) = 41Looking at the current implementation in Linux long nvme_dev_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
[...]
switch (cmd) {
case NVME_IOCTL_ADMIN_CMD:
return nvme_user_cmd(ctrl, NULL, argp, 0, open_for_write);
case NVME_IOCTL_ADMIN64_CMD:
return nvme_user_cmd64(ctrl, NULL, argp, 0, open_for_write);
case NVME_IOCTL_IO_CMD:
return nvme_dev_user_cmd(ctrl, argp, open_for_write);
[...]
}That means we can't rely on checking |
|
The kernel support seems to be an oversight. I don't see an obvious reason why it should not work. Thus we should fix this in the kernel as well. |
|
Thanks! |
|
I tried to fix the kernel also by the patch below but seems unfortunately difficult to be applied it. Thank you. |
Since currently NVME_IOCTL_IO64_CMD not supported for the char dev. Currently the char dev nvmeX not able be used for the io-passthru command. Also previously NVME_IOCTL_IO_CMD used for the io-passthru command. Therefore for the char dev nvmeX use NVME_IOCTL_IO_CMD instead.