]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ublk: don't pass q_id to ublk_queue_cmd_buf_size()
authorCaleb Sander Mateos <csander@purestorage.com>
Thu, 18 Sep 2025 01:49:38 +0000 (19:49 -0600)
committerJens Axboe <axboe@kernel.dk>
Sat, 20 Sep 2025 12:36:27 +0000 (06:36 -0600)
ublk_queue_cmd_buf_size() only needs the queue depth, which is the same
for all queues. Get the queue depth from the ublk_device instead so the
q_id parameter can be dropped.

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 9f2db91af48199bd81440b32d776aa1d1e84d179..bac16ec3151ced98cc82b87eea8080c9350b4e30 100644 (file)
@@ -762,11 +762,9 @@ static inline int __ublk_queue_cmd_buf_size(int depth)
        return round_up(depth * sizeof(struct ublksrv_io_desc), PAGE_SIZE);
 }
 
-static inline int ublk_queue_cmd_buf_size(struct ublk_device *ub, int q_id)
+static inline int ublk_queue_cmd_buf_size(struct ublk_device *ub)
 {
-       struct ublk_queue *ubq = ublk_get_queue(ub, q_id);
-
-       return __ublk_queue_cmd_buf_size(ubq->q_depth);
+       return __ublk_queue_cmd_buf_size(ub->dev_info.queue_depth);
 }
 
 static int ublk_max_cmd_buf_size(void)
@@ -1703,7 +1701,7 @@ static int ublk_ch_mmap(struct file *filp, struct vm_area_struct *vma)
                        __func__, q_id, current->pid, vma->vm_start,
                        phys_off, (unsigned long)sz);
 
-       if (sz != ublk_queue_cmd_buf_size(ub, q_id))
+       if (sz != ublk_queue_cmd_buf_size(ub))
                return -EINVAL;
 
        pfn = virt_to_phys(ublk_queue_cmd_buf(ub, q_id)) >> PAGE_SHIFT;
@@ -2565,7 +2563,7 @@ static const struct file_operations ublk_ch_fops = {
 
 static void ublk_deinit_queue(struct ublk_device *ub, int q_id)
 {
-       int size = ublk_queue_cmd_buf_size(ub, q_id);
+       int size = ublk_queue_cmd_buf_size(ub);
        struct ublk_queue *ubq = ublk_get_queue(ub, q_id);
        int i;
 
@@ -2592,7 +2590,7 @@ static int ublk_init_queue(struct ublk_device *ub, int q_id)
        ubq->flags = ub->dev_info.flags;
        ubq->q_id = q_id;
        ubq->q_depth = ub->dev_info.queue_depth;
-       size = ublk_queue_cmd_buf_size(ub, q_id);
+       size = ublk_queue_cmd_buf_size(ub);
 
        ptr = (void *) __get_free_pages(gfp_flags, get_order(size));
        if (!ptr)