squashfs: fixups for caching
cover squashfs: fixups for caching
These are a couple of fixups for squashfs-cache-partial-compressed-blocks.patch which is currently in mm-nonmm-unstable.
---
Vincent Whitchurch (2):
squashfs: fix page update race
squashfs: fix page indices
fs/squashfs/block.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
---
base-commit: 84cc8b966a3d4cde585761d05cc448dc1da0824f
change-id: 20230526-squashfs-cache-fixup-194431de42eb
Best regards,
Signature · 1 line
Vincent Whitchurch <[email protected]>
PATCH 1/2 squashfs: fix page update race
We only put the page into the cache after we've read it, so the PageUptodate() check should not be necessary. In fact, it's actively harmful since the check could fail (since we used find_get_page() and not find_lock_page()) and we could end up submitting a page for I/O after it has been read and while it's actively being used, which could lead to corruption depending on what the block driver does with it.
--- fs/squashfs/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/squashfs/block.c +1 -1
@@ -92,7 +92,7 @@ static int squashfs_bio_read_cached(struct bio *fullbio,bio_for_each_segment_all (bv, fullbio, iter_all) {struct page *page = bv->bv_page; -if (page->mapping == cache_mapping &&PageUptodate (page)) { +if (page->mapping == cache_mapping) { idx++;continue ; }
Signature · 1 line
2.34.1
Re: [PATCH mm-nonmm-unstable 1/2] squashfs: fix page update race
Looks good:
PATCH 2/2 squashfs: fix page indices
In reply to Vincent WhitchurchThe page cache functions want the page index as an argument but we're currently passing in the byte address.
--- fs/squashfs/block.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/squashfs/block.c +3 -3
@@ -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 );
Signature · 1 line
2.34.1
Re: [PATCH mm-nonmm-unstable 2/2] squashfs: fix page indices
Quoted 2 lines · Vincent Whitchurch
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.