linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: folio_wait_stable() should check for bdev
@ 2023-11-03  5:09 Li Dongyang
  2023-11-03  8:11 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Li Dongyang @ 2023-11-03  5:09 UTC (permalink / raw)
  To: linux-block, linux-fsdevel; +Cc: hch, adilger.kernel

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@ddn.com>
---
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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm: folio_wait_stable() should check for bdev
  2023-11-03  5:09 [PATCH] mm: folio_wait_stable() should check for bdev Li Dongyang
@ 2023-11-03  8:11 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2023-11-03  8:11 UTC (permalink / raw)
  To: Li Dongyang; +Cc: linux-block, linux-fsdevel, hch, adilger.kernel

On Fri, Nov 03, 2023 at 04:09:49PM +1100, Li Dongyang wrote:
> 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/20231024064416.897956-1-hch@lst.de/


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-03  8:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-03  5:09 [PATCH] mm: folio_wait_stable() should check for bdev Li Dongyang
2023-11-03  8:11 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).