Skip to content

Commit 25c028a

Browse files
calebsanderaxboe
authored andcommitted
ublk: pass q_id and tag to __ublk_check_and_get_req()
__ublk_check_and_get_req() only uses its ublk_queue argument to get the q_id and tag. Pass those arguments explicitly to save an access to the ublk_queue. Signed-off-by: Caleb Sander Mateos <[email protected]> Reviewed-by: Ming Lei <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent ce88e3e commit 25c028a

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

drivers/block/ublk_drv.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ static void ublk_io_release(void *priv);
250250
static void ublk_stop_dev_unlocked(struct ublk_device *ub);
251251
static void ublk_abort_queue(struct ublk_device *ub, struct ublk_queue *ubq);
252252
static inline struct request *__ublk_check_and_get_req(struct ublk_device *ub,
253-
const struct ublk_queue *ubq, struct ublk_io *io,
254-
size_t offset);
253+
u16 q_id, u16 tag, struct ublk_io *io, size_t offset);
255254
static inline unsigned int ublk_req_build_flags(struct request *req);
256255

257256
static inline struct ublksrv_io_desc *
@@ -2126,7 +2125,7 @@ static void ublk_io_release(void *priv)
21262125

21272126
static int ublk_register_io_buf(struct io_uring_cmd *cmd,
21282127
struct ublk_device *ub,
2129-
const struct ublk_queue *ubq,
2128+
u16 q_id, u16 tag,
21302129
struct ublk_io *io,
21312130
unsigned int index, unsigned int issue_flags)
21322131
{
@@ -2136,7 +2135,7 @@ static int ublk_register_io_buf(struct io_uring_cmd *cmd,
21362135
if (!ublk_dev_support_zero_copy(ub))
21372136
return -EINVAL;
21382137

2139-
req = __ublk_check_and_get_req(ub, ubq, io, 0);
2138+
req = __ublk_check_and_get_req(ub, q_id, tag, io, 0);
21402139
if (!req)
21412140
return -EINVAL;
21422141

@@ -2153,7 +2152,7 @@ static int ublk_register_io_buf(struct io_uring_cmd *cmd,
21532152
static int
21542153
ublk_daemon_register_io_buf(struct io_uring_cmd *cmd,
21552154
struct ublk_device *ub,
2156-
const struct ublk_queue *ubq, struct ublk_io *io,
2155+
u16 q_id, u16 tag, struct ublk_io *io,
21572156
unsigned index, unsigned issue_flags)
21582157
{
21592158
unsigned new_registered_buffers;
@@ -2166,7 +2165,7 @@ ublk_daemon_register_io_buf(struct io_uring_cmd *cmd,
21662165
*/
21672166
new_registered_buffers = io->task_registered_buffers + 1;
21682167
if (unlikely(new_registered_buffers >= UBLK_REFCOUNT_INIT))
2169-
return ublk_register_io_buf(cmd, ub, ubq, io, index,
2168+
return ublk_register_io_buf(cmd, ub, q_id, tag, io, index,
21702169
issue_flags);
21712170

21722171
if (!ublk_dev_support_zero_copy(ub) || !ublk_rq_has_data(req))
@@ -2358,8 +2357,8 @@ static int ublk_ch_uring_cmd_local(struct io_uring_cmd *cmd,
23582357
* so can be handled on any task
23592358
*/
23602359
if (_IOC_NR(cmd_op) == UBLK_IO_REGISTER_IO_BUF)
2361-
return ublk_register_io_buf(cmd, ub, ubq, io, addr,
2362-
issue_flags);
2360+
return ublk_register_io_buf(cmd, ub, q_id, tag, io,
2361+
addr, issue_flags);
23632362

23642363
goto out;
23652364
}
@@ -2380,7 +2379,7 @@ static int ublk_ch_uring_cmd_local(struct io_uring_cmd *cmd,
23802379

23812380
switch (_IOC_NR(cmd_op)) {
23822381
case UBLK_IO_REGISTER_IO_BUF:
2383-
return ublk_daemon_register_io_buf(cmd, ub, ubq, io, addr,
2382+
return ublk_daemon_register_io_buf(cmd, ub, q_id, tag, io, addr,
23842383
issue_flags);
23852384
case UBLK_IO_COMMIT_AND_FETCH_REQ:
23862385
ret = ublk_check_commit_and_fetch(ubq, io, addr);
@@ -2429,16 +2428,15 @@ static int ublk_ch_uring_cmd_local(struct io_uring_cmd *cmd,
24292428
}
24302429

24312430
static inline struct request *__ublk_check_and_get_req(struct ublk_device *ub,
2432-
const struct ublk_queue *ubq, struct ublk_io *io, size_t offset)
2431+
u16 q_id, u16 tag, struct ublk_io *io, size_t offset)
24332432
{
2434-
unsigned tag = io - ubq->ios;
24352433
struct request *req;
24362434

24372435
/*
24382436
* can't use io->req in case of concurrent UBLK_IO_COMMIT_AND_FETCH_REQ,
24392437
* which would overwrite it with io->cmd
24402438
*/
2441-
req = blk_mq_tag_to_rq(ub->tag_set.tags[ubq->q_id], tag);
2439+
req = blk_mq_tag_to_rq(ub->tag_set.tags[q_id], tag);
24422440
if (!req)
24432441
return NULL;
24442442

@@ -2536,7 +2534,7 @@ static struct request *ublk_check_and_get_req(struct kiocb *iocb,
25362534
return ERR_PTR(-EINVAL);
25372535

25382536
*io = &ubq->ios[tag];
2539-
req = __ublk_check_and_get_req(ub, ubq, *io, buf_off);
2537+
req = __ublk_check_and_get_req(ub, q_id, tag, *io, buf_off);
25402538
if (!req)
25412539
return ERR_PTR(-EINVAL);
25422540

0 commit comments

Comments
 (0)