Patch "filemap: add a per-mapping stable writes flag" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    filemap: add a per-mapping stable writes flag

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     filemap-add-a-per-mapping-stable-writes-flag.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 28a5490b3586d1c511530d0848ade4165e206e96
Author: Christoph Hellwig <hch@xxxxxx>
Date:   Wed Oct 25 16:10:17 2023 +0200

    filemap: add a per-mapping stable writes flag
    
    [ Upstream commit 762321dab9a72760bf9aec48362f932717c9424d ]
    
    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>
    Link: https://lore.kernel.org/r/20231025141020.192413-2-hch@xxxxxx
    Tested-by: Ilya Dryomov <idryomov@xxxxxxxxx>
    Reviewed-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
    Reviewed-by: Darrick J. Wong <djwong@xxxxxxxxxx>
    Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>
    Stable-dep-of: 1898efcdbed3 ("block: update the stable_writes flag in bdev_add")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/inode.c b/fs/inode.c
index 73ad1b0d47758..8cfda7a6d5900 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -215,6 +215,8 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
 	lockdep_set_class_and_name(&mapping->invalidate_lock,
 				   &sb->s_type->invalidate_lock_key,
 				   "mapping.invalidate_lock");
+	if (sb->s_iflags & SB_I_STABLE_WRITES)
+		mapping_set_stable_writes(mapping);
 	inode->i_private = NULL;
 	inode->i_mapping = mapping;
 	INIT_HLIST_HEAD(&inode->i_dentry);	/* buggered by rcu freeing */
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index fdbb90ae56c70..1be5a1fa6a3a8 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -200,6 +200,8 @@ enum mapping_flags {
 	AS_NO_WRITEBACK_TAGS = 5,
 	AS_LARGE_FOLIO_SUPPORT = 6,
 	AS_RELEASE_ALWAYS,	/* Call ->release_folio(), even if no private data */
+	AS_STABLE_WRITES,	/* must wait for writeback before modifying
+				   folio contents */
 };
 
 /**
@@ -285,6 +287,21 @@ static inline void mapping_clear_release_always(struct address_space *mapping)
 	clear_bit(AS_RELEASE_ALWAYS, &mapping->flags);
 }
 
+static inline bool mapping_stable_writes(const struct address_space *mapping)
+{
+	return test_bit(AS_STABLE_WRITES, &mapping->flags);
+}
+
+static inline void mapping_set_stable_writes(struct address_space *mapping)
+{
+	set_bit(AS_STABLE_WRITES, &mapping->flags);
+}
+
+static inline void mapping_clear_stable_writes(struct address_space *mapping)
+{
+	clear_bit(AS_STABLE_WRITES, &mapping->flags);
+}
+
 static inline gfp_t mapping_gfp_mask(struct address_space * mapping)
 {
 	return mapping->gfp_mask;
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 7e9d8d857ecca..de5f69921b946 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -3078,7 +3078,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);
 }
 EXPORT_SYMBOL_GPL(folio_wait_stable);




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux