Skip to content

Commit 6f09ffb

Browse files
plougherbrauner
authored andcommitted
Squashfs: Update squashfs_readahead() to not use page->index
This commit removes references to page->index in the pages returned from __readahead_batch(), and instead uses the 'start' variable. This does reveal a bug in the previous code in that 'start' was not updated every time around the loop. This is fixed in this commit. Signed-off-by: Phillip Lougher <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 2258e22 commit 6f09ffb

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

fs/squashfs/file.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,6 @@ static void squashfs_readahead(struct readahead_control *ractl)
551551
return;
552552

553553
for (;;) {
554-
pgoff_t index;
555554
int res, bsize;
556555
u64 block = 0;
557556
unsigned int expected;
@@ -570,21 +569,16 @@ static void squashfs_readahead(struct readahead_control *ractl)
570569
if (readahead_pos(ractl) >= i_size_read(inode))
571570
goto skip_pages;
572571

573-
index = pages[0]->index >> shift;
574-
575-
if ((pages[nr_pages - 1]->index >> shift) != index)
576-
goto skip_pages;
577-
578-
if (index == file_end && squashfs_i(inode)->fragment_block !=
579-
SQUASHFS_INVALID_BLK) {
572+
if (start >> msblk->block_log == file_end &&
573+
squashfs_i(inode)->fragment_block != SQUASHFS_INVALID_BLK) {
580574
res = squashfs_readahead_fragment(pages, nr_pages,
581575
expected);
582576
if (res)
583577
goto skip_pages;
584578
continue;
585579
}
586580

587-
bsize = read_blocklist(inode, index, &block);
581+
bsize = read_blocklist(inode, start >> msblk->block_log, &block);
588582
if (bsize == 0)
589583
goto skip_pages;
590584

@@ -602,7 +596,7 @@ static void squashfs_readahead(struct readahead_control *ractl)
602596

603597
/* Last page (if present) may have trailing bytes not filled */
604598
bytes = res % PAGE_SIZE;
605-
if (index == file_end && bytes && last_page)
599+
if (start >> msblk->block_log == file_end && bytes && last_page)
606600
memzero_page(last_page, bytes,
607601
PAGE_SIZE - bytes);
608602

@@ -616,6 +610,8 @@ static void squashfs_readahead(struct readahead_control *ractl)
616610
unlock_page(pages[i]);
617611
put_page(pages[i]);
618612
}
613+
614+
start += readahead_batch_length(ractl);
619615
}
620616

621617
kfree(pages);

0 commit comments

Comments
 (0)