[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250914121109.36403-3-wangyufei@vivo.com>
Date: Sun, 14 Sep 2025 20:11:09 +0800
From: wangyufei <wangyufei@...o.com>
To: viro@...iv.linux.org.uk,
brauner@...nel.org,
jack@...e.cz,
cem@...nel.org
Cc: kundan.kumar@...sung.com,
anuj20.g@...sung.com,
hch@....de,
bernd@...ernd.com,
djwong@...nel.org,
david@...morbit.com,
linux-kernel@...r.kernel.org,
linux-xfs@...r.kernel.org,
linux-fsdevel@...r.kernel.org,
opensource.kernel@...o.com,
wangyufei <wangyufei@...o.com>
Subject: [RFC 2/2] xfs: implement get_inode_wb_ctx_idx() for per-AG parallel writeback
The number of writeback contexts is set to the number of CPUs by
default. This allows XFS to decide how to assign inodes to writeback
contexts based on its allocation groups.
Implement get_inode_wb_ctx_idx() in xfs_super_operations as follows:
- Limit the number of active writeback contexts to the number of AGs.
- Assign inodes from the same AG to a unique writeback context.
Signed-off-by: wangyufei <wangyufei@...o.com>
---
fs/xfs/xfs_super.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 77acb3e5a..156df0397 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1279,6 +1279,19 @@ xfs_fs_show_stats(
return 0;
}
+static unsigned int
+xfs_fs_get_inode_wb_ctx_idx(
+ struct inode *inode,
+ int nr_wb_ctx)
+{
+ struct xfs_inode *xfs_inode = XFS_I(inode);
+ struct xfs_mount *mp = XFS_M(inode->i_sb);
+
+ if (mp->m_sb.sb_agcount <= nr_wb_ctx)
+ return XFS_INO_TO_AGNO(mp, xfs_inode->i_ino);
+ return xfs_inode->i_ino % nr_wb_ctx;
+}
+
static const struct super_operations xfs_super_operations = {
.alloc_inode = xfs_fs_alloc_inode,
.destroy_inode = xfs_fs_destroy_inode,
@@ -1295,6 +1308,7 @@ static const struct super_operations xfs_super_operations = {
.free_cached_objects = xfs_fs_free_cached_objects,
.shutdown = xfs_fs_shutdown,
.show_stats = xfs_fs_show_stats,
+ .get_inode_wb_ctx_idx = xfs_fs_get_inode_wb_ctx_idx,
};
static int
--
2.34.1
Powered by blists - more mailing lists