Skip to content

Commit d4a9390

Browse files
calebsanderkawasaki
authored andcommitted
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>
1 parent ec9caac commit d4a9390

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

drivers/block/ublk_drv.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3673,6 +3673,19 @@ static int ublk_ctrl_uring_cmd_permission(struct ublk_device *ub,
36733673
return ret;
36743674
}
36753675

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+
36763689
static int ublk_ctrl_uring_cmd(struct io_uring_cmd *cmd,
36773690
unsigned int issue_flags)
36783691
{
@@ -3681,7 +3694,8 @@ static int ublk_ctrl_uring_cmd(struct io_uring_cmd *cmd,
36813694
u32 cmd_op = cmd->cmd_op;
36823695
int ret = -EINVAL;
36833696

3684-
if (issue_flags & IO_URING_F_NONBLOCK)
3697+
if (ublk_ctrl_uring_cmd_may_sleep(cmd_op) &&
3698+
issue_flags & IO_URING_F_NONBLOCK)
36853699
return -EAGAIN;
36863700

36873701
ublk_ctrl_cmd_dump(cmd);

0 commit comments

Comments
 (0)