squashfs: use a folio throughout squashfs_read_folio()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 20 Dec 2024 22:46:24 +0000 (22:46 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 25 Jan 2025 06:47:22 +0000 (22:47 -0800)
Use modern folio APIs where they exist and convert back to struct
page for the internal functions.

Link: https://lkml.kernel.org/r/20241220224634.723899-1-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Phillip Lougher <phillip@squashfs.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/squashfs/file.c

index 21aaa96856c10605c53a8c5631dd211b081d2742..bc6598c3a48fb1819253fef0c08b15194e1a8a1e 100644 (file)
@@ -445,21 +445,19 @@ static int squashfs_readpage_sparse(struct page *page, int expected)
 
 static int squashfs_read_folio(struct file *file, struct folio *folio)
 {
-       struct page *page = &folio->page;
-       struct inode *inode = page->mapping->host;
+       struct inode *inode = folio->mapping->host;
        struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
-       int index = page->index >> (msblk->block_log - PAGE_SHIFT);
+       int index = folio->index >> (msblk->block_log - PAGE_SHIFT);
        int file_end = i_size_read(inode) >> msblk->block_log;
        int expected = index == file_end ?
                        (i_size_read(inode) & (msblk->block_size - 1)) :
                         msblk->block_size;
        int res = 0;
-       void *pageaddr;
 
        TRACE("Entered squashfs_readpage, page index %lx, start block %llx\n",
-                               page->index, squashfs_i(inode)->start);
+                               folio->index, squashfs_i(inode)->start);
 
-       if (page->index >= ((i_size_read(inode) + PAGE_SIZE - 1) >>
+       if (folio->index >= ((i_size_read(inode) + PAGE_SIZE - 1) >>
                                        PAGE_SHIFT))
                goto out;
 
@@ -472,23 +470,18 @@ static int squashfs_read_folio(struct file *file, struct folio *folio)
                        goto out;
 
                if (res == 0)
-                       res = squashfs_readpage_sparse(page, expected);
+                       res = squashfs_readpage_sparse(&folio->page, expected);
                else
-                       res = squashfs_readpage_block(page, block, res, expected);
+                       res = squashfs_readpage_block(&folio->page, block, res, expected);
        } else
-               res = squashfs_readpage_fragment(page, expected);
+               res = squashfs_readpage_fragment(&folio->page, expected);
 
        if (!res)
                return 0;
 
 out:
-       pageaddr = kmap_atomic(page);
-       memset(pageaddr, 0, PAGE_SIZE);
-       kunmap_atomic(pageaddr);
-       flush_dcache_page(page);
-       if (res == 0)
-               SetPageUptodate(page);
-       unlock_page(page);
+       folio_zero_segment(folio, 0, folio_size(folio));
+       folio_end_read(folio, res == 0);
 
        return res;
 }