]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ublk: don't access ublk_queue in ublk_check_commit_and_fetch()
authorCaleb Sander Mateos <csander@purestorage.com>
Thu, 18 Sep 2025 01:49:50 +0000 (19:49 -0600)
committerJens Axboe <axboe@kernel.dk>
Sat, 20 Sep 2025 12:36:27 +0000 (06:36 -0600)
For ublk servers with many ublk queues, accessing the ublk_queue in
ublk_check_commit_and_fetch() is a frequent cache miss. Get the flags
from the ublk_device instead, which is accessed earlier in
ublk_ch_uring_cmd_local().

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>
drivers/block/ublk_drv.c

index 9a726d048703fcc47ac138fd7d1f40ccc336320a..b92b7823005dedbcd6b6ad15a00e93384c136ee1 100644 (file)
@@ -2243,17 +2243,17 @@ out:
        return ret;
 }
 
-static int ublk_check_commit_and_fetch(const struct ublk_queue *ubq,
+static int ublk_check_commit_and_fetch(const struct ublk_device *ub,
                                       struct ublk_io *io, __u64 buf_addr)
 {
        struct request *req = io->req;
 
-       if (ublk_need_map_io(ubq)) {
+       if (ublk_dev_need_map_io(ub)) {
                /*
                 * COMMIT_AND_FETCH_REQ has to provide IO buffer if
                 * NEED GET DATA is not enabled or it is Read IO.
                 */
-               if (!buf_addr && (!ublk_need_get_data(ubq) ||
+               if (!buf_addr && (!ublk_dev_need_get_data(ub) ||
                                        req_op(req) == REQ_OP_READ))
                        return -EINVAL;
        } else if (req_op(req) != REQ_OP_ZONE_APPEND && buf_addr) {
@@ -2381,7 +2381,7 @@ static int ublk_ch_uring_cmd_local(struct io_uring_cmd *cmd,
                return ublk_daemon_register_io_buf(cmd, ub, q_id, tag, io, addr,
                                                   issue_flags);
        case UBLK_IO_COMMIT_AND_FETCH_REQ:
-               ret = ublk_check_commit_and_fetch(ubq, io, addr);
+               ret = ublk_check_commit_and_fetch(ub, io, addr);
                if (ret)
                        goto out;
                io->res = result;