From 85d79abea329abd4851e2e0bb98c5742a0720234 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Wed, 28 May 2025 13:42:54 +0200 Subject: [PATCH] ioctl: only use io_uring for char devices The block devices io_uring interface is the generic block subsystem interface and not the nvme one. Thus the nvme io_uring operation only work on a char devices, e.g either nvme0 or ng0n1. Reported-by: Yi Zhang Reported-by: Shinichiro Kawasaki Signed-off-by: Daniel Wagner --- src/nvme/ioctl.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/nvme/ioctl.c b/src/nvme/ioctl.c index 9a9db0be3..f06c03be0 100644 --- a/src/nvme/ioctl.c +++ b/src/nvme/ioctl.c @@ -452,10 +452,16 @@ int nvme_get_log_page(int fd, __u32 xfer_len, struct nvme_get_log_args *args) #ifdef CONFIG_LIBURING int n = 0; struct io_uring ring; + struct stat st; + bool use_uring = false; if (io_uring_kernel_support == IO_URING_AVAILABLE) { - if (nvme_uring_cmd_setup(&ring)) - return -1; + if (fstat(fd, &st) == 0 && S_ISCHR(st.st_mode)) { + use_uring = true; + + if (nvme_uring_cmd_setup(&ring)) + return -1; + } } #endif /* @@ -477,7 +483,7 @@ int nvme_get_log_page(int fd, __u32 xfer_len, struct nvme_get_log_args *args) args->log = ptr; args->rae = offset + xfer < data_len || retain; #ifdef CONFIG_LIBURING - if (io_uring_kernel_support == IO_URING_AVAILABLE) { + if (io_uring_kernel_support == IO_URING_AVAILABLE && use_uring) { if (n >= NVME_URING_ENTRIES) { ret = nvme_uring_cmd_wait_complete(&ring, n); n = 0; @@ -498,7 +504,7 @@ int nvme_get_log_page(int fd, __u32 xfer_len, struct nvme_get_log_args *args) } while (offset < data_len); #ifdef CONFIG_LIBURING - if (io_uring_kernel_support == IO_URING_AVAILABLE) { + if (io_uring_kernel_support == IO_URING_AVAILABLE && use_uring) { ret = nvme_uring_cmd_wait_complete(&ring, n); nvme_uring_cmd_exit(&ring); if (ret)