* [f2fs-dev] [PATCH v2] f2fs: remove mappedtodisk flag usage in mmap write path
@ 2026-10-11 4:02 Nanzhe Zhao via Linux-f2fs-devel
2026-10-11 7:12 ` Chao Yu via Linux-f2fs-devel
2026-10-11 7:47 ` Barry Song via Linux-f2fs-devel
0 siblings, 2 replies; 4+ messages in thread
From: Nanzhe Zhao via Linux-f2fs-devel @ 2026-10-11 4:02 UTC (permalink / raw)
To: linux-f2fs-devel, Chao Yu, Jaegeuk Kim; +Cc: Barry Song, Nanzhe Zhao, stable
PG_mappedtodisk was inherited from the nobh/buffer-head era. However,
f2fs has no buffer heads and the flag is no longer meaningful. The only
user of the flag is the "no holes" shortcut in f2fs_vm_page_mkwrite(),
which makes mmap write faults skip marking the folio dirty. Chao Yu
pointed out that this is not only a cleanup: it causes the following
race condition with filesystem freezing:
CPU0 (write fault) CPU1 (freeze_super)
---- ----
f2fs_vm_page_mkwrite()
sb_start_pagefault()
/* shortcut: no dirty */
sb_end_pagefault()
sb_wait_write(SB_FREEZE_PAGEFAULT)
/* no waiter, passes */
sync_filesystem()
/* folio not dirty, skipped */
finish_fault()
/* PTE writable */
fault_dirty_shared_page()
folio_mark_dirty()
/* dirty folio on a frozen fs */
It will also skip APP_MAPPED_IO iostat/REQ_TIME updates and post-EOF
folio zeroing.
Remove this shortcut in f2fs_vm_page_mkwrite() and stop setting it in
f2fs_read_single_page().
Reported-by: Chao Yu <chao@kernel.org>
Link: https://lore.kernel.org/linux-f2fs-devel/496b913c-eb81-4fa8-be72-c6a06a10aba2@kernel.org/
Fixes: fbfa2cc58d53 ("f2fs: add file operations")
Cc: stable@vger.kernel.org
Signed-off-by: Nanzhe Zhao <zhaonanzhe@xiaomi.com>
---
fs/f2fs/data.c | 1 -
fs/f2fs/file.c | 6 ------
2 files changed, 7 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 21f396ebe22c..35d9ddaf78f4 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2260,7 +2260,6 @@ static int f2fs_read_single_page(struct inode *inode, struct fsverity_info *vi,
got_it:
if ((map->m_flags & F2FS_MAP_MAPPED)) {
block_nr = map->m_pblk + block_in_file - map->m_lblk;
- folio_set_mappedtodisk(folio);
if (!f2fs_is_valid_blkaddr(F2FS_I_SB(inode), block_nr,
DATA_GENERIC_ENHANCE_READ)) {
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index edc352569e87..2d763e156d06 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -217,12 +217,6 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)
/* wait for GCed page writeback via META_MAPPING */
f2fs_wait_on_block_writeback(inode, dn.data_blkaddr);
- /*
- * check to see if the page is mapped already (no holes)
- */
- if (folio_test_mappedtodisk(folio))
- goto out_sem;
-
/* page is wholly or partially inside EOF */
if (((loff_t)(folio->index + 1) << PAGE_SHIFT) >
i_size_read(inode)) {
--
2.43.0
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [f2fs-dev] [PATCH v2] f2fs: remove mappedtodisk flag usage in mmap write path
2026-10-11 4:02 [f2fs-dev] [PATCH v2] f2fs: remove mappedtodisk flag usage in mmap write path Nanzhe Zhao via Linux-f2fs-devel
@ 2026-10-11 7:12 ` Chao Yu via Linux-f2fs-devel
2026-10-11 7:47 ` Barry Song via Linux-f2fs-devel
1 sibling, 0 replies; 4+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2026-10-11 7:12 UTC (permalink / raw)
To: Nanzhe Zhao, linux-f2fs-devel, Jaegeuk Kim; +Cc: Barry Song, stable
On 10/11/26 12:02, Nanzhe Zhao wrote:
> PG_mappedtodisk was inherited from the nobh/buffer-head era. However,
> f2fs has no buffer heads and the flag is no longer meaningful. The only
> user of the flag is the "no holes" shortcut in f2fs_vm_page_mkwrite(),
> which makes mmap write faults skip marking the folio dirty. Chao Yu
> pointed out that this is not only a cleanup: it causes the following
> race condition with filesystem freezing:
>
> CPU0 (write fault) CPU1 (freeze_super)
> ---- ----
> f2fs_vm_page_mkwrite()
> sb_start_pagefault()
> /* shortcut: no dirty */
> sb_end_pagefault()
>
> sb_wait_write(SB_FREEZE_PAGEFAULT)
> /* no waiter, passes */
> sync_filesystem()
> /* folio not dirty, skipped */
>
> finish_fault()
> /* PTE writable */
> fault_dirty_shared_page()
> folio_mark_dirty()
> /* dirty folio on a frozen fs */
>
> It will also skip APP_MAPPED_IO iostat/REQ_TIME updates and post-EOF
> folio zeroing.
>
> Remove this shortcut in f2fs_vm_page_mkwrite() and stop setting it in
> f2fs_read_single_page().
>
> Reported-by: Chao Yu <chao@kernel.org>
> Link: https://lore.kernel.org/linux-f2fs-devel/496b913c-eb81-4fa8-be72-c6a06a10aba2@kernel.org/
> Fixes: fbfa2cc58d53 ("f2fs: add file operations")
> Cc: stable@vger.kernel.org
> Signed-off-by: Nanzhe Zhao <zhaonanzhe@xiaomi.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [f2fs-dev] [PATCH v2] f2fs: remove mappedtodisk flag usage in mmap write path
2026-10-11 4:02 [f2fs-dev] [PATCH v2] f2fs: remove mappedtodisk flag usage in mmap write path Nanzhe Zhao via Linux-f2fs-devel
2026-10-11 7:12 ` Chao Yu via Linux-f2fs-devel
@ 2026-10-11 7:47 ` Barry Song via Linux-f2fs-devel
2026-10-12 3:27 ` Nanzhe Zhao via Linux-f2fs-devel
1 sibling, 1 reply; 4+ messages in thread
From: Barry Song via Linux-f2fs-devel @ 2026-10-11 7:47 UTC (permalink / raw)
To: Nanzhe Zhao; +Cc: Jaegeuk Kim, stable, linux-f2fs-devel
On Sun, Oct 11, 2026 at 12:02 PM Nanzhe Zhao <zhaonanzhe@xiaomi.com> wrote:
>
> PG_mappedtodisk was inherited from the nobh/buffer-head era. However,
> f2fs has no buffer heads and the flag is no longer meaningful. The only
> user of the flag is the "no holes" shortcut in f2fs_vm_page_mkwrite(),
> which makes mmap write faults skip marking the folio dirty. Chao Yu
> pointed out that this is not only a cleanup: it causes the following
> race condition with filesystem freezing:
Somehow, I feel that "Remove this shortcut in
`f2fs_vm_page_mkwrite()` and stop setting it in
`f2fs_read_single_page()`" should come before "Chao Yu
pointed out that this is not only a cleanup: it causes
the following".
We're saying that removing this shortcut is both a cleanup
and a fix for the race, right?
>
> CPU0 (write fault) CPU1 (freeze_super)
> ---- ----
> f2fs_vm_page_mkwrite()
> sb_start_pagefault()
> /* shortcut: no dirty */
> sb_end_pagefault()
>
> sb_wait_write(SB_FREEZE_PAGEFAULT)
> /* no waiter, passes */
> sync_filesystem()
> /* folio not dirty, skipped */
>
> finish_fault()
> /* PTE writable */
> fault_dirty_shared_page()
> folio_mark_dirty()
> /* dirty folio on a frozen fs */
>
> It will also skip APP_MAPPED_IO iostat/REQ_TIME updates and post-EOF
> folio zeroing.
>
> Remove this shortcut in f2fs_vm_page_mkwrite() and stop setting it in
> f2fs_read_single_page().
I mean, this sentence should be moved earlier, or the
preceding sentences should be reworded.
>
> Reported-by: Chao Yu <chao@kernel.org>
> Link: https://lore.kernel.org/linux-f2fs-devel/496b913c-eb81-4fa8-be72-c6a06a10aba2@kernel.org/
> Fixes: fbfa2cc58d53 ("f2fs: add file operations")
> Cc: stable@vger.kernel.org
> Signed-off-by: Nanzhe Zhao <zhaonanzhe@xiaomi.com>
> ---
Reviewed-by: Barry Song <baohua@kernel.org>
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [f2fs-dev] [PATCH v2] f2fs: remove mappedtodisk flag usage in mmap write path
2026-10-11 7:47 ` Barry Song via Linux-f2fs-devel
@ 2026-10-12 3:27 ` Nanzhe Zhao via Linux-f2fs-devel
0 siblings, 0 replies; 4+ messages in thread
From: Nanzhe Zhao via Linux-f2fs-devel @ 2026-10-12 3:27 UTC (permalink / raw)
To: Barry Song, linux-f2fs-devel; +Cc: Jaegeuk Kim
Hi Barry,
Thanks for the review. I have sent the patch v3 with the reworded commit message:
https://lore.kernel.org/linux-f2fs-devel/20261012030315.978375-1-zhaonanzhe@xiaomi.com/
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-12 3:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-11 4:02 [f2fs-dev] [PATCH v2] f2fs: remove mappedtodisk flag usage in mmap write path Nanzhe Zhao via Linux-f2fs-devel
2026-10-11 7:12 ` Chao Yu via Linux-f2fs-devel
2026-10-11 7:47 ` Barry Song via Linux-f2fs-devel
2026-10-12 3:27 ` Nanzhe Zhao via Linux-f2fs-devel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.