f2fs: do not support mmap write for large folio
Subsystems (3)
Jaegeuk Kim
maintainerPATCH 1/1 f2fs: do not support mmap write for large folio
Let's check mmmap writes onto the large folio.
--- fs/f2fs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/file.c +1 -1
@@ -82,7 +82,7 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)int err =0 ;vm_fault_t ret; -if (unlikely (IS_IMMUTABLE (inode))) +if (mapping_large_folio_support (inode->i_mapping))return VM_FAULT_SIGBUS ;if (is_inode_flag_set (inode,FI_COMPRESS_RELEASED )) {
Signature · 1 line
2.53.0.1213.gd9a14994de-goog
Quoted 2 lines · On Mon, Apr 6, 2026 at 8:56 AM Jaegeuk Kim via Linux-f2fs-devel…
Let's check mmmap writes onto the large folio.
typo? mmap?
Quoted 11 lines
Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/f2fs/file.c +0
-0
fs/f2fs/file.c static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf) · line 85
Quoted 4 lines
fs/f2fs/file.c +0
-1@@ -82,7 +82,7 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)int err =0 ;vm_fault_t ret; -if (unlikely (IS_IMMUTABLE (inode)))
Did you remove this intentionally?
Quoted 13 lines
fs/f2fs/file.c +1
-1+if (mapping_large_folio_support (inode->i_mapping))return VM_FAULT_SIGBUS ;if (is_inode_flag_set (inode,FI_COMPRESS_RELEASED )) { --2.53.0.1213.gd9a14994de-goog
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Jaegeuk Kim
maintainerQuoted 21 lines · Daeho Jeong
Quoted 2 lines · On Mon, Apr 6, 2026 at 8:56 AM Jaegeuk Kim via Linux-f2fs-devel…
Let's check mmmap writes onto the large folio.
typo? mmap?
Quoted 14 lines
Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/f2fs/file.c +0
-0@@ -82,7 +82,7 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)int err =0 ;vm_fault_t ret;
Quoted 3 lines
fs/f2fs/file.c static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf) · line 85
Quoted 1 line
fs/f2fs/file.c +0
-1-if (unlikely (IS_IMMUTABLE (inode)))Did you remove this intentionally?
Ah, let me remain it back to isolate the change.
Quoted 14 lines
Quoted 14 lines
fs/f2fs/file.c +1
-1+if (mapping_large_folio_support (inode->i_mapping))return VM_FAULT_SIGBUS ;if (is_inode_flag_set (inode,FI_COMPRESS_RELEASED )) { --2.53.0.1213.gd9a14994de-goog
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 1 line · Jaegeuk Kim
Let's check mmmap writes onto the large folio.
Why? And how is this not breaking applications?
Quoted 23 lines
Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/f2fs/file.c +1
-1@@ -82,7 +82,7 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)int err =0 ;vm_fault_t ret; -if (unlikely (IS_IMMUTABLE (inode))) +if (mapping_large_folio_support (inode->i_mapping))return VM_FAULT_SIGBUS ;if (is_inode_flag_set (inode,FI_COMPRESS_RELEASED )) {Signature · 1 line
2.53.0.1213.gd9a14994de-goog
---end quoted text---
Jaegeuk Kim
maintainerQuoted 4 lines · Christoph Hellwig
Quoted 1 line · Jaegeuk Kim
Let's check mmmap writes onto the large folio.
Why? And how is this not breaking applications?
Since we only support the large folio on the read case.
Quoted 25 lines
Quoted 24 lines
Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/f2fs/file.c +1
-1@@ -82,7 +82,7 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)int err =0 ;vm_fault_t ret; -if (unlikely (IS_IMMUTABLE (inode))) +if (mapping_large_folio_support (inode->i_mapping))return VM_FAULT_SIGBUS ;if (is_inode_flag_set (inode,FI_COMPRESS_RELEASED )) {Signature · 1 line
2.53.0.1213.gd9a14994de-goog---end quoted text---
Quoted 7 lines · Jaegeuk Kim
Quoted 4 lines · Christoph Hellwig
Quoted 1 line · Jaegeuk Kim
Let's check mmmap writes onto the large folio.
Why? And how is this not breaking applications?
Since we only support the large folio on the read case.
In general spelling such basic out in the commit log, and even comments is really helpful. I'm curious how this works, though - by the time you read a large folio you don't know if it will ever be written to.
Quoted 10 lines · Christoph Hellwig
Quoted 5 lines · Jaegeuk Kim
Quoted 2 lines · Christoph Hellwig
Why? And how is this not breaking applications?
Since we only support the large folio on the read case.
In general spelling such basic out in the commit log, and even comments is really helpful. I'm curious how this works, though - by the time you read a large folio you don't know if it will ever be written to.
Why are only large folios supported for read?
Where is that allocation logic and how can that path even be triggered?
Also, usually we check for large folios by testing the actual folio, not whether the mapping supports them?
Signature · 3 lines
Cheers, David
Jaegeuk Kim
maintainerQuoted 12 lines · David Hildenbrand (Arm)
Quoted 10 lines · Christoph Hellwig
Quoted 5 lines · Jaegeuk Kim
Quoted 2 lines · Christoph Hellwig
Why? And how is this not breaking applications?
Since we only support the large folio on the read case.
In general spelling such basic out in the commit log, and even comments is really helpful. I'm curious how this works, though - by the time you read a large folio you don't know if it will ever be written to.
Quoted 6 lines
Why are only large folios supported for read?
Where is that allocation logic and how can that path even be triggered?
Also, usually we check for large folios by testing the actual folio, not whether the mapping supports them?
Currently I think it's simple to check the mapping in our case.
Quoted 5 lines
Signature · 4 lines
-- Cheers, David
Quoted 9 lines · Jaegeuk Kim
Quoted 8 lines · David Hildenbrand (Arm)
Quoted 4 lines · Christoph Hellwig
In general spelling such basic out in the commit log, and even comments is really helpful. I'm curious how this works, though - by the time you read a large folio you don't know if it will ever be written to.
Why are only large folios supported for read?
Quoted 8 lines
Quoted 4 lines
Where is that allocation logic and how can that path even be triggered?
Also, usually we check for large folios by testing the actual folio, not whether the mapping supports them?
Currently I think it's simple to check the mapping in our case.
Thanks for the pointer.
So you are adding code for something that is impossible to be reached.
Reading the other discussions, I agree that this should be flagged clearer as an assertion, and not a fix.
I'll let maintainers decide whether that is a assertion we should add :)
Signature · 3 lines
Cheers, David
Let's check mmap writes onto the large folio, since we don't support writing large folios.
---
- log v2:
: add comments
fs/f2fs/file.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/f2fs/file.c +6 -1
@@ -82,7 +82,12 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)int err =0 ;vm_fault_t ret; -if (unlikely (IS_IMMUTABLE (inode))) +/* +* We only support large folio on the read case. +* Don't make any dirty pages. +*/ +if (unlikely (IS_IMMUTABLE (inode)) || +mapping_large_folio_support (inode->i_mapping))return VM_FAULT_SIGBUS ;if (is_inode_flag_set (inode,FI_COMPRESS_RELEASED )) {
Signature · 1 line
2.53.0.1213.gd9a14994de-goog
[adding back fsdevel and mm to the discussion]
Quoted 2 lines · Jaegeuk Kim
Let's check mmap writes onto the large folio, since we don't support writing large folios.
What does this fix? As state in the previous round of discussion f2fs only support large folios for immutable files, how do you get ->mkwrite called for them.
The only way I can think of that is when clearing the immutable flag, but simply rejecting writes with SIGBUS after that seems like it's breaking the expected API, and I don't see handling for normal writes after that either.
Jaegeuk Kim
maintainerQuoted 9 lines · Christoph Hellwig
[adding back fsdevel and mm to the discussion]
Quoted 2 lines · Jaegeuk Kim
Let's check mmap writes onto the large folio, since we don't support writing large folios.
What does this fix? As state in the previous round of discussion f2fs only support large folios for immutable files, how do you get ->mkwrite called for them.
I'm approaching this as a safeguard first, since in any buggy case, this will crash the filesystem.
Quoted 5 lines
The only way I can think of that is when clearing the immutable flag, but simply rejecting writes with SIGBUS after that seems like it's breaking the expected API, and I don't see handling for normal writes after that either.
Chao Yu
maintainerQuoted 19 lines · On 4/9/2026 2:13 AM, Jaegeuk Kim via Linux-f2fs-devel wrote:
Let's check mmap writes onto the large folio, since we don't support writing large folios.
Reviewed-by Daeho Jeong <[email protected]>Signed-off-by Jaegeuk Kim <[email protected]>---
- log v2:
: add commentsfs/f2fs/file.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)fs/f2fs/file.c +0
-0@@ -82,7 +82,12 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)int err =0 ;
fs/f2fs/file.c static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf) · line 91
Quoted 10 lines
fs/f2fs/file.c +6
-1vm_fault_t ret; -if (unlikely (IS_IMMUTABLE (inode))) +/* +* We only support large folio on the read case. +* Don't make any dirty pages. +*/ +if (unlikely (IS_IMMUTABLE (inode)) || +mapping_large_folio_support (inode->i_mapping))return VM_FAULT_SIGBUS ;
The code itself looks good, since it's an impossible case, should we use f2fs_bug_on(, mapping_large_folio_support()) to catch any bug case rather than just returning error here w/o log?
Thanks,
Quoted 2 lines
fs/f2fs/file.c +0
-0if (is_inode_flag_set (inode,FI_COMPRESS_RELEASED )) {
Jaegeuk Kim
maintainerQuoted 25 lines · Chao Yu
Quoted 24 lines · On 4/9/2026 2:13 AM, Jaegeuk Kim via Linux-f2fs-devel wrote:
Let's check mmap writes onto the large folio, since we don't support writing large folios.
Reviewed-by Daeho Jeong <[email protected]>Signed-off-by Jaegeuk Kim <[email protected]>---
- log v2:
: add commentsfs/f2fs/file.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)fs/f2fs/file.c +3
-1@@ -82,7 +82,12 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)int err =0 ;vm_fault_t ret; -if (unlikely (IS_IMMUTABLE (inode))) +/* +* We only support large folio on the read case. +* Don't make any dirty pages.
Quoted 8 lines
fs/f2fs/file.c static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf) · line 91
Quoted 4 lines
fs/f2fs/file.c +3
-0+*/ +if (unlikely (IS_IMMUTABLE (inode)) || +mapping_large_folio_support (inode->i_mapping))return VM_FAULT_SIGBUS ;The code itself looks good, since it's an impossible case, should we use
f2fs_bug_on(, mapping_large_folio_support())to catch any bug case rather than just returning error here w/o log?
Instead of kernel panicing for the production, I'd leave a kernel message first.
Quoted 4 lines
Thanks,
Quoted 1 line
fs/f2fs/file.c +0
-0if (is_inode_flag_set (inode,FI_COMPRESS_RELEASED )) {
Let's check mmap writes onto the large folio, since we don't support writing large folios.
---
- add f2fs_err to catch any issue
fs/f2fs/file.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
fs/f2fs/file.c +10 -1
@@ -82,8 +82,17 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)int err =0 ;vm_fault_t ret; -if (unlikely (IS_IMMUTABLE (inode))) +/* +* We only support large folio on the read case. +* Don't make any dirty pages. +*/ +if (unlikely (IS_IMMUTABLE (inode)) || +mapping_large_folio_support (inode->i_mapping)) { +f2fs_err (sbi,"Not expected: immutable: %d large_folio: %d" , +IS_IMMUTABLE (inode), +mapping_large_folio_support (inode->i_mapping));return VM_FAULT_SIGBUS ; + }if (is_inode_flag_set (inode,FI_COMPRESS_RELEASED )) { err = -EIO ;
Signature · 1 line
2.54.0.rc0.605.g598a273b03-goog
Quoted 5 lines · On 4/14/2026 6:46 AM, Jaegeuk Kim via Linux-f2fs-devel wrote:
Let's check mmap writes onto the large folio, since we don't support writing large folios.
Reviewed-by Daeho Jeong <[email protected]>Signed-off-by Jaegeuk Kim <[email protected]>
Thanks,