Skip to content

Commit 2258e22

Browse files
plougherbrauner
authored andcommitted
Squashfs: Update page_actor to not use page->index
This commit removes an unnecessary use of page->index, and moves the other use over to folio->index. Signed-off-by: Phillip Lougher <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 8400291 commit 2258e22

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

fs/squashfs/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ static void squashfs_readahead(struct readahead_control *ractl)
589589
goto skip_pages;
590590

591591
actor = squashfs_page_actor_init_special(msblk, pages, nr_pages,
592-
expected);
592+
expected, start);
593593
if (!actor)
594594
goto skip_pages;
595595

fs/squashfs/file_direct.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize,
6767
* Create a "page actor" which will kmap and kunmap the
6868
* page cache pages appropriately within the decompressor
6969
*/
70-
actor = squashfs_page_actor_init_special(msblk, page, pages, expected);
70+
actor = squashfs_page_actor_init_special(msblk, page, pages, expected,
71+
start_index << PAGE_SHIFT);
7172
if (actor == NULL)
7273
goto out;
7374

fs/squashfs/page_actor.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ struct squashfs_page_actor *squashfs_page_actor_init(void **buffer,
6060
}
6161

6262
/* Implementation of page_actor for decompressing directly into page cache. */
63+
static loff_t page_next_index(struct squashfs_page_actor *actor)
64+
{
65+
return page_folio(actor->page[actor->next_page])->index;
66+
}
67+
6368
static void *handle_next_page(struct squashfs_page_actor *actor)
6469
{
6570
int max_pages = (actor->length + PAGE_SIZE - 1) >> PAGE_SHIFT;
@@ -68,7 +73,7 @@ static void *handle_next_page(struct squashfs_page_actor *actor)
6873
return NULL;
6974

7075
if ((actor->next_page == actor->pages) ||
71-
(actor->next_index != actor->page[actor->next_page]->index)) {
76+
(actor->next_index != page_next_index(actor))) {
7277
actor->next_index++;
7378
actor->returned_pages++;
7479
actor->last_page = NULL;
@@ -103,7 +108,7 @@ static void direct_finish_page(struct squashfs_page_actor *actor)
103108
}
104109

105110
struct squashfs_page_actor *squashfs_page_actor_init_special(struct squashfs_sb_info *msblk,
106-
struct page **page, int pages, int length)
111+
struct page **page, int pages, int length, loff_t start_index)
107112
{
108113
struct squashfs_page_actor *actor = kmalloc(sizeof(*actor), GFP_KERNEL);
109114

@@ -125,7 +130,7 @@ struct squashfs_page_actor *squashfs_page_actor_init_special(struct squashfs_sb_
125130
actor->pages = pages;
126131
actor->next_page = 0;
127132
actor->returned_pages = 0;
128-
actor->next_index = page[0]->index & ~((1 << (msblk->block_log - PAGE_SHIFT)) - 1);
133+
actor->next_index = start_index >> PAGE_SHIFT;
129134
actor->pageaddr = NULL;
130135
actor->last_page = NULL;
131136
actor->alloc_buffer = msblk->decompressor->alloc_buffer;

fs/squashfs/page_actor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ extern struct squashfs_page_actor *squashfs_page_actor_init(void **buffer,
2929
int pages, int length);
3030
extern struct squashfs_page_actor *squashfs_page_actor_init_special(
3131
struct squashfs_sb_info *msblk,
32-
struct page **page, int pages, int length);
32+
struct page **page, int pages, int length,
33+
loff_t start_index);
3334
static inline struct page *squashfs_page_actor_free(struct squashfs_page_actor *actor)
3435
{
3536
struct page *last_page = actor->last_page;

0 commit comments

Comments
 (0)