@@ -400,6 +400,7 @@ 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 ) {
@@ -412,8 +413,9 @@ static int nvme_uring_cmd_admin_passthru_async(struct io_uring *ring, struct nvm
412413
413414static int nvme_uring_cmd_wait_complete (struct io_uring * ring , int n )
414415{
416+ struct nvme_get_log_args * args ;
415417 struct io_uring_cqe * cqe ;
416- int i , ret ;
418+ int i , ret = 0 ;
417419
418420 for (i = 0 ; i < n ; i ++ ) {
419421 ret = io_uring_wait_cqe (ring , & cqe );
@@ -422,10 +424,18 @@ static int nvme_uring_cmd_wait_complete(struct io_uring *ring, int n)
422424 return -1 ;
423425 }
424426
427+ if (cqe -> res ) {
428+ args = (struct nvme_get_log_args * )cqe -> user_data ;
429+ if (args -> result )
430+ * args -> result = cqe -> res ;
431+ ret = cqe -> res ;
432+ break ;
433+ }
434+
425435 io_uring_cqe_seen (ring , cqe );
426436 }
427437
428- return n ;
438+ return ret ;
429439}
430440#endif
431441
@@ -469,11 +479,14 @@ int nvme_get_log_page(int fd, __u32 xfer_len, struct nvme_get_log_args *args)
469479#ifdef CONFIG_LIBURING
470480 if (io_uring_kernel_support == IO_URING_AVAILABLE ) {
471481 if (n >= NVME_URING_ENTRIES ) {
472- nvme_uring_cmd_wait_complete (& ring , n );
482+ ret = nvme_uring_cmd_wait_complete (& ring , n );
473483 n = 0 ;
474484 }
475485 n += 1 ;
476486 ret = nvme_uring_cmd_admin_passthru_async (& ring , args );
487+
488+ if (ret )
489+ nvme_uring_cmd_exit (& ring );
477490 } else
478491#endif
479492 ret = nvme_get_log (args );
@@ -488,8 +501,8 @@ int nvme_get_log_page(int fd, __u32 xfer_len, struct nvme_get_log_args *args)
488501 if (io_uring_kernel_support == IO_URING_AVAILABLE ) {
489502 ret = nvme_uring_cmd_wait_complete (& ring , n );
490503 nvme_uring_cmd_exit (& ring );
491- if (ret < 0 )
492- return -1 ;
504+ if (ret )
505+ return ret ;
493506 }
494507#endif
495508 return 0 ;
0 commit comments