From: Roman Gushchin <guro@fb.com>
To: Jan Kara <jack@suse.cz>, Tejun Heo <tj@kernel.org>
Cc: <linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-mm@kvack.org>, Alexander Viro <viro@zeniv.linux.org.uk>,
Dennis Zhou <dennis@kernel.org>,
Dave Chinner <dchinner@redhat.com>, <cgroups@vger.kernel.org>,
Roman Gushchin <guro@fb.com>
Subject: [PATCH v6 4/5] writeback, cgroup: support switching multiple inodes at once
Date: Wed, 2 Jun 2021 17:55:16 -0700 [thread overview]
Message-ID: <20210603005517.1403689-5-guro@fb.com> (raw)
In-Reply-To: <20210603005517.1403689-1-guro@fb.com>
Currently only a single inode can be switched to another writeback
structure at once. That means to switch an inode a separate
inode_switch_wbs_context structure must be allocated, and a separate
rcu callback and work must be scheduled.
It's fine for the existing ad-hoc switching, which is not happening
that often, but sub-optimal for massive switching required in order to
release a writeback structure. To prepare for it, let's add a support
for switching multiple inodes at once.
Instead of containing a single inode pointer, inode_switch_wbs_context
will contain a NULL-terminated array of inode
pointers. inode_do_switch_wbs() will be called for each inode.
Signed-off-by: Roman Gushchin <guro@fb.com>
---
fs/fs-writeback.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 212494d89cc2..49d7b23a7cfe 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -335,10 +335,10 @@ static struct bdi_writeback *inode_to_wb_and_lock_list(struct inode *inode)
}
struct inode_switch_wbs_context {
- struct inode *inode;
- struct bdi_writeback *new_wb;
-
struct rcu_work work;
+
+ struct bdi_writeback *new_wb;
+ struct inode *inodes[];
};
static void bdi_down_write_wb_switch_rwsem(struct backing_dev_info *bdi)
@@ -473,10 +473,14 @@ static void inode_switch_wbs_work_fn(struct work_struct *work)
{
struct inode_switch_wbs_context *isw =
container_of(to_rcu_work(work), struct inode_switch_wbs_context, work);
+ struct inode **inodep;
+
+ for (inodep = &isw->inodes[0]; *inodep; inodep++) {
+ inode_do_switch_wbs(*inodep, isw->new_wb);
+ iput(*inodep);
+ }
- inode_do_switch_wbs(isw->inode, isw->new_wb);
wb_put(isw->new_wb);
- iput(isw->inode);
kfree(isw);
atomic_dec(&isw_nr_in_flight);
}
@@ -503,7 +507,7 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)
if (atomic_read(&isw_nr_in_flight) > WB_FRN_MAX_IN_FLIGHT)
return;
- isw = kzalloc(sizeof(*isw), GFP_ATOMIC);
+ isw = kzalloc(sizeof(*isw) + 2 * sizeof(struct inode *), GFP_ATOMIC);
if (!isw)
return;
@@ -528,7 +532,7 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)
__iget(inode);
spin_unlock(&inode->i_lock);
- isw->inode = inode;
+ isw->inodes[0] = inode;
/*
* In addition to synchronizing among switchers, I_WB_SWITCH tells
--
2.31.1
next prev parent reply other threads:[~2021-06-03 0:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-03 0:55 [PATCH v6 0/5] cgroup, blkcg: prevent dirty inodes to pin dying memory cgroups Roman Gushchin
2021-06-03 0:55 ` [PATCH v6 1/5] writeback, cgroup: switch to rcu_work API in inode_switch_wbs() Roman Gushchin
2021-06-03 8:46 ` Jan Kara
2021-06-03 0:55 ` [PATCH v6 2/5] writeback, cgroup: keep list of inodes attached to bdi_writeback Roman Gushchin
2021-06-03 8:55 ` Jan Kara
2021-06-03 0:55 ` [PATCH v6 3/5] writeback, cgroup: split out the functional part of inode_switch_wbs_work_fn() Roman Gushchin
2021-06-03 8:57 ` Jan Kara
2021-06-03 0:55 ` Roman Gushchin [this message]
2021-06-03 10:10 ` [PATCH v6 4/5] writeback, cgroup: support switching multiple inodes at once Jan Kara
2021-06-03 0:55 ` [PATCH v6 5/5] writeback, cgroup: release dying cgwbs by switching attached inodes Roman Gushchin
2021-06-03 10:02 ` Jan Kara
2021-06-04 1:36 ` Roman Gushchin
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=20210603005517.1403689-5-guro@fb.com \
--to=guro@fb.com \
--cc=cgroups@vger.kernel.org \
--cc=dchinner@redhat.com \
--cc=dennis@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=tj@kernel.org \
--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