All of lore.kernel.org
 help / color / mirror / Atom feed
From: Catherine Hoang <catherine.hoang@oracle.com>
To: linux-xfs@vger.kernel.org
Subject: [PATCH 6.6 CANDIDATE v1 19/21] filemap: add a per-mapping stable writes flag
Date: Tue, 30 Jan 2024 15:44:17 -0800	[thread overview]
Message-ID: <20240130234419.45896-20-catherine.hoang@oracle.com> (raw)
In-Reply-To: <20240130234419.45896-1-catherine.hoang@oracle.com>

From: Christoph Hellwig <hch@lst.de>

commit 762321dab9a72760bf9aec48362f932717c9424d upstream.

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@lst.de>
Link: https://lore.kernel.org/r/20231025141020.192413-2-hch@lst.de
Tested-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
---
 fs/inode.c              |  2 ++
 include/linux/pagemap.h | 17 +++++++++++++++++
 mm/page-writeback.c     |  2 +-
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/fs/inode.c b/fs/inode.c
index 84bc3c76e5cc..ae1a6410b53d 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 351c3b7f93a1..8c9608b217b0 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -204,6 +204,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 */
 };
 
 /**
@@ -289,6 +291,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 b8d3d7040a50..4656534b8f5c 100644
--- a/mm/page-writeback.c
+++ 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);
 }
 EXPORT_SYMBOL_GPL(folio_wait_stable);
-- 
2.39.3


  parent reply	other threads:[~2024-01-30 23:45 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-30 23:43 [PATCH 6.6 CANDIDATE v1 00/21] xfs backports for 6.6.y (from v6.7) Catherine Hoang
2024-01-30 23:43 ` [PATCH 6.6 CANDIDATE v1 01/21] xfs: bump max fsgeom struct version Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 02/21] xfs: hoist freeing of rt data fork extent mappings Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 03/21] xfs: prevent rt growfs when quota is enabled Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 04/21] xfs: rt stubs should return negative errnos when rt disabled Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 05/21] xfs: fix units conversion error in xfs_bmap_del_extent_delay Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 06/21] xfs: make sure maxlen is still congruent with prod when rounding down Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 07/21] xfs: introduce protection for drop nlink Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 08/21] xfs: handle nimaps=0 from xfs_bmapi_write in xfs_alloc_file_space Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 09/21] xfs: allow read IO and FICLONE to run concurrently Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 10/21] xfs: factor out xfs_defer_pending_abort Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 11/21] xfs: abort intent items when recovery intents fail Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 12/21] xfs: only remap the written blocks in xfs_reflink_end_cow_extent Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 13/21] xfs: up(ic_sema) if flushing data device fails Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 14/21] xfs: fix internal error from AGFL exhaustion Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 15/21] xfs: fix again select in kconfig XFS_ONLINE_SCRUB_STATS Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 16/21] xfs: inode recovery does not validate the recovered inode Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 17/21] xfs: clean up dqblk extraction Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 18/21] xfs: dquot recovery does not validate the recovered dquot Catherine Hoang
2024-01-30 23:44 ` Catherine Hoang [this message]
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 20/21] xfs: clean up FS_XFLAG_REALTIME handling in xfs_ioctl_setattr_xflags Catherine Hoang
2024-01-30 23:44 ` [PATCH 6.6 CANDIDATE v1 21/21] xfs: respect the stable writes flag on the RT device Catherine Hoang
2024-01-31  3:49 ` [PATCH 6.6 CANDIDATE v1 00/21] xfs backports for 6.6.y (from v6.7) Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240130234419.45896-20-catherine.hoang@oracle.com \
    --to=catherine.hoang@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.