[PATCH 06/17] ublk: don't dereference ublk_queue in ublk_check_and_get_req()

From: Caleb Sander Mateos

Date: Wed Sep 17 2025 - 21:51:49 EST


For ublk servers with many ublk queues, accessing the ublk_queue in
ublk_ch_{read,write}_iter() is a frequent cache miss. Get the flags and
queue depth from the ublk_device instead, which is accessed just before.

Signed-off-by: Caleb Sander Mateos <csander@xxxxxxxxxxxxxxx>
---
drivers/block/ublk_drv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 58f688eac742..d6d8dcb72e4b 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -2525,14 +2525,14 @@ static struct request *ublk_check_and_get_req(struct kiocb *iocb,

if (q_id >= ub->dev_info.nr_hw_queues)
return ERR_PTR(-EINVAL);

ubq = ublk_get_queue(ub, q_id);
- if (!ublk_support_user_copy(ubq))
+ if (!ublk_dev_support_user_copy(ub))
return ERR_PTR(-EACCES);

- if (tag >= ubq->q_depth)
+ if (tag >= ub->dev_info.queue_depth)
return ERR_PTR(-EINVAL);

*io = &ubq->ios[tag];
req = __ublk_check_and_get_req(ub, ubq, *io, buf_off);
if (!req)
--
2.45.2