]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
squashfs: Use folios in squashfs_bio_read_cached()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 17 Mar 2025 13:34:17 +0000 (09:34 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 17 Mar 2025 19:55:41 +0000 (15:55 -0400)
Remove an access to page->mapping and a few calls to the old page-based
APIs.  This doesn't support large folios, but it's still a nice
improvement.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
fs/squashfs/block.c

index 2dc730800f448d8cb44f2d5c4e625e607d1faf2f..6c079084714e484a85d86b5cf661fe30d4e09920 100644 (file)
@@ -80,19 +80,18 @@ static int squashfs_bio_read_cached(struct bio *fullbio,
                struct address_space *cache_mapping, u64 index, int length,
                u64 read_start, u64 read_end, int page_count)
 {
-       struct page *head_to_cache = NULL, *tail_to_cache = NULL;
+       struct folio *head_to_cache = NULL, *tail_to_cache = NULL;
        struct block_device *bdev = fullbio->bi_bdev;
        int start_idx = 0, end_idx = 0;
-       struct bvec_iter_all iter_all;
+       struct folio_iter fi;;
        struct bio *bio = NULL;
-       struct bio_vec *bv;
        int idx = 0;
        int err = 0;
 
-       bio_for_each_segment_all(bv, fullbio, iter_all) {
-               struct page *page = bv->bv_page;
+       bio_for_each_folio_all(fi, fullbio) {
+               struct folio *folio = fi.folio;
 
-               if (page->mapping == cache_mapping) {
+               if (folio->mapping == cache_mapping) {
                        idx++;
                        continue;
                }
@@ -107,9 +106,9 @@ static int squashfs_bio_read_cached(struct bio *fullbio,
                 * adjacent blocks.
                 */
                if (idx == 0 && index != read_start)
-                       head_to_cache = page;
+                       head_to_cache = folio;
                else if (idx == page_count - 1 && index + length != read_end)
-                       tail_to_cache = page;
+                       tail_to_cache = folio;
 
                if (!bio || idx != end_idx) {
                        struct bio *new = bio_alloc_clone(bdev, fullbio,
@@ -141,25 +140,25 @@ static int squashfs_bio_read_cached(struct bio *fullbio,
                return err;
 
        if (head_to_cache) {
-               int ret = add_to_page_cache_lru(head_to_cache, cache_mapping,
+               int ret = filemap_add_folio(cache_mapping, head_to_cache,
                                                read_start >> PAGE_SHIFT,
                                                GFP_NOIO);
 
                if (!ret) {
-                       SetPageUptodate(head_to_cache);
-                       unlock_page(head_to_cache);
+                       folio_mark_uptodate(head_to_cache);
+                       folio_unlock(head_to_cache);
                }
 
        }
 
        if (tail_to_cache) {
-               int ret = add_to_page_cache_lru(tail_to_cache, cache_mapping,
+               int ret = filemap_add_folio(cache_mapping, tail_to_cache,
                                                (read_end >> PAGE_SHIFT) - 1,
                                                GFP_NOIO);
 
                if (!ret) {
-                       SetPageUptodate(tail_to_cache);
-                       unlock_page(tail_to_cache);
+                       folio_mark_uptodate(tail_to_cache);
+                       folio_unlock(tail_to_cache);
                }
        }