folio_wait_stable() now checks SB_I_STABLE_WRITES flag on the superblock instead of backing_dev_info, this could trigger a false block integrity error when doing buffered write directly to the block device, as folio_wait_stable() is a noop for bdev and the content could be modified during writeback. Check if the folio's superblock is bdev and wait for writeback if the backing device requires stables_writes. Fixes: 1cb039f3dc16 ("bdi: replace BDI_CAP_STABLE_WRITES with a queue and a sb flag") Signed-off-by: Li Dongyang <dongyangli@xxxxxxx> --- This patch supersedes the previous block: add SB_I_STABLE_WRITES to bdev sb flag --- --- mm/page-writeback.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index b8d3d7040a50..a236f93347a1 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -3110,7 +3110,11 @@ EXPORT_SYMBOL_GPL(folio_wait_writeback_killable); */ void folio_wait_stable(struct folio *folio) { - if (folio_inode(folio)->i_sb->s_iflags & SB_I_STABLE_WRITES) + struct inode *inode = folio_inode(folio); + + if (inode->i_sb->s_iflags & SB_I_STABLE_WRITES || + (sb_is_blkdev_sb(inode->i_sb) && + bdev_stable_writes(I_BDEV(inode)))) folio_wait_writeback(folio); } EXPORT_SYMBOL_GPL(folio_wait_stable); -- 2.42.0