block: never reduce ra_pages in blk_apply_bdi_limits
PATCH 1/1 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.
--- block/blk-settings.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
block/blk-settings.c +7 -1
@@ -61,8 +61,14 @@ void blk_apply_bdi_limits(struct backing_dev_info *bdi,/* * For read-ahead of large files to be effective, we need to read ahead * at least twice the optimal I/O size. +* +* There is no hardware limitation for the read-ahead size and the user +* might have increased the read-ahead size through sysfs, so don't ever +* decrease it. */ - bdi->ra_pages =max (lim->io_opt *2 /PAGE_SIZE ,VM_READAHEAD_PAGES ); + bdi->ra_pages =max3 (bdi->ra_pages, + lim->io_opt *2 /PAGE_SIZE , +VM_READAHEAD_PAGES ); bdi->io_pages = lim->max_sectors >>PAGE_SECTORS_SHIFT ; }
Signature · 1 line
2.47.2
Quoted 33 lines · Christoph Hellwig
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_optand 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 804e498e0496 ("sd: convert to the atomic queue limits API")Reported-by Holger Hoffstätte <[email protected]>Signed-off-by Christoph Hellwig <[email protected]>Tested-by Holger Hoffstätte <[email protected]>--- block/blk-settings.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)block/blk-settings.c +2
-0@@ -61,8 +61,14 @@ void blk_apply_bdi_limits(struct backing_dev_info *bdi,/* * For read-ahead of large files to be effective, we need to read ahead * at least twice the optimal I/O size. +* +* There is no hardware limitation for the read-ahead size and the user
block/blk-settings.c void blk_apply_bdi_limits(struct backing_dev_info *bdi, · line 74
Quoted 10 lines
block/blk-settings.c +5
-1+* might have increased the read-ahead size through sysfs, so don't ever +* decrease it. */ - bdi->ra_pages =max (lim->io_opt *2 /PAGE_SIZE ,VM_READAHEAD_PAGES ); + bdi->ra_pages =max3 (bdi->ra_pages, + lim->io_opt *2 /PAGE_SIZE , +VM_READAHEAD_PAGES ); bdi->io_pages = lim->max_sectors >>PAGE_SECTORS_SHIFT ; }
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Quoted 9 lines · Christoph Hellwig
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.[...]
Applied, thanks!
[1/1] block: never reduce ra_pages in blk_apply_bdi_limits
commit: 7b720c720253e2070459420b2628a7b9ee6733b3
Best regards,
Signature · 1 line
Jens Axboe