Linux XFS filesystem development
 help / color / mirror / Atom feed
From: wangyufei <wangyufei@vivo.com>
To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz,
	cem@kernel.org
Cc: kundan.kumar@samsung.com, anuj20.g@samsung.com, hch@lst.de,
	bernd@bsbernd.com, djwong@kernel.org, david@fromorbit.com,
	linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, opensource.kernel@vivo.com,
	wangyufei <wangyufei@vivo.com>
Subject: [RFC 1/2] writeback: add support for filesystems to affine inodes to specific writeback ctx
Date: Sun, 14 Sep 2025 20:11:08 +0800	[thread overview]
Message-ID: <20250914121109.36403-2-wangyufei@vivo.com> (raw)
In-Reply-To: <20250914121109.36403-1-wangyufei@vivo.com>

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@vivo.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


  reply	other threads:[~2025-09-14 12:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-14 12:11 [RFC 0/2] writeback: add support for filesystems to optimize parallel writeback wangyufei
2025-09-14 12:11 ` wangyufei [this message]
2025-09-14 12:11 ` [RFC 2/2] xfs: implement get_inode_wb_ctx_idx() for per-AG " wangyufei
2025-09-22 16:56   ` Christoph Hellwig
2025-09-23 18:46     ` 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=20250914121109.36403-2-wangyufei@vivo.com \
    --to=wangyufei@vivo.com \
    --cc=anuj20.g@samsung.com \
    --cc=bernd@bsbernd.com \
    --cc=brauner@kernel.org \
    --cc=cem@kernel.org \
    --cc=david@fromorbit.com \
    --cc=djwong@kernel.org \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=kundan.kumar@samsung.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=opensource.kernel@vivo.com \
    --cc=viro@zeniv.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox