From: Phillip Lougher <phillip@squashfs.org.uk>
To: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Cc: willy@infradead.org, lizetao1@huawei.com,
Phillip Lougher <phillip@squashfs.org.uk>
Subject: [PATCH 2/4] Squashfs: Update squashfs_readahead() to not use page->index
Date: Mon, 19 Aug 2024 00:58:45 +0100 [thread overview]
Message-ID: <20240818235847.170468-3-phillip@squashfs.org.uk> (raw)
In-Reply-To: <20240818235847.170468-1-phillip@squashfs.org.uk>
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 <phillip@squashfs.org.uk>
---
fs/squashfs/file.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
index 2b6b63f4ccd1..50fe5a078b83 100644
--- a/fs/squashfs/file.c
+++ b/fs/squashfs/file.c
@@ -551,7 +551,6 @@ static void squashfs_readahead(struct readahead_control *ractl)
return;
for (;;) {
- pgoff_t index;
int res, bsize;
u64 block = 0;
unsigned int expected;
@@ -570,13 +569,8 @@ static void squashfs_readahead(struct readahead_control *ractl)
if (readahead_pos(ractl) >= i_size_read(inode))
goto skip_pages;
- index = pages[0]->index >> shift;
-
- if ((pages[nr_pages - 1]->index >> shift) != index)
- goto skip_pages;
-
- if (index == file_end && squashfs_i(inode)->fragment_block !=
- SQUASHFS_INVALID_BLK) {
+ if (start >> msblk->block_log == file_end &&
+ squashfs_i(inode)->fragment_block != SQUASHFS_INVALID_BLK) {
res = squashfs_readahead_fragment(pages, nr_pages,
expected);
if (res)
@@ -584,7 +578,7 @@ static void squashfs_readahead(struct readahead_control *ractl)
continue;
}
- bsize = read_blocklist(inode, index, &block);
+ bsize = read_blocklist(inode, start >> msblk->block_log, &block);
if (bsize == 0)
goto skip_pages;
@@ -602,7 +596,7 @@ static void squashfs_readahead(struct readahead_control *ractl)
/* Last page (if present) may have trailing bytes not filled */
bytes = res % PAGE_SIZE;
- if (index == file_end && bytes && last_page)
+ if (start >> msblk->block_log == file_end && bytes && last_page)
memzero_page(last_page, bytes,
PAGE_SIZE - bytes);
@@ -616,6 +610,8 @@ static void squashfs_readahead(struct readahead_control *ractl)
unlock_page(pages[i]);
put_page(pages[i]);
}
+
+ start += readahead_batch_length(ractl);
}
kfree(pages);
--
2.39.2
next prev parent reply other threads:[~2024-08-19 0:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-18 23:58 [PATCH 0/4] Squashfs: Update code " Phillip Lougher
2024-08-18 23:58 ` [PATCH 1/4] Squashfs: Update page_actor " Phillip Lougher
2024-08-18 23:58 ` Phillip Lougher [this message]
2024-08-18 23:58 ` [PATCH 3/4] Squashfs: Update squashfs_readpage_block() " Phillip Lougher
2024-08-18 23:58 ` [PATCH 4/4] Squashfs: Rewrite and update squashfs_readahead_fragment() " Phillip Lougher
2024-08-19 12:09 ` [PATCH 0/4] Squashfs: Update code " Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240818235847.170468-3-phillip@squashfs.org.uk \
--to=phillip@squashfs.org.uk \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizetao1@huawei.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®