On Tue, Oct 24, 2023 at 08:44:14AM +0200, Christoph Hellwig wrote: > folio_wait_stable waits for writeback to finish before modifying the > contents of a folio again, e.g. to support check summing of the data > in the block integrity code. > > Currently this behavior is controlled by the SB_I_STABLE_WRITES flag > on the super_block, which means it is uniform for the entire file system. > This is wrong for the block device pseudofs which is shared by all > block devices, or file systems that can use multiple devices like XFS > witht the RT subvolume or btrfs (although btrfs currently reimplements > folio_wait_stable anyway). > > Add a per-address_space AS_STABLE_WRITES flag to control the behavior > in a more fine grained way. The existing SB_I_STABLE_WRITES is kept > to initialize AS_STABLE_WRITES to the existing default which covers > most cases. > > Signed-off-by: Christoph Hellwig <hch@xxxxxx> Reviewed-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> > +++ b/mm/page-writeback.c > @@ -3110,7 +3110,7 @@ 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) > + if (mapping_stable_writes(folio_mapping(folio))) > folio_wait_writeback(folio); What I really like about this is that we've gone from folio->mapping->host->i_sb->s_iflags to folio->mapping->flags which saves us two pointer dereferences. Sure, probably cached, but maybe not, and cache misses are expensive.