diff options
author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2022-03-31 14:15:59 -0400 |
---|---|---|
committer | Matthew Wilcox (Oracle) <willy@infradead.org> | 2022-05-08 14:45:56 -0400 |
commit | a42634a6c07d5a66e8ad446ad0f184c0c78012ff (patch) | |
tree | bfe369d13c1ff0ad7e4360d8f120fc08a6f2a93e /mm/readahead.c | |
parent | 2ca456c24801e439256c0ec7dbe21eba7b01544e (diff) | |
download | linux-rpi-a42634a6c07d5a66e8ad446ad0f184c0c78012ff.tar.gz linux-rpi-a42634a6c07d5a66e8ad446ad0f184c0c78012ff.tar.bz2 linux-rpi-a42634a6c07d5a66e8ad446ad0f184c0c78012ff.zip |
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) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'mm/readahead.c')
-rw-r--r-- | mm/readahead.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/mm/readahead.c b/mm/readahead.c index 4a60cdb64262..60a28af25c4e 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -145,7 +145,7 @@ EXPORT_SYMBOL_GPL(file_ra_state_init); static void read_pages(struct readahead_control *rac) { const struct address_space_operations *aops = rac->mapping->a_ops; - struct page *page; + struct folio *folio; struct blk_plug plug; if (!readahead_count(rac)) @@ -156,24 +156,23 @@ static void read_pages(struct readahead_control *rac) if (aops->readahead) { aops->readahead(rac); /* - * Clean up the remaining pages. The sizes in ->ra + * Clean up the remaining folios. The sizes in ->ra * may be used to size the next readahead, so make sure * they accurately reflect what happened. */ - while ((page = readahead_page(rac))) { - rac->ra->size -= 1; - if (rac->ra->async_size > 0) { - rac->ra->async_size -= 1; - delete_from_page_cache(page); + while ((folio = readahead_folio(rac)) != NULL) { + unsigned long nr = folio_nr_pages(folio); + + rac->ra->size -= nr; + if (rac->ra->async_size >= nr) { + rac->ra->async_size -= nr; + filemap_remove_folio(folio); } - unlock_page(page); - put_page(page); + folio_unlock(folio); } } else { - while ((page = readahead_page(rac))) { - aops->readpage(rac->file, page); - put_page(page); - } + while ((folio = readahead_folio(rac))) + aops->readpage(rac->file, &folio->page); } blk_finish_plug(&plug); |