Skip to content

Commit 7b720c7

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: never reduce ra_pages in blk_apply_bdi_limits
When the user increased the read-ahead size through sysfs this value currently get lost if the device is reprobe, including on a resume from suspend. As there is no hardware limitation for the read-ahead size there is no real need to reset it or track a separate hardware limitation like for max_sectors. This restores the pre-atomic queue limit behavior in the sd driver as sd did not use blk_queue_io_opt and thus never updated the read ahead size to the value based of the optimal I/O, but changes behavior for all other drivers. As the new behavior seems useful and sd is the driver for which the readahead size tweaks are most useful that seems like a worthwhile trade off. Fixes: 804e498 ("sd: convert to the atomic queue limits API") Reported-by: Holger Hoffstätte <holger@applied-asynchrony.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Tested-by: Holger Hoffstätte <holger@applied-asynchrony.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Link: https://lore.kernel.org/r/20250424082521.1967286-1-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 1d01973 commit 7b720c7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

block/blk-settings.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,14 @@ void blk_apply_bdi_limits(struct backing_dev_info *bdi,
6161
/*
6262
* For read-ahead of large files to be effective, we need to read ahead
6363
* at least twice the optimal I/O size.
64+
*
65+
* There is no hardware limitation for the read-ahead size and the user
66+
* might have increased the read-ahead size through sysfs, so don't ever
67+
* decrease it.
6468
*/
65-
bdi->ra_pages = max(lim->io_opt * 2 / PAGE_SIZE, VM_READAHEAD_PAGES);
69+
bdi->ra_pages = max3(bdi->ra_pages,
70+
lim->io_opt * 2 / PAGE_SIZE,
71+
VM_READAHEAD_PAGES);
6672
bdi->io_pages = lim->max_sectors >> PAGE_SECTORS_SHIFT;
6773
}
6874

0 commit comments

Comments
 (0)