[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250914121109.36403-2-wangyufei@vivo.com>
Date: Sun, 14 Sep 2025 20:11:08 +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 1/2] writeback: add support for filesystems to affine inodes to specific writeback ctx
Introduce a new superblock operation get_inode_wb_ctx_idx() to allow
filesystems to decide how inodes are assigned to writeback contexts.
This helps optimize parallel writeback performance based on the
underlying filesystem architecture.
In fetch_bdi_writeback_ctx(), if this operation is implemented by the
filesystem, it will return a specific writeback context index for a
given inode. Otherwise fall back to the default way.
Signed-off-by: wangyufei <wangyufei@...o.com>
---
include/linux/backing-dev.h | 3 +++
include/linux/fs.h | 1 +
2 files changed, 4 insertions(+)
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index c93509f5e..d02536f6e 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -144,7 +144,10 @@ static inline struct bdi_writeback_ctx *
fetch_bdi_writeback_ctx(struct inode *inode)
{
struct backing_dev_info *bdi = inode_to_bdi(inode);
+ struct super_block *sb = inode->i_sb;
+ if (sb->s_op->get_inode_wb_ctx_idx)
+ return bdi->wb_ctx_arr[sb->s_op->get_inode_wb_ctx_idx(inode, bdi->nr_wb_ctx)];
return bdi->wb_ctx_arr[inode->i_ino % bdi->nr_wb_ctx];
}
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 6c07228bd..fad7a75fd 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2491,6 +2491,7 @@ struct super_operations {
*/
int (*remove_bdev)(struct super_block *sb, struct block_device *bdev);
void (*shutdown)(struct super_block *sb);
+ unsigned int (*get_inode_wb_ctx_idx)(struct inode *inode, int nr_wb_ctx);
};
/*
--
2.34.1
Powered by blists - more mailing lists