From: Kundan Kumar <kundan.kumar@samsung.com>
To: 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,
p.raghav@samsung.com, da.gomez@samsung.com
Cc: 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, Kundan Kumar <kundan.kumar@samsung.com>,
Anuj Gupta <anuj20.g@samsung.com>
Subject: [PATCH 07/13] writeback: modify sync related functions to iterate over all writeback contexts
Date: Thu, 29 May 2025 16:44:58 +0530 [thread overview]
Message-ID: <20250529111504.89912-8-kundan.kumar@samsung.com> (raw)
In-Reply-To: <20250529111504.89912-1-kundan.kumar@samsung.com>
Modify sync related functions to iterate over all writeback contexts.
Signed-off-by: Kundan Kumar <kundan.kumar@samsung.com>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
fs/fs-writeback.c | 66 +++++++++++++++++++++++++++++++----------------
1 file changed, 44 insertions(+), 22 deletions(-)
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 9b0940a6fe78..7558b8a33fe0 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -2752,11 +2752,13 @@ static void wait_sb_inodes(struct super_block *sb)
mutex_unlock(&sb->s_sync_lock);
}
-static void __writeback_inodes_sb_nr(struct super_block *sb, unsigned long nr,
- enum wb_reason reason, bool skip_if_busy)
+static void __writeback_inodes_sb_nr_ctx(struct super_block *sb,
+ unsigned long nr,
+ enum wb_reason reason,
+ bool skip_if_busy,
+ struct bdi_writeback_ctx *bdi_wb_ctx)
{
- struct backing_dev_info *bdi = sb->s_bdi;
- DEFINE_WB_COMPLETION(done, bdi->wb_ctx_arr[0]);
+ DEFINE_WB_COMPLETION(done, bdi_wb_ctx);
struct wb_writeback_work work = {
.sb = sb,
.sync_mode = WB_SYNC_NONE,
@@ -2766,13 +2768,23 @@ static void __writeback_inodes_sb_nr(struct super_block *sb, unsigned long nr,
.reason = reason,
};
+ bdi_split_work_to_wbs(sb->s_bdi, bdi_wb_ctx, &work, skip_if_busy);
+ wb_wait_for_completion(&done);
+}
+
+static void __writeback_inodes_sb_nr(struct super_block *sb, unsigned long nr,
+ enum wb_reason reason, bool skip_if_busy)
+{
+ struct backing_dev_info *bdi = sb->s_bdi;
+ struct bdi_writeback_ctx *bdi_wb_ctx;
+
if (!bdi_has_dirty_io(bdi) || bdi == &noop_backing_dev_info)
return;
WARN_ON(!rwsem_is_locked(&sb->s_umount));
- bdi_split_work_to_wbs(sb->s_bdi, bdi->wb_ctx_arr[0], &work,
- skip_if_busy);
- wb_wait_for_completion(&done);
+ for_each_bdi_wb_ctx(bdi, bdi_wb_ctx)
+ __writeback_inodes_sb_nr_ctx(sb, nr, reason, skip_if_busy,
+ bdi_wb_ctx);
}
/**
@@ -2825,17 +2837,11 @@ void try_to_writeback_inodes_sb(struct super_block *sb, enum wb_reason reason)
}
EXPORT_SYMBOL(try_to_writeback_inodes_sb);
-/**
- * sync_inodes_sb - sync sb inode pages
- * @sb: the superblock
- *
- * This function writes and waits on any dirty inode belonging to this
- * super_block.
- */
-void sync_inodes_sb(struct super_block *sb)
+static void sync_inodes_bdi_wb_ctx(struct super_block *sb,
+ struct backing_dev_info *bdi,
+ struct bdi_writeback_ctx *bdi_wb_ctx)
{
- struct backing_dev_info *bdi = sb->s_bdi;
- DEFINE_WB_COMPLETION(done, bdi->wb_ctx_arr[0]);
+ DEFINE_WB_COMPLETION(done, bdi_wb_ctx);
struct wb_writeback_work work = {
.sb = sb,
.sync_mode = WB_SYNC_ALL,
@@ -2846,6 +2852,25 @@ void sync_inodes_sb(struct super_block *sb)
.for_sync = 1,
};
+ /* protect against inode wb switch, see inode_switch_wbs_work_fn() */
+ bdi_down_write_wb_ctx_switch_rwsem(bdi_wb_ctx);
+ bdi_split_work_to_wbs(bdi, bdi_wb_ctx, &work, false);
+ wb_wait_for_completion(&done);
+ bdi_up_write_wb_ctx_switch_rwsem(bdi_wb_ctx);
+}
+
+/**
+ * sync_inodes_sb - sync sb inode pages
+ * @sb: the superblock
+ *
+ * This function writes and waits on any dirty inode belonging to this
+ * super_block.
+ */
+void sync_inodes_sb(struct super_block *sb)
+{
+ struct backing_dev_info *bdi = sb->s_bdi;
+ struct bdi_writeback_ctx *bdi_wb_ctx;
+
/*
* Can't skip on !bdi_has_dirty() because we should wait for !dirty
* inodes under writeback and I_DIRTY_TIME inodes ignored by
@@ -2855,11 +2880,8 @@ void sync_inodes_sb(struct super_block *sb)
return;
WARN_ON(!rwsem_is_locked(&sb->s_umount));
- /* protect against inode wb switch, see inode_switch_wbs_work_fn() */
- bdi_down_write_wb_ctx_switch_rwsem(bdi->wb_ctx_arr[0]);
- bdi_split_work_to_wbs(bdi, bdi->wb_ctx_arr[0], &work, false);
- wb_wait_for_completion(&done);
- bdi_up_write_wb_ctx_switch_rwsem(bdi->wb_ctx_arr[0]);
+ for_each_bdi_wb_ctx(bdi, bdi_wb_ctx)
+ sync_inodes_bdi_wb_ctx(sb, bdi, bdi_wb_ctx);
wait_sb_inodes(sb);
}
--
2.25.1
next prev parent reply other threads:[~2025-05-29 11:34 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20250529113215epcas5p2edd67e7b129621f386be005fdba53378@epcas5p2.samsung.com>
2025-05-29 11:14 ` [PATCH 00/13] Parallelizing filesystem writeback Kundan Kumar
[not found] ` <CGME20250529113219epcas5p4d8ccb25ea910faea7120f092623f321d@epcas5p4.samsung.com>
2025-05-29 11:14 ` [PATCH 01/13] writeback: add infra for parallel writeback Kundan Kumar
[not found] ` <CGME20250529113224epcas5p2eea35fd0ebe445d8ad0471a144714b23@epcas5p2.samsung.com>
2025-05-29 11:14 ` [PATCH 02/13] writeback: add support to initialize and free multiple writeback ctxs Kundan Kumar
[not found] ` <CGME20250529113228epcas5p1db88ab42c2dac0698d715e38bd5e0896@epcas5p1.samsung.com>
2025-05-29 11:14 ` [PATCH 03/13] writeback: link bdi_writeback to its corresponding bdi_writeback_ctx Kundan Kumar
[not found] ` <CGME20250529113232epcas5p4e6f3b2f03d3a5f8fcaace3ddd03298d0@epcas5p4.samsung.com>
2025-05-29 11:14 ` [PATCH 04/13] writeback: affine inode to a writeback ctx within a bdi Kundan Kumar
2025-06-02 14:24 ` Christoph Hellwig
[not found] ` <CGME20250529113236epcas5p2049b6cc3be27d8727ac1f15697987ff5@epcas5p2.samsung.com>
2025-05-29 11:14 ` [PATCH 05/13] writeback: modify bdi_writeback search logic to search across all wb ctxs Kundan Kumar
[not found] ` <CGME20250529113240epcas5p295dcf9a016cc28e5c3e88d698808f645@epcas5p2.samsung.com>
2025-05-29 11:14 ` [PATCH 06/13] writeback: invoke all writeback contexts for flusher and dirtytime writeback Kundan Kumar
[not found] ` <CGME20250529113245epcas5p2978b77ce5ccf2d620f2a9ee5e796bee3@epcas5p2.samsung.com>
2025-05-29 11:14 ` Kundan Kumar [this message]
[not found] ` <CGME20250529113249epcas5p38b29d3c6256337eadc2d1644181f9b74@epcas5p3.samsung.com>
2025-05-29 11:14 ` [PATCH 08/13] writeback: add support to collect stats for all writeback ctxs Kundan Kumar
[not found] ` <CGME20250529113253epcas5p1a28e77b2d9824d55f594ccb053725ece@epcas5p1.samsung.com>
2025-05-29 11:15 ` [PATCH 09/13] f2fs: add support in f2fs to handle multiple writeback contexts Kundan Kumar
2025-06-02 14:20 ` Christoph Hellwig
[not found] ` <CGME20250529113257epcas5p4dbaf9c8e2dc362767c8553399632c1ea@epcas5p4.samsung.com>
2025-05-29 11:15 ` [PATCH 10/13] fuse: add support for multiple writeback contexts in fuse Kundan Kumar
2025-06-02 14:21 ` Christoph Hellwig
2025-06-02 15:50 ` Bernd Schubert
2025-06-02 15:55 ` Christoph Hellwig
[not found] ` <CGME20250529113302epcas5p3bdae265288af32172fb7380a727383eb@epcas5p3.samsung.com>
2025-05-29 11:15 ` [PATCH 11/13] gfs2: add support in gfs2 to handle multiple writeback contexts Kundan Kumar
[not found] ` <CGME20250529113306epcas5p3d10606ae4ea7c3491e93bde9ae408c9f@epcas5p3.samsung.com>
2025-05-29 11:15 ` [PATCH 12/13] nfs: add support in nfs " Kundan Kumar
2025-06-02 14:22 ` Christoph Hellwig
[not found] ` <CGME20250529113311epcas5p3c8f1785b34680481e2126fda3ab51ad9@epcas5p3.samsung.com>
2025-05-29 11:15 ` [PATCH 13/13] writeback: set the num of writeback contexts to number of online cpus Kundan Kumar
2025-06-03 14:36 ` kernel test robot
2025-05-30 3:37 ` [PATCH 00/13] Parallelizing filesystem writeback Andrew Morton
2025-06-25 15:44 ` Kundan Kumar
2025-07-02 18:43 ` Darrick J. Wong
2025-07-03 13:05 ` Christoph Hellwig
2025-07-04 7:02 ` Kundan Kumar
2025-07-07 14:28 ` Christoph Hellwig
2025-07-07 15:47 ` Jan Kara
2025-06-02 14:19 ` Christoph Hellwig
2025-06-03 9:16 ` Anuj Gupta/Anuj Gupta
2025-06-03 13:24 ` Christoph Hellwig
2025-06-03 13:52 ` Anuj gupta
2025-06-03 14:04 ` Christoph Hellwig
2025-06-03 14:05 ` Christoph Hellwig
2025-06-06 5:04 ` Kundan Kumar
2025-06-09 4:00 ` Christoph Hellwig
2025-06-04 9:22 ` Kundan Kumar
2025-06-11 15:51 ` Darrick J. Wong
2025-06-24 5:59 ` Kundan Kumar
2025-07-02 18:44 ` 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=20250529111504.89912-8-kundan.kumar@samsung.com \
--to=kundan.kumar@samsung.com \
--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=da.gomez@samsung.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=jack@suse.cz \
--cc=jaegeuk@kernel.org \
--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=p.raghav@samsung.com \
--cc=ritesh.list@gmail.com \
--cc=trondmy@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--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