Skip to content

Commit b7e255b

Browse files
calebsanderaxboe
authored andcommitted
ublk: don't pass q_id to ublk_queue_cmd_buf_size()
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>
1 parent 163f80d commit b7e255b

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

drivers/block/ublk_drv.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -762,11 +762,9 @@ static inline int __ublk_queue_cmd_buf_size(int depth)
762762
return round_up(depth * sizeof(struct ublksrv_io_desc), PAGE_SIZE);
763763
}
764764

765-
static inline int ublk_queue_cmd_buf_size(struct ublk_device *ub, int q_id)
765+
static inline int ublk_queue_cmd_buf_size(struct ublk_device *ub)
766766
{
767-
struct ublk_queue *ubq = ublk_get_queue(ub, q_id);
768-
769-
return __ublk_queue_cmd_buf_size(ubq->q_depth);
767+
return __ublk_queue_cmd_buf_size(ub->dev_info.queue_depth);
770768
}
771769

772770
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)
17031701
__func__, q_id, current->pid, vma->vm_start,
17041702
phys_off, (unsigned long)sz);
17051703

1706-
if (sz != ublk_queue_cmd_buf_size(ub, q_id))
1704+
if (sz != ublk_queue_cmd_buf_size(ub))
17071705
return -EINVAL;
17081706

17091707
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 = {
25652563

25662564
static void ublk_deinit_queue(struct ublk_device *ub, int q_id)
25672565
{
2568-
int size = ublk_queue_cmd_buf_size(ub, q_id);
2566+
int size = ublk_queue_cmd_buf_size(ub);
25692567
struct ublk_queue *ubq = ublk_get_queue(ub, q_id);
25702568
int i;
25712569

@@ -2592,7 +2590,7 @@ static int ublk_init_queue(struct ublk_device *ub, int q_id)
25922590
ubq->flags = ub->dev_info.flags;
25932591
ubq->q_id = q_id;
25942592
ubq->q_depth = ub->dev_info.queue_depth;
2595-
size = ublk_queue_cmd_buf_size(ub, q_id);
2593+
size = ublk_queue_cmd_buf_size(ub);
25962594

25972595
ptr = (void *) __get_free_pages(gfp_flags, get_order(size));
25982596
if (!ptr)

0 commit comments

Comments
 (0)