Linux-f2fs-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: Yongpeng Yang <monty_pavel@sina.com>, Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Yongpeng Yang <yangyongpeng@xiaomi.com>,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH v2] f2fs: invalidate block device page cache on umount
Date: Tue, 24 Mar 2026 19:05:05 +0800	[thread overview]
Message-ID: <7813a041-13e7-4e4b-9b5e-16f4e83252d4@kernel.org> (raw)
In-Reply-To: <20260324094707.3959420-2-monty_pavel@sina.com>

On 3/24/26 17:47, Yongpeng Yang wrote:
> 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.
> 
> 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>

Thanks,


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

  reply	other threads:[~2026-03-24 11:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-24  9:47 [f2fs-dev] [PATCH v2] f2fs: invalidate block device page cache on umount Yongpeng Yang
2026-03-24 11:05 ` Chao Yu via Linux-f2fs-devel [this message]
2026-04-02 16:30 ` patchwork-bot+f2fs--- via Linux-f2fs-devel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7813a041-13e7-4e4b-9b5e-16f4e83252d4@kernel.org \
    --to=linux-f2fs-devel@lists.sourceforge.net \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=monty_pavel@sina.com \
    --cc=yangyongpeng@xiaomi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox