On Mon, Feb 03, 2025 at 06:46:49PM +1030, Qu Wenruo wrote: > It's pretty common to reproduce, just start a VM with an image on btrfs, set > the VM cache mode to none (aka, using direct IO), and run XFS/EXT4 inside > the VM, run some fsstress it should cause btrfs to hit data csum mismatch > false alerts. > > The root cause is the content change during direct IO, and XFS/EXT4 doesn't > wait for folio writeback before dirtying the folio (if no AS_STABLE_WRITES > set). > That's a valid optimization, but that will cause contents change. XFS honours the bdev flag: static inline void xfs_update_stable_writes(struct xfs_inode *ip) { if (bdev_stable_writes(xfs_inode_buftarg(ip)->bt_bdev)) mapping_set_stable_writes(VFS_I(ip)->i_mapping); else mapping_clear_stable_writes(VFS_I(ip)->i_mapping); } so this is a block layer issue if it's not set. > (I know there is the AS_STABLE_WRITES, but I'm not sure if qemu will pass > that flag to virtio block devices inside the VM)