Skip to content

Commit 1a6e88b

Browse files
metaspaceaxboe
authored andcommitted
ublk: move check for empty address field on command submission
In preparation for zoned storage support, move the check for empty `addr` field into the command handler case statement. Note that the check makes no sense for `UBLK_IO_NEED_GET_DATA` because the `addr` field must always be set for this command. Signed-off-by: Andreas Hindborg <a.hindborg@samsung.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20230804114610.179530-3-nmi@metaspace.dk Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 9d4ed6d commit 1a6e88b

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

drivers/block/ublk_drv.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,11 +1419,6 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
14191419
^ (_IOC_NR(cmd_op) == UBLK_IO_NEED_GET_DATA))
14201420
goto out;
14211421

1422-
if (ublk_support_user_copy(ubq) && ub_cmd->addr) {
1423-
ret = -EINVAL;
1424-
goto out;
1425-
}
1426-
14271422
ret = ublk_check_cmd_op(cmd_op);
14281423
if (ret)
14291424
goto out;
@@ -1450,6 +1445,10 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
14501445
*/
14511446
if (!ub_cmd->addr && !ublk_need_get_data(ubq))
14521447
goto out;
1448+
} else if (ub_cmd->addr) {
1449+
/* User copy requires addr to be unset */
1450+
ret = -EINVAL;
1451+
goto out;
14531452
}
14541453

14551454
ublk_fill_io_cmd(io, cmd, ub_cmd->addr);
@@ -1469,7 +1468,12 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
14691468
if (!ub_cmd->addr && (!ublk_need_get_data(ubq) ||
14701469
req_op(req) == REQ_OP_READ))
14711470
goto out;
1471+
} else if (ub_cmd->addr) {
1472+
/* User copy requires addr to be unset */
1473+
ret = -EINVAL;
1474+
goto out;
14721475
}
1476+
14731477
ublk_fill_io_cmd(io, cmd, ub_cmd->addr);
14741478
ublk_commit_completion(ub, ub_cmd);
14751479
break;

0 commit comments

Comments
 (0)