Skip to content

Commit a42634a

Browse files
author
Matthew Wilcox (Oracle)
committed
readahead: Use a folio in read_pages()
Handle multi-page folios correctly and removes a few calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent 2ca456c commit a42634a

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

mm/readahead.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ EXPORT_SYMBOL_GPL(file_ra_state_init);
145145
static void read_pages(struct readahead_control *rac)
146146
{
147147
const struct address_space_operations *aops = rac->mapping->a_ops;
148-
struct page *page;
148+
struct folio *folio;
149149
struct blk_plug plug;
150150

151151
if (!readahead_count(rac))
@@ -156,24 +156,23 @@ static void read_pages(struct readahead_control *rac)
156156
if (aops->readahead) {
157157
aops->readahead(rac);
158158
/*
159-
* Clean up the remaining pages. The sizes in ->ra
159+
* Clean up the remaining folios. The sizes in ->ra
160160
* may be used to size the next readahead, so make sure
161161
* they accurately reflect what happened.
162162
*/
163-
while ((page = readahead_page(rac))) {
164-
rac->ra->size -= 1;
165-
if (rac->ra->async_size > 0) {
166-
rac->ra->async_size -= 1;
167-
delete_from_page_cache(page);
163+
while ((folio = readahead_folio(rac)) != NULL) {
164+
unsigned long nr = folio_nr_pages(folio);
165+
166+
rac->ra->size -= nr;
167+
if (rac->ra->async_size >= nr) {
168+
rac->ra->async_size -= nr;
169+
filemap_remove_folio(folio);
168170
}
169-
unlock_page(page);
170-
put_page(page);
171+
folio_unlock(folio);
171172
}
172173
} else {
173-
while ((page = readahead_page(rac))) {
174-
aops->readpage(rac->file, page);
175-
put_page(page);
176-
}
174+
while ((folio = readahead_folio(rac)))
175+
aops->readpage(rac->file, &folio->page);
177176
}
178177

179178
blk_finish_plug(&plug);

0 commit comments

Comments
 (0)