Skip to content

Commit 70ff72e

Browse files
committed
readahead: don't shorten readahead window in read_pages()
commit 7a1eb89 Author: Jan Kara <jack@suse.cz> Date: Wed Dec 4 19:10:15 2024 +0100 readahead: don't shorten readahead window in read_pages() Patch series "readahead: Reintroduce fix for improper RA window sizing". This small patch series reintroduces a fix of readahead window confusion (and thus read throughput reduction) when page_cache_ra_order() ends up failing due to folios already present in the page cache. After thinking about this for a while I have ended up with a dumb fix that just rechecks if we have something to read before calling do_page_cache_ra(). This fixes the problem reported in [1]. I still think it doesn't make much sense to update readahead window size in read_pages() so patch 1 removes that but the real fix in patch 2 does not depend on it. [1] https://lore.kernel.org/all/49648605-d800-4859-be49-624bbe60519d@gmail.com This patch (of 2): When ->readahead callback doesn't read all requested pages, read_pages() shortens the readahead window (ra->size). However we don't know why pages were not read and what appropriate window size is. So don't try to secondguess the filesystem. If it needs different readahead window, it should set it manually similarly as during expansion the filesystem can use readahead_expand(). Link: https://lkml.kernel.org/r/20241204181016.15273-1-jack@suse.cz Link: https://lkml.kernel.org/r/20241204181016.15273-2-jack@suse.cz Signed-off-by: Jan Kara <jack@suse.cz> Cc: Matthew Wilcox <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> JIRA: https://issues.redhat.com/browse/RHEL-77742 Signed-off-by: Nico Pache <npache@redhat.com>
1 parent 6a6fa8e commit 70ff72e

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

mm/readahead.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,10 @@ static void read_pages(struct readahead_control *rac)
158158

159159
if (aops->readahead) {
160160
aops->readahead(rac);
161-
/*
162-
* Clean up the remaining folios. The sizes in ->ra
163-
* may be used to size the next readahead, so make sure
164-
* they accurately reflect what happened.
165-
*/
161+
/* Clean up the remaining folios. */
166162
while ((folio = readahead_folio(rac)) != NULL) {
167-
unsigned long nr = folio_nr_pages(folio);
168-
169163
folio_get(folio);
170-
rac->ra->size -= nr;
171-
if (rac->ra->async_size >= nr) {
172-
rac->ra->async_size -= nr;
173-
filemap_remove_folio(folio);
174-
}
164+
filemap_remove_folio(folio);
175165
folio_unlock(folio);
176166
folio_put(folio);
177167
}

0 commit comments

Comments
 (0)