Skip to content

Commit b994729

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: refactor disk_update_readahead
Factor out a blk_apply_bdi_limits limits helper that can be used with an explicit queue_limits argument, which will be useful later. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Link: https://lore.kernel.org/r/20240213073425.1621680-3-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 8c4955c commit b994729

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

block/blk-settings.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ void blk_set_stacking_limits(struct queue_limits *lim)
8585
}
8686
EXPORT_SYMBOL(blk_set_stacking_limits);
8787

88+
static void blk_apply_bdi_limits(struct backing_dev_info *bdi,
89+
struct queue_limits *lim)
90+
{
91+
/*
92+
* For read-ahead of large files to be effective, we need to read ahead
93+
* at least twice the optimal I/O size.
94+
*/
95+
bdi->ra_pages = max(lim->io_opt * 2 / PAGE_SIZE, VM_READAHEAD_PAGES);
96+
bdi->io_pages = lim->max_sectors >> PAGE_SECTORS_SHIFT;
97+
}
98+
8899
/**
89100
* blk_queue_bounce_limit - set bounce buffer limit for queue
90101
* @q: the request queue for the device
@@ -393,15 +404,7 @@ EXPORT_SYMBOL(blk_queue_alignment_offset);
393404

394405
void disk_update_readahead(struct gendisk *disk)
395406
{
396-
struct request_queue *q = disk->queue;
397-
398-
/*
399-
* For read-ahead of large files to be effective, we need to read ahead
400-
* at least twice the optimal I/O size.
401-
*/
402-
disk->bdi->ra_pages =
403-
max(queue_io_opt(q) * 2 / PAGE_SIZE, VM_READAHEAD_PAGES);
404-
disk->bdi->io_pages = queue_max_sectors(q) >> (PAGE_SHIFT - 9);
407+
blk_apply_bdi_limits(disk->bdi, &disk->queue->limits);
405408
}
406409
EXPORT_SYMBOL_GPL(disk_update_readahead);
407410

0 commit comments

Comments
 (0)