Skip to contentSkip to conversation

mm: folio_wait_stable() should check for bdev

PATCH In review Li Dongyang 2 participants 2 messages Nov 3, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: folio_wait_stable() should check for bdev

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")

---
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(-)
mm/page-writeback.c +5 -1
index b8d3d7040a50..a236f93347a1 100644
@@ -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);
Signature · 1 line
2.42.0
#1 lore raw
Quoted 9 lines · Li Dongyang

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.

https://lore.kernel.org/lkml/CAOi1vP9Zit-A9rRk9jy+d1itaBzUSBzFBuhXE+EDfBtF-Mf0og@mail.gmail.com/T/#t

https://lore.kernel.org/all/[email protected]/