Merge tag 'folio-5.19' of git://git.infradead.org/users/willy/pagecache
[linux-2.6-microblaze.git] / mm / readahead.c
index 26bf74a..b78921b 100644 (file)
@@ -15,7 +15,7 @@
  * explicitly requested by the application.  Readahead only ever
  * attempts to read folios that are not yet in the page cache.  If a
  * folio is present but not up-to-date, readahead will not try to read
- * it. In that case a simple ->readpage() will be requested.
+ * it. In that case a simple ->read_folio() will be requested.
  *
  * Readahead is triggered when an application read request (whether a
  * system call or a page fault) finds that the requested folio is not in
@@ -78,7 +78,7 @@
  * address space operation, for which mpage_readahead() is a canonical
  * implementation.  ->readahead() should normally initiate reads on all
  * folios, but may fail to read any or all folios without causing an I/O
- * error.  The page cache reading code will issue a ->readpage() request
+ * error.  The page cache reading code will issue a ->read_folio() request
  * for any folio which ->readahead() did not read, and only an error
  * from this will be final.
  *
  * were not fetched with readahead_folio().  This will allow a
  * subsequent synchronous readahead request to try them again.  If they
  * are left in the page cache, then they will be read individually using
- * ->readpage() which may be less efficient.
+ * ->read_folio() which may be less efficient.
  */
 
 #include <linux/blkdev.h>
@@ -146,7 +146,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))
@@ -157,24 +157,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)) != NULL)
+                       aops->read_folio(rac->file, folio);
        }
 
        blk_finish_plug(&plug);
@@ -255,8 +254,8 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
        }
 
        /*
-        * Now start the IO.  We ignore I/O errors - if the page is not
-        * uptodate then the caller will launch readpage again, and
+        * Now start the IO.  We ignore I/O errors - if the folio is not
+        * uptodate then the caller will launch read_folio again, and
         * will then handle the error.
         */
        read_pages(ractl);
@@ -304,7 +303,7 @@ void force_page_cache_ra(struct readahead_control *ractl,
        struct backing_dev_info *bdi = inode_to_bdi(mapping->host);
        unsigned long max_pages, index;
 
-       if (unlikely(!mapping->a_ops->readpage && !mapping->a_ops->readahead))
+       if (unlikely(!mapping->a_ops->read_folio && !mapping->a_ops->readahead))
                return;
 
        /*