All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: invalidate block device page cache on umount
@ 2026-02-16 11:27 Yongpeng Yang
  2026-03-11  9:31 ` Yongpeng Yang
  2026-03-12  0:49 ` Chao Yu via Linux-f2fs-devel
  0 siblings, 2 replies; 11+ messages in thread
From: Yongpeng Yang @ 2026-02-16 11:27 UTC (permalink / raw)
  To: Chao Yu, Jaegeuk Kim; +Cc: Yongpeng Yang, Yongpeng Yang, linux-f2fs-devel

From: Yongpeng Yang <yangyongpeng@xiaomi.com>

Neither F2FS nor VFS invalidates the block device page cache, which
results in reading stale metadata. An example scenario is shown below:

Terminal A                  Terminal B
mount /dev/vdb /mnt/f2fs
touch mx // ino = 4
sync
dump.f2fs -i 4 /dev/vdb// block on "[Y/N]"
                            touch mx2 // ino = 5
                            sync
                            umount /mnt/f2fs
                            dump.f2fs -i 5 /dev/vdb // block addr is 0

After umount, the block device page cache is not purged, causing
`dump.f2fs -i 5 /dev/vdb` to read stale metadata and see inode 5 with
block address 0.

This patch calls invalidate_bdev during umount to invalidate the block
device page cache, preventing stale metadata from being read.

Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com>
---
 fs/f2fs/super.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 1a755997aff5..39d3b52ceac1 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2091,6 +2091,12 @@ static void f2fs_put_super(struct super_block *sb)
 #if IS_ENABLED(CONFIG_UNICODE)
 	utf8_unload(sb->s_encoding);
 #endif
+	sync_blockdev(sb->s_bdev);
+	invalidate_bdev(sb->s_bdev);
+	for (i = 1; i < sbi->s_ndevs; i++) {
+		sync_blockdev(FDEV(i).bdev);
+		invalidate_bdev(FDEV(i).bdev);
+	}
 }
 
 int f2fs_sync_fs(struct super_block *sb, int sync)
-- 
2.52.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] 11+ messages in thread

end of thread, other threads:[~2026-03-24  9:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-16 11:27 [f2fs-dev] [PATCH] f2fs: invalidate block device page cache on umount Yongpeng Yang
2026-03-11  9:31 ` Yongpeng Yang
2026-03-12  0:49 ` Chao Yu via Linux-f2fs-devel
2026-03-12  3:56   ` Yongpeng Yang
2026-03-12 10:41     ` Chao Yu via Linux-f2fs-devel
2026-03-12 10:49       ` Chao Yu via Linux-f2fs-devel
2026-03-12 11:34         ` Yongpeng Yang
2026-03-13  7:19           ` Chao Yu via Linux-f2fs-devel
2026-03-13  9:42             ` Yongpeng Yang
2026-03-24  8:34               ` Chao Yu via Linux-f2fs-devel
2026-03-24  9:36                 ` Yongpeng Yang

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.