From: Jan Kara <jack@suse.cz>
To: Kundan Kumar <kundan.kumar@samsung.com>
Cc: jaegeuk@kernel.org, chao@kernel.org, viro@zeniv.linux.org.uk,
brauner@kernel.org, jack@suse.cz, miklos@szeredi.hu,
agruenba@redhat.com, trondmy@kernel.org, anna@kernel.org,
akpm@linux-foundation.org, willy@infradead.org,
mcgrof@kernel.org, clm@meta.com, david@fromorbit.com,
amir73il@gmail.com, axboe@kernel.dk, hch@lst.de,
ritesh.list@gmail.com, djwong@kernel.org, dave@stgolabs.net,
wangyufei@vivo.com, linux-f2fs-devel@lists.sourceforge.net,
linux-fsdevel@vger.kernel.org, gfs2@lists.linux.dev,
linux-nfs@vger.kernel.org, linux-mm@kvack.org,
gost.dev@samsung.com, anuj20.g@samsung.com, vishak.g@samsung.com,
joshi.k@samsung.com
Subject: Re: [PATCH v2 04/16] writeback: affine inode to a writeback ctx within a bdi
Date: Tue, 21 Oct 2025 13:58:19 +0200 [thread overview]
Message-ID: <p7mc3a7upsebbipxrredqhtazwt3tvyn4qt5jtsn3wb43orew2@6jzeodvk4tli> (raw)
In-Reply-To: <20251014120845.2361-5-kundan.kumar@samsung.com>
On Tue 14-10-25 17:38:33, Kundan Kumar wrote:
> Affine inode to a writeback context. This helps in minimizing the
> filesytem fragmentation due to inode being processed by different
> threads.
>
> To support parallel writeback, wire up a new superblock operation
> get_inode_wb_ctx(). Filesystems can override this callback and select
> desired writeback context for a inode. FS can use the wb context based
> on its geometry and also use 64 bit inode numbers.
>
> If a filesystem doesn't implement this callback, it defaults to
> DEFALT_WB_CTX = 0, maintaining its original behavior.
>
> An example implementation for XFS is provided, where XFS selects the
> writeback context based on its Allocation Group number.
>
> Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
> Signed-off-by: Kundan Kumar <kundan.kumar@samsung.com>
As Christoph asked in other patch. Please introduce generic writeback
changes in one patch and then provide xfs implementation of
xfs_get_inode_wb_ctx() in another patch. Thanks.
Honza
> ---
> fs/fs-writeback.c | 3 ++-
> fs/xfs/xfs_super.c | 13 +++++++++++++
> include/linux/backing-dev.h | 5 ++++-
> include/linux/fs.h | 1 +
> 4 files changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index 0715a7617391..56c048e22f72 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -265,7 +265,8 @@ void __inode_attach_wb(struct inode *inode, struct folio *folio)
> {
> struct backing_dev_info *bdi = inode_to_bdi(inode);
> struct bdi_writeback *wb = NULL;
> - struct bdi_writeback_ctx *bdi_writeback_ctx = bdi->wb_ctx[0];
> + struct bdi_writeback_ctx *bdi_writeback_ctx =
> + fetch_bdi_writeback_ctx(inode);
>
> if (inode_cgwb_enabled(inode)) {
> struct cgroup_subsys_state *memcg_css;
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index bb0a82635a77..b3ec9141d902 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -53,6 +53,7 @@
> #include <linux/magic.h>
> #include <linux/fs_context.h>
> #include <linux/fs_parser.h>
> +#include <linux/backing-dev.h>
>
> static const struct super_operations xfs_super_operations;
>
> @@ -1294,6 +1295,17 @@ xfs_fs_show_stats(
> return 0;
> }
>
> +static struct bdi_writeback_ctx *
> +xfs_get_inode_wb_ctx(
> + struct inode *inode)
> +{
> + struct xfs_inode *ip = XFS_I(inode);
> + struct backing_dev_info *bdi = inode_to_bdi(inode);
> + xfs_agino_t agno = XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino);
> +
> + return bdi->wb_ctx[agno % bdi->nr_wb_ctx];
> +}
> +
> static const struct super_operations xfs_super_operations = {
> .alloc_inode = xfs_fs_alloc_inode,
> .destroy_inode = xfs_fs_destroy_inode,
> @@ -1310,6 +1322,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 = xfs_get_inode_wb_ctx,
> };
>
> static int
> diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
> index 951ab5497500..59bbb69d300c 100644
> --- a/include/linux/backing-dev.h
> +++ b/include/linux/backing-dev.h
> @@ -148,6 +148,7 @@ static inline bool mapping_can_writeback(struct address_space *mapping)
> return inode_to_bdi(mapping->host)->capabilities & BDI_CAP_WRITEBACK;
> }
>
> +#define DEFAULT_WB_CTX 0
> #define for_each_bdi_wb_ctx(bdi, wbctx) \
> for (int __i = 0; __i < (bdi)->nr_wb_ctx \
> && ((wbctx) = (bdi)->wb_ctx[__i]) != NULL; __i++)
> @@ -157,7 +158,9 @@ fetch_bdi_writeback_ctx(struct inode *inode)
> {
> struct backing_dev_info *bdi = inode_to_bdi(inode);
>
> - return bdi->wb_ctx[0];
> + if (inode->i_sb->s_op->get_inode_wb_ctx)
> + return inode->i_sb->s_op->get_inode_wb_ctx(inode);
> + return bdi->wb_ctx[DEFAULT_WB_CTX];
> }
>
> #ifdef CONFIG_CGROUP_WRITEBACK
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 754fec84f350..5199b0d49fa5 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2379,6 +2379,7 @@ struct super_operations {
> */
> int (*remove_bdev)(struct super_block *sb, struct block_device *bdev);
> void (*shutdown)(struct super_block *sb);
> + struct bdi_writeback_ctx *(*get_inode_wb_ctx)(struct inode *inode);
> };
>
> /*
> --
> 2.25.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2025-10-21 11:58 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20251014120958epcas5p267c3c9f9dbe6ffc53c25755327de89f9@epcas5p2.samsung.com>
2025-10-14 12:08 ` [PATCH v2 00/16] Parallelizing filesystem writeback Kundan Kumar
[not found] ` <CGME20251014121014epcas5p11d254fd09fcc157ea69c39bd9c5984ed@epcas5p1.samsung.com>
2025-10-14 12:08 ` [PATCH v2 01/16] writeback: add infra for parallel writeback Kundan Kumar
2025-10-21 11:52 ` Jan Kara
[not found] ` <CGME20251014121020epcas5p36ca8a0d6d74f7b81996bb367329feb4a@epcas5p3.samsung.com>
2025-10-14 12:08 ` [PATCH v2 02/16] writeback: add support to initialize and free multiple writeback ctxs Kundan Kumar
[not found] ` <CGME20251014121026epcas5p1aecefead887a6b4b6745cca0519d1092@epcas5p1.samsung.com>
2025-10-14 12:08 ` [PATCH v2 03/16] writeback: link bdi_writeback to its corresponding bdi_writeback_ctx Kundan Kumar
[not found] ` <CGME20251014121031epcas5p37b0c4e23a7ad2d623ba776498f795fb0@epcas5p3.samsung.com>
2025-10-14 12:08 ` [PATCH v2 04/16] writeback: affine inode to a writeback ctx within a bdi Kundan Kumar
2025-10-21 11:58 ` Jan Kara [this message]
[not found] ` <CGME20251014121036epcas5p17c607955db032d076daa2e5cfecfe8ea@epcas5p1.samsung.com>
2025-10-14 12:08 ` [PATCH v2 05/16] writeback: modify bdi_writeback search logic to search across all wb ctxs Kundan Kumar
2025-10-21 12:05 ` Jan Kara
[not found] ` <CGME20251014121042epcas5p16a955879f8aaca4d0a4fd50bc5344f55@epcas5p1.samsung.com>
2025-10-14 12:08 ` [PATCH v2 06/16] writeback: invoke all writeback contexts for flusher and dirtytime writeback Kundan Kumar
[not found] ` <CGME20251014121048epcas5p4e8665c2e4e12367465aa4d4ec1de84d9@epcas5p4.samsung.com>
2025-10-14 12:08 ` [PATCH v2 07/16] writeback: modify sync related functions to iterate over all writeback contexts Kundan Kumar
[not found] ` <CGME20251014121056epcas5p1cd2a7fde9f54633b5a331f4553f88735@epcas5p1.samsung.com>
2025-10-14 12:08 ` [PATCH v2 08/16] writeback: add support to collect stats for all writeback ctxs Kundan Kumar
[not found] ` <CGME20251014121102epcas5p3280cd3e6bf16a2fb6a7fe483751f07a7@epcas5p3.samsung.com>
2025-10-14 12:08 ` [PATCH v2 09/16] f2fs: add support in f2fs to handle multiple writeback contexts Kundan Kumar
2025-10-15 7:29 ` Christoph Hellwig
[not found] ` <CGME20251014121108epcas5p1d68e41bdb1d51ae137b9bb22a7d16fd1@epcas5p1.samsung.com>
2025-10-14 12:08 ` [PATCH v2 10/16] fuse: add support for multiple writeback contexts in fuse Kundan Kumar
[not found] ` <CGME20251014121113epcas5p3522dd553825deccfb9a1c9c12f071e3a@epcas5p3.samsung.com>
2025-10-14 12:08 ` [PATCH v2 11/16] gfs2: add support in gfs2 to handle multiple writeback contexts Kundan Kumar
[not found] ` <CGME20251014121117epcas5p3f095fc3e8c279700c7256e07cd780c5f@epcas5p3.samsung.com>
2025-10-14 12:08 ` [PATCH v2 12/16] nfs: add support in nfs " Kundan Kumar
[not found] ` <CGME20251014121122epcas5p3a01a79d090c3cca8caaf78c0f411e4c4@epcas5p3.samsung.com>
2025-10-14 12:08 ` [PATCH v2 13/16] writeback: configure the num of writeback contexts between 0 and number of online cpus Kundan Kumar
[not found] ` <CGME20251014121126epcas5p2ff20c9139bdd702c77b9de50e4f259c7@epcas5p2.samsung.com>
2025-10-14 12:08 ` [PATCH v2 14/16] writeback: segregated allocation and free of writeback contexts Kundan Kumar
[not found] ` <CGME20251014121130epcas5p3b76f1a7ab53a57403275e9ba5d3549a3@epcas5p3.samsung.com>
2025-10-14 12:08 ` [PATCH v2 15/16] writeback: added support to change the number of writebacks using a sysfs attribute Kundan Kumar
[not found] ` <CGME20251014121135epcas5p2aa801677c0561db10291c51d669873e2@epcas5p2.samsung.com>
2025-10-14 12:08 ` [PATCH v2 16/16] writeback: added XFS support for matching writeback count to allocation group count Kundan Kumar
2025-10-15 7:30 ` Christoph Hellwig
2025-10-15 1:03 ` [PATCH v2 00/16] Parallelizing filesystem writeback Andrew Morton
2025-10-15 8:54 ` Kundan Kumar
2025-10-15 7:31 ` Christoph Hellwig
2025-10-20 22:46 ` Dave Chinner
2025-10-21 10:36 ` Kundan Kumar
2025-10-21 12:11 ` Jan Kara
2025-10-23 11:41 ` Kundan Kumar
2025-10-22 4:39 ` Christoph Hellwig
2025-10-29 6:05 ` Kundan Kumar
2025-10-29 6:09 ` Darrick J. Wong
2025-10-29 8:55 ` Christoph Hellwig
2025-11-07 9:24 ` Kundan Kumar
2025-11-07 13:37 ` Christoph Hellwig
2025-11-11 5:41 ` Kundan Kumar
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=p7mc3a7upsebbipxrredqhtazwt3tvyn4qt5jtsn3wb43orew2@6jzeodvk4tli \
--to=jack@suse.cz \
--cc=agruenba@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=amir73il@gmail.com \
--cc=anna@kernel.org \
--cc=anuj20.g@samsung.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=chao@kernel.org \
--cc=clm@meta.com \
--cc=dave@stgolabs.net \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=gfs2@lists.linux.dev \
--cc=gost.dev@samsung.com \
--cc=hch@lst.de \
--cc=jaegeuk@kernel.org \
--cc=joshi.k@samsung.com \
--cc=kundan.kumar@samsung.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nfs@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=miklos@szeredi.hu \
--cc=ritesh.list@gmail.com \
--cc=trondmy@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=vishak.g@samsung.com \
--cc=wangyufei@vivo.com \
--cc=willy@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox