[mm-nonmm-unstable,2/2] squashfs: fix page indices

Message ID 20230526-squashfs-cache-fixup-v1-2-d54a7fa23e7b@axis.com
State New
Headers
Series squashfs: fixups for caching |

Commit Message

Vincent Whitchurch May 26, 2023, 1:25 p.m. UTC
  The page cache functions want the page index as an argument but we're
currently passing in the byte address.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
 fs/squashfs/block.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Christoph Hellwig May 26, 2023, 1:37 p.m. UTC | #1
On Fri, May 26, 2023 at 03:25:46PM +0200, Vincent Whitchurch wrote:
> The page cache functions want the page index as an argument but we're
> currently passing in the byte address.

Can you avoid the overly long lines by movning the GFP_NOFS parameters
to the following lines?

The rest look good.
  

Patch

diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c
index f2412e5fc84b..447fb04f2b61 100644
--- a/fs/squashfs/block.c
+++ b/fs/squashfs/block.c
@@ -142,7 +142,7 @@  static int squashfs_bio_read_cached(struct bio *fullbio,
 
 	if (head_to_cache) {
 		int ret = add_to_page_cache_lru(head_to_cache, cache_mapping,
-						read_start, GFP_NOIO);
+						read_start >> PAGE_SHIFT, GFP_NOIO);
 
 		if (!ret) {
 			SetPageUptodate(head_to_cache);
@@ -153,7 +153,7 @@  static int squashfs_bio_read_cached(struct bio *fullbio,
 
 	if (tail_to_cache) {
 		int ret = add_to_page_cache_lru(tail_to_cache, cache_mapping,
-						read_end - PAGE_SIZE, GFP_NOIO);
+						(read_end >> PAGE_SHIFT) - 1, GFP_NOIO);
 
 		if (!ret) {
 			SetPageUptodate(tail_to_cache);
@@ -192,7 +192,7 @@  static int squashfs_bio_read(struct super_block *sb, u64 index, int length,
 
 		if (cache_mapping)
 			page = find_get_page(cache_mapping,
-					     read_start + i * PAGE_SIZE);
+					     (read_start >> PAGE_SHIFT) + i);
 		if (!page)
 			page = alloc_page(GFP_NOIO);