mm: Fix assertion in folio_end_read()
Subsystems (4)
Matthew Wilcox (Oracle)
maintainerPATCH 1/2 mm: Fix assertion in folio_end_read()
We only need to assert that the uptodate flag is clear if we're going to set it. This hasn't been a problem before now because we have only used folio_end_read() when completing with an error, but it's convenient to use it in squashfs if we discover the folio is already uptodate.
--- mm/filemap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/filemap.c +1 -1
@@ -1505,7 +1505,7 @@ void folio_end_read(struct folio *folio, bool success)/* Must be in bottom byte for x86 to work */ BUILD_BUG_ON (PG_uptodate >7 );VM_BUG_ON_FOLIO (!folio_test_locked (folio), folio); -VM_BUG_ON_FOLIO (folio_test_uptodate (folio), folio); +VM_BUG_ON_FOLIO (success &&folio_test_uptodate (folio), folio);if (likely (success)) mask |=1 << PG_uptodate;
Signature · 1 line
2.45.2
Matthew Wilcox (Oracle)
maintainerPATCH 2/2 squashfs: Fix "convert squashfs_fill_page() to take a folio"
I got the polarity of "uptodate" wrong. Rename it. Thanks to Ryan for testing; please fold into above named patch, and he'd like you to add
--- fs/squashfs/file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/squashfs/file.c +3 -3
@@ -400,7 +400,7 @@ void squashfs_copy_cache(struct folio *folio, bytes -= PAGE_SIZE, offset += PAGE_SIZE) {struct folio *push_folio;size_t avail = buffer ?min (bytes,PAGE_SIZE ) :0 ; -bool uptodate = true; +bool updated = false;TRACE ("bytes %zu, i %d, available_bytes %zu\n" , bytes, i, avail);
@@ -415,9 +415,9 @@ void squashfs_copy_cache(struct folio *folio,if (folio_test_uptodate (push_folio)) goto skip_folio; - uptodate =squashfs_fill_page (push_folio, buffer, offset, avail); + updated =squashfs_fill_page (push_folio, buffer, offset, avail); skip_folio: -folio_end_read (push_folio, uptodate); +folio_end_read (push_folio, updated);if (i != folio->index)folio_put (push_folio); }
Signature · 1 line
2.45.2
Re: [PATCH 2/2] squashfs: Fix "convert squashfs_fill_page() to take a folio"
Quoted 5 lines · Matthew Wilcox (Oracle)
I got the polarity of "uptodate" wrong. Rename it. Thanks to Ryan for testing; please fold into above named patch, and he'd like you to add
Tested-by Ryan Roberts <[email protected]>
This is missing the change to folio_end_read() and the change for IS_ERR() that was in the version of the patch I tested. Just checking that those were handled separately in a thread I'm not CCed on?
Quoted 31 lines
Signed-off-by Matthew Wilcox (Oracle) <[email protected]>--- fs/squashfs/file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)fs/squashfs/file.c +3
-3@@ -400,7 +400,7 @@ void squashfs_copy_cache(struct folio *folio, bytes -= PAGE_SIZE, offset += PAGE_SIZE) {struct folio *push_folio;size_t avail = buffer ?min (bytes,PAGE_SIZE ) :0 ; -bool uptodate = true; +bool updated = false;TRACE ("bytes %zu, i %d, available_bytes %zu\n" , bytes, i, avail);@@ -415,9 +415,9 @@ void squashfs_copy_cache(struct folio *folio,if (folio_test_uptodate (push_folio)) goto skip_folio; - uptodate =squashfs_fill_page (push_folio, buffer, offset, avail); + updated =squashfs_fill_page (push_folio, buffer, offset, avail); skip_folio: -folio_end_read (push_folio, uptodate); +folio_end_read (push_folio, updated);if (i != folio->index)folio_put (push_folio); }
Matthew Wilcox
maintainerRe: [PATCH 2/2] squashfs: Fix "convert squashfs_fill_page() to take a folio"
Quoted 10 lines · Ryan Roberts
Quoted 5 lines · Matthew Wilcox (Oracle)
I got the polarity of "uptodate" wrong. Rename it. Thanks to Ryan for testing; please fold into above named patch, and he'd like you to add
Tested-by Ryan Roberts <[email protected]>This is missing the change to
folio_end_read()and the change forIS_ERR()that was in the version of the patch I tested. Just checking that those were handled separately in a thread I'm not CCed on?
https://lore.kernel.org/mm-commits/[email protected]/
https://lore.kernel.org/mm-commits/[email protected]/
Shouldn't be anything missing; I applied the first one to my tree, then wrote the second one and the third one you're replying to. Then I did a git diff HEAD~3 and sent the result to you to test.
Has anything gone wrong in this process?
Andrew Morton
maintainerRe: [PATCH 2/2] squashfs: Fix "convert squashfs_fill_page() to take a folio"
Quoted 6 lines · On Sat, 11 Jan 2025 17:58:32 +0000 Matthew Wilcox <[email protected]> wrote:
Quoted 5 lines · Ryan Roberts
Quoted 4 lines · Matthew Wilcox (Oracle)
I got the polarity of "uptodate" wrong. Rename it. Thanks to Ryan for testing; please fold into above named patch, and he'd like you to add
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Tested-by Ryan Roberts <[email protected]>This is missing the change to
folio_end_read()and the change forIS_ERR()that was in the version of the patch I tested. Just checking that those were handled separately in a thread I'm not CCed on?
I have this as a fix against a different patch: "squashfs: convert squashfs_copy_cache() to take a folio"
I queued this separately as a hotfix, without cc:stable. I guess it didn't really need that urgency, but wrong code is wrong.
Quoted 5 lines
Shouldn't be anything missing; I applied the first one to my tree, then wrote the second one and the third one you're replying to. Then I did a git diff HEAD~3 and sent the result to you to test.
Has anything gone wrong in this process?
I don't think so.
Re: [PATCH 2/2] squashfs: Fix "convert squashfs_fill_page() to take a folio"
Quoted 24 lines · Andrew Morton
Quoted 6 lines · On Sat, 11 Jan 2025 17:58:32 +0000 Matthew Wilcox <[email protected]> wrote:
Quoted 5 lines · Ryan Roberts
Quoted 4 lines · Matthew Wilcox (Oracle)
I got the polarity of "uptodate" wrong. Rename it. Thanks to Ryan for testing; please fold into above named patch, and he'd like you to add
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Tested-by Ryan Roberts <[email protected]>This is missing the change to
folio_end_read()and the change forIS_ERR()that was in the version of the patch I tested. Just checking that those were handled separately in a thread I'm not CCed on?I have this as a fix against a different patch: "squashfs: convert
squashfs_copy_cache()to take a folio"I queued this separately as a hotfix, without cc:stable. I guess it didn't really need that urgency, but wrong code is wrong.
Quoted 7 lines
Quoted 5 lines
Shouldn't be anything missing; I applied the first one to my tree, then wrote the second one and the third one you're replying to. Then I did a git diff HEAD~3 and sent the result to you to test.
Has anything gone wrong in this process?
I don't think so.
Agreed - thanks!
Re: [PATCH 2/2] squashfs: Fix "convert squashfs_fill_page() to take a folio"
In reply to Matthew Wilcox (Oracle)Quoted 7 lines · Matthew Wilcox (Oracle)
I got the polarity of "uptodate" wrong. Rename it. Thanks to Ryan for testing; please fold into above named patch, and he'd like you to add
Tested-by Ryan Roberts <[email protected]>Signed-off-by Matthew Wilcox (Oracle) <[email protected]>
Quoted 29 lines
--- fs/squashfs/file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)fs/squashfs/file.c +3
-3@@ -400,7 +400,7 @@ void squashfs_copy_cache(struct folio *folio, bytes -= PAGE_SIZE, offset += PAGE_SIZE) {struct folio *push_folio;size_t avail = buffer ?min (bytes,PAGE_SIZE ) :0 ; -bool uptodate = true; +bool updated = false;TRACE ("bytes %zu, i %d, available_bytes %zu\n" , bytes, i, avail);@@ -415,9 +415,9 @@ void squashfs_copy_cache(struct folio *folio,if (folio_test_uptodate (push_folio)) goto skip_folio; - uptodate =squashfs_fill_page (push_folio, buffer, offset, avail); + updated =squashfs_fill_page (push_folio, buffer, offset, avail); skip_folio: -folio_end_read (push_folio, uptodate); +folio_end_read (push_folio, updated);if (i != folio->index)folio_put (push_folio); }
Quoted 6 lines · Matthew Wilcox (Oracle)
We only need to assert that the uptodate flag is clear if we're going to set it. This hasn't been a problem before now because we have only used
folio_end_read()when completing with an error, but it's convenient to use it in squashfs if we discover the folio is already uptodate.Signed-off-by Matthew Wilcox (Oracle) <[email protected]>
Quoted 17 lines
--- mm/filemap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/filemap.c +1
-1@@ -1505,7 +1505,7 @@ void folio_end_read(struct folio *folio, bool success)/* Must be in bottom byte for x86 to work */ BUILD_BUG_ON (PG_uptodate >7 );VM_BUG_ON_FOLIO (!folio_test_locked (folio), folio); -VM_BUG_ON_FOLIO (folio_test_uptodate (folio), folio); +VM_BUG_ON_FOLIO (success &&folio_test_uptodate (folio), folio);if (likely (success)) mask |=1 << PG_uptodate;