Squashfs: Update squashfs_readpage_block() to not use page->index
authorPhillip Lougher <phillip@squashfs.org.uk>
Sun, 18 Aug 2024 23:58:46 +0000 (00:58 +0100)
committerChristian Brauner <brauner@kernel.org>
Mon, 19 Aug 2024 12:08:20 +0000 (14:08 +0200)
This commit replaces references to page->index to folio->index or
their equivalent.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
Link: https://lore.kernel.org/r/20240818235847.170468-4-phillip@squashfs.org.uk
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/squashfs/file_direct.c

index 0586e6ba94bf7f9633f57a034170f2b5f81b404c..646d4d421f99797781a2ab6178727df664c985c6 100644 (file)
@@ -23,15 +23,15 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize,
        int expected)
 
 {
+       struct folio *folio = page_folio(target_page);
        struct inode *inode = target_page->mapping->host;
        struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
-
        loff_t file_end = (i_size_read(inode) - 1) >> PAGE_SHIFT;
        int mask = (1 << (msblk->block_log - PAGE_SHIFT)) - 1;
-       loff_t start_index = target_page->index & ~mask;
+       loff_t start_index = folio->index & ~mask;
        loff_t end_index = start_index | mask;
        int i, n, pages, bytes, res = -ENOMEM;
-       struct page **page;
+       struct page **page, *last_page;
        struct squashfs_page_actor *actor;
        void *pageaddr;
 
@@ -46,7 +46,7 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize,
 
        /* Try to grab all the pages covered by the Squashfs block */
        for (i = 0, n = start_index; n <= end_index; n++) {
-               page[i] = (n == target_page->index) ? target_page :
+               page[i] = (n == folio->index) ? target_page :
                        grab_cache_page_nowait(target_page->mapping, n);
 
                if (page[i] == NULL)
@@ -75,7 +75,7 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize,
        /* Decompress directly into the page cache buffers */
        res = squashfs_read_data(inode->i_sb, block, bsize, NULL, actor);
 
-       squashfs_page_actor_free(actor);
+       last_page = squashfs_page_actor_free(actor);
 
        if (res < 0)
                goto mark_errored;
@@ -87,8 +87,8 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize,
 
        /* Last page (if present) may have trailing bytes not filled */
        bytes = res % PAGE_SIZE;
-       if (page[pages - 1]->index == end_index && bytes) {
-               pageaddr = kmap_local_page(page[pages - 1]);
+       if (end_index == file_end && last_page && bytes) {
+               pageaddr = kmap_local_page(last_page);
                memset(pageaddr + bytes, 0, PAGE_SIZE - bytes);
                kunmap_local(pageaddr);
        }