mm/filemap: Hoist filler_t decision to the top of do_read_cache_folio()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Sun, 8 May 2022 19:07:11 +0000 (15:07 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 9 May 2022 20:36:52 +0000 (16:36 -0400)
Now that filler_t and aops->read_folio() have the same type, we can decide
which one to use at the top of the function, and cache ->read_folio in
the filler parameter.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
mm/filemap.c

index 81a0ed0..9b7fa47 100644 (file)
@@ -3487,6 +3487,9 @@ static struct folio *do_read_cache_folio(struct address_space *mapping,
 {
        struct folio *folio;
        int err;
+
+       if (!filler)
+               filler = mapping->a_ops->read_folio;
 repeat:
        folio = filemap_get_folio(mapping, index);
        if (!folio) {
@@ -3503,11 +3506,7 @@ repeat:
                }
 
 filler:
-               if (filler)
-                       err = filler(file, folio);
-               else
-                       err = mapping->a_ops->read_folio(file, folio);
-
+               err = filler(file, folio);
                if (err < 0) {
                        folio_put(folio);
                        return ERR_PTR(err);