Skip to content

Commit 2b59f0a

Browse files
committed
ioctl: return status code when using liburing
The status code should be propagated like it is done for the ioctl interface. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 4a615f3 commit 2b59f0a

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

src/nvme/ioctl.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -400,20 +400,21 @@ static int nvme_uring_cmd_admin_passthru_async(struct io_uring *ring, struct nvm
400400
sqe->fd = args->fd;
401401
sqe->opcode = IORING_OP_URING_CMD;
402402
sqe->cmd_op = NVME_URING_CMD_ADMIN;
403+
sqe->user_data = (__u64)(uintptr_t)args;
403404

404405
ret = io_uring_submit(ring);
405406
if (ret < 0) {
406407
errno = -ret;
407408
return -1;
408409
}
409-
410410
return 0;
411411
}
412412

413413
static int nvme_uring_cmd_wait_complete(struct io_uring *ring, int n)
414414
{
415+
struct nvme_get_log_args *args;
415416
struct io_uring_cqe *cqe;
416-
int i, ret;
417+
int i, ret = 0;
417418

418419
for (i = 0; i < n; i++) {
419420
ret = io_uring_wait_cqe(ring, &cqe);
@@ -422,10 +423,18 @@ static int nvme_uring_cmd_wait_complete(struct io_uring *ring, int n)
422423
return -1;
423424
}
424425

426+
if (cqe->res) {
427+
args = (struct nvme_get_log_args *)cqe->user_data;
428+
if (args->result)
429+
*args->result = cqe->res;
430+
ret = cqe->res;
431+
break;
432+
}
433+
425434
io_uring_cqe_seen(ring, cqe);
426435
}
427436

428-
return n;
437+
return ret;
429438
}
430439
#endif
431440

@@ -469,11 +478,14 @@ int nvme_get_log_page(int fd, __u32 xfer_len, struct nvme_get_log_args *args)
469478
#ifdef CONFIG_LIBURING
470479
if (io_uring_kernel_support == IO_URING_AVAILABLE) {
471480
if (n >= NVME_URING_ENTRIES) {
472-
nvme_uring_cmd_wait_complete(&ring, n);
481+
ret = nvme_uring_cmd_wait_complete(&ring, n);
473482
n = 0;
474483
}
475484
n += 1;
476485
ret = nvme_uring_cmd_admin_passthru_async(&ring, args);
486+
487+
if (ret)
488+
nvme_uring_cmd_exit(&ring);
477489
} else
478490
#endif
479491
ret = nvme_get_log(args);
@@ -488,8 +500,8 @@ int nvme_get_log_page(int fd, __u32 xfer_len, struct nvme_get_log_args *args)
488500
if (io_uring_kernel_support == IO_URING_AVAILABLE) {
489501
ret = nvme_uring_cmd_wait_complete(&ring, n);
490502
nvme_uring_cmd_exit(&ring);
491-
if (ret < 0)
492-
return -1;
503+
if (ret)
504+
return ret;
493505
}
494506
#endif
495507
return 0;

0 commit comments

Comments
 (0)