Skip to content

Commit 0454a99

Browse files
committed
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 <yi.zhang@redhat.com> Reported-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com> Signed-off-by: Daniel Wagner <wagi@kernel.org>
1 parent a4dad98 commit 0454a99

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/nvme/ioctl.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,16 @@ int nvme_get_log_page(int fd, __u32 xfer_len, struct nvme_get_log_args *args)
452452
#ifdef CONFIG_LIBURING
453453
int n = 0;
454454
struct io_uring ring;
455+
struct stat st;
456+
bool use_uring = false;
455457

456458
if (io_uring_kernel_support == IO_URING_AVAILABLE) {
457-
if (nvme_uring_cmd_setup(&ring))
458-
return -1;
459+
if (fstat(fd, &st) == 0 && S_ISCHR(st.st_mode)) {
460+
use_uring = true;
461+
462+
if (nvme_uring_cmd_setup(&ring))
463+
return -1;
464+
}
459465
}
460466
#endif
461467
/*
@@ -477,7 +483,7 @@ int nvme_get_log_page(int fd, __u32 xfer_len, struct nvme_get_log_args *args)
477483
args->log = ptr;
478484
args->rae = offset + xfer < data_len || retain;
479485
#ifdef CONFIG_LIBURING
480-
if (io_uring_kernel_support == IO_URING_AVAILABLE) {
486+
if (io_uring_kernel_support == IO_URING_AVAILABLE && use_uring) {
481487
if (n >= NVME_URING_ENTRIES) {
482488
ret = nvme_uring_cmd_wait_complete(&ring, n);
483489
n = 0;
@@ -498,7 +504,7 @@ int nvme_get_log_page(int fd, __u32 xfer_len, struct nvme_get_log_args *args)
498504
} while (offset < data_len);
499505

500506
#ifdef CONFIG_LIBURING
501-
if (io_uring_kernel_support == IO_URING_AVAILABLE) {
507+
if (io_uring_kernel_support == IO_URING_AVAILABLE && use_uring) {
502508
ret = nvme_uring_cmd_wait_complete(&ring, n);
503509
nvme_uring_cmd_exit(&ring);
504510
if (ret)

0 commit comments

Comments
 (0)