]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Squashfs: Update page_actor to not use page->index
authorPhillip Lougher <phillip@squashfs.org.uk>
Sun, 18 Aug 2024 23:58:44 +0000 (00:58 +0100)
committerChristian Brauner <brauner@kernel.org>
Mon, 19 Aug 2024 12:08:20 +0000 (14:08 +0200)
This commit removes an unnecessary use of page->index,
and moves the other use over to folio->index.

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

index a8c1e7f9a6092355d8493b415f328254489a955e..2b6b63f4ccd1a19189a45fdb4844b05b7aa58fbc 100644 (file)
@@ -589,7 +589,7 @@ static void squashfs_readahead(struct readahead_control *ractl)
                        goto skip_pages;
 
                actor = squashfs_page_actor_init_special(msblk, pages, nr_pages,
-                                                        expected);
+                                                       expected, start);
                if (!actor)
                        goto skip_pages;
 
index 2a689ce71de98a7d3d021ac2ccb828548189914c..0586e6ba94bf7f9633f57a034170f2b5f81b404c 100644 (file)
@@ -67,7 +67,8 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize,
         * Create a "page actor" which will kmap and kunmap the
         * page cache pages appropriately within the decompressor
         */
-       actor = squashfs_page_actor_init_special(msblk, page, pages, expected);
+       actor = squashfs_page_actor_init_special(msblk, page, pages, expected,
+                                               start_index << PAGE_SHIFT);
        if (actor == NULL)
                goto out;
 
index 81af6c4ca115784c3f93a04fbbb439a2e3191844..2b3e807d4dea2186ccf8e5f3533dbb2979b134dd 100644 (file)
@@ -60,6 +60,11 @@ struct squashfs_page_actor *squashfs_page_actor_init(void **buffer,
 }
 
 /* Implementation of page_actor for decompressing directly into page cache. */
+static loff_t page_next_index(struct squashfs_page_actor *actor)
+{
+       return page_folio(actor->page[actor->next_page])->index;
+}
+
 static void *handle_next_page(struct squashfs_page_actor *actor)
 {
        int max_pages = (actor->length + PAGE_SIZE - 1) >> PAGE_SHIFT;
@@ -68,7 +73,7 @@ static void *handle_next_page(struct squashfs_page_actor *actor)
                return NULL;
 
        if ((actor->next_page == actor->pages) ||
-                       (actor->next_index != actor->page[actor->next_page]->index)) {
+                       (actor->next_index != page_next_index(actor))) {
                actor->next_index++;
                actor->returned_pages++;
                actor->last_page = NULL;
@@ -103,7 +108,7 @@ static void direct_finish_page(struct squashfs_page_actor *actor)
 }
 
 struct squashfs_page_actor *squashfs_page_actor_init_special(struct squashfs_sb_info *msblk,
-       struct page **page, int pages, int length)
+       struct page **page, int pages, int length, loff_t start_index)
 {
        struct squashfs_page_actor *actor = kmalloc(sizeof(*actor), GFP_KERNEL);
 
@@ -125,7 +130,7 @@ struct squashfs_page_actor *squashfs_page_actor_init_special(struct squashfs_sb_
        actor->pages = pages;
        actor->next_page = 0;
        actor->returned_pages = 0;
-       actor->next_index = page[0]->index & ~((1 << (msblk->block_log - PAGE_SHIFT)) - 1);
+       actor->next_index = start_index >> PAGE_SHIFT;
        actor->pageaddr = NULL;
        actor->last_page = NULL;
        actor->alloc_buffer = msblk->decompressor->alloc_buffer;
index 97d4983559b195e893c7a71836ff52fd9772b3fd..c6d837f0e9ca9cac6ac3c171fa629f7cd7c33a2c 100644 (file)
@@ -29,7 +29,8 @@ extern struct squashfs_page_actor *squashfs_page_actor_init(void **buffer,
                                int pages, int length);
 extern struct squashfs_page_actor *squashfs_page_actor_init_special(
                                struct squashfs_sb_info *msblk,
-                               struct page **page, int pages, int length);
+                               struct page **page, int pages, int length,
+                               loff_t start_index);
 static inline struct page *squashfs_page_actor_free(struct squashfs_page_actor *actor)
 {
        struct page *last_page = actor->last_page;