summaryrefslogtreecommitdiff
path: root/include/linux/tc_act/git@git.tavy.me:linux-stable.git
diff options
context:
space:
mode:
authorYongpeng Yang <yangyongpeng@xiaomi.com>2026-03-24 17:47:08 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2026-04-02 16:24:20 +0000
commit8979bc3d2a252940a277392b5eb6e52be7a3e1a5 (patch)
tree356046901db2e23652c5c262b72471b45c31a870 /include/linux/tc_act/git@git.tavy.me:linux-stable.git
parent02d91398a602c394d72cd61a67c84e2730c5f79b (diff)
f2fs: invalidate block device page cache on umount
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. Btrfs has encountered a similar issue before, the solution there was to call sync_blockdev() and invalidate_bdev() when the device is closed: mail-archive.com/linux-btrfs@vger.kernel.org/msg54188.html For the root user, the f2fs kernel calls sync_blockdev() on umount to flush all cached data to disk, and f2fs-tools can release the page cache by issuing ioctl(fd, BLKFLSBUF) when accessing the device. However, non-root users are not permitted to drop the page cache, and may still observe stale data. This patch calls sync_blockdev() and invalidate_bdev() during umount to invalidate the block device page cache, thereby preventing stale metadata from being read. Note that this may result in an extra sync_blockdev() call on the first device, in both f2fs_put_super() and kill_block_super(). The second call do nothing, as there are no dirty pages left to flush. It ensures that non-root users do not observe stale data. Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'include/linux/tc_act/git@git.tavy.me:linux-stable.git')
0 files changed, 0 insertions, 0 deletions