Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ublk: allow non-blocking ctrl cmds in IO_URING_F_NONBLOCK issue

Handling most of the ublksrv_ctrl_cmd opcodes require locking a mutex,
so ublk_ctrl_uring_cmd() bails out with EAGAIN when called with the
IO_URING_F_NONBLOCK issue flag. However, several opcodes can be handled
without blocking:
- UBLK_CMD_GET_QUEUE_AFFINITY
- UBLK_CMD_GET_DEV_INFO
- UBLK_CMD_GET_DEV_INFO2
- UBLK_U_CMD_GET_FEATURES

Handle these opcodes synchronously instead of returning EAGAIN so
io_uring doesn't need to issue the command via the worker thread pool.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Caleb Sander Mateos and committed by
Jens Axboe
87213b0d 0f45353d

+15 -1
+15 -1
drivers/block/ublk_drv.c
··· 3673 3673 return ret; 3674 3674 } 3675 3675 3676 + static bool ublk_ctrl_uring_cmd_may_sleep(u32 cmd_op) 3677 + { 3678 + switch (_IOC_NR(cmd_op)) { 3679 + case UBLK_CMD_GET_QUEUE_AFFINITY: 3680 + case UBLK_CMD_GET_DEV_INFO: 3681 + case UBLK_CMD_GET_DEV_INFO2: 3682 + case _IOC_NR(UBLK_U_CMD_GET_FEATURES): 3683 + return false; 3684 + default: 3685 + return true; 3686 + } 3687 + } 3688 + 3676 3689 static int ublk_ctrl_uring_cmd(struct io_uring_cmd *cmd, 3677 3690 unsigned int issue_flags) 3678 3691 { ··· 3694 3681 u32 cmd_op = cmd->cmd_op; 3695 3682 int ret = -EINVAL; 3696 3683 3697 - if (issue_flags & IO_URING_F_NONBLOCK) 3684 + if (ublk_ctrl_uring_cmd_may_sleep(cmd_op) && 3685 + issue_flags & IO_URING_F_NONBLOCK) 3698 3686 return -EAGAIN; 3699 3687 3700 3688 ublk_ctrl_cmd_dump(cmd);