From: Andreas Gruenbacher <agruenba@redhat.com>
To: Jan Kara <jack@suse.cz>
Cc: Andreas Gruenbacher <agruenba@redhat.com>,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
Christian Brauner <brauner@kernel.org>,
Christoph Hellwig <hch@infradead.org>,
Mikhail Rudenko <xyzzy@yandex-team.ru>
Subject: Re: [PATCH v2 3/5] fs: Basic infrastructure for offloading inode reclaim
Date: Wed, 23 Sep 2026 22:09:26 +0200 [thread overview]
Message-ID: <20260923200927.1834507-1-agruenba@redhat.com> (raw)
In-Reply-To: 20260911085142.1774803-8-jack@suse.cz
Jan,
it seems that we don't really need struct inodes_to_prune; see below.
diff --git a/fs/inode.c b/fs/inode.c
index 7c69ef44619a..f8303af66fcd 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -938,12 +938,6 @@ void evict_inodes(struct super_block *sb)
}
EXPORT_SYMBOL_GPL(evict_inodes);
-struct inodes_to_prune {
- struct list_head freeable;
- struct list_head deferred;
- unsigned int deferred_count;
-};
-
/*
* Isolate the inode from the LRU in preparation for freeing it.
*
@@ -958,7 +952,7 @@ struct inodes_to_prune {
static enum lru_status inode_lru_isolate(struct list_head *item,
struct list_lru_one *lru, void *arg)
{
- struct inodes_to_prune *lists = arg;
+ struct list_head *freeable = arg;
struct inode *inode = container_of(item, struct inode, i_lru);
/*
@@ -1013,13 +1007,7 @@ static enum lru_status inode_lru_isolate(struct list_head *item,
WARN_ON(inode_state_read(inode) & I_NEW);
inode_state_set(inode, I_FREEING);
- /* Inode will take long time to cleanup. Offload that to worker. */
- if (inode_state_read(inode) & I_DEFER_RECLAIM) {
- list_lru_isolate_move(lru, &inode->i_lru, &lists->deferred);
- lists->deferred_count++;
- } else {
- list_lru_isolate_move(lru, &inode->i_lru, &lists->freeable);
- }
+ list_lru_isolate_move(lru, &inode->i_lru, freeable);
spin_unlock(&inode->i_lock);
this_cpu_dec(nr_unused);
@@ -1042,27 +1030,34 @@ static int get_deferred_sb_id(struct super_block *sb)
*/
long prune_icache_sb(struct super_block *sb, struct shrink_control *sc)
{
- struct inodes_to_prune lists = {
- .freeable = LIST_HEAD_INIT(lists.freeable),
- .deferred = LIST_HEAD_INIT(lists.deferred),
- };
- long freed;
+ struct inode *inode, *tmp;
+ long freed, deferred = 0;
+ LIST_HEAD(freeable);
freed = list_lru_shrink_walk(&sb->s_inode_lru, sc,
- inode_lru_isolate, &lists);
- dispose_list(&lists.freeable);
- if (!list_empty(&lists.deferred)) {
+ inode_lru_isolate, &freeable);
+
+ list_for_each_entry_safe(inode, tmp, &freeable, i_lru) {
+ if (inode_state_read(inode) & I_DEFER_RECLAIM) {
+ deferred++;
+ continue;
+ }
+ list_del_init(&inode->i_lru);
+ evict(inode);
+ cond_resched();
+ }
+
+ if (!list_empty(&freeable)) {
int id = get_deferred_sb_id(sb);
int i, wake_count;
spin_lock(&deferred_reclaim.queues[id].lock);
- list_splice_tail(&lists.deferred,
- &deferred_reclaim.queues[id].list);
- atomic_add(lists.deferred_count, &sb->s_deferred_reclaim_count);
+ list_splice_tail(&freeable, &deferred_reclaim.queues[id].list);
+ atomic_add(deferred, &sb->s_deferred_reclaim_count);
spin_unlock(&deferred_reclaim.queues[id].lock);
/* Queue works to process inodes we've added to the list */
- wake_count = (lists.deferred_count + INODE_RECLAIM_BATCH_SIZE)
+ wake_count = (deferred + INODE_RECLAIM_BATCH_SIZE)
/ INODE_RECLAIM_BATCH_SIZE;
if (wake_count > deferred_reclaim.workers)
wake_count = deferred_reclaim.workers;
--
2.55.0
Thanks,
Andreas
next reply other threads:[~2026-09-23 20:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 20:09 Andreas Gruenbacher [this message]
2026-09-24 17:13 ` [PATCH v2 3/5] fs: Basic infrastructure for offloading inode reclaim Jan Kara
-- strict thread matches above, loose matches on Subject: below --
2026-09-23 20:04 Andreas Gruenbacher
2026-09-11 8:51 [PATCH 0/5 v2] fs: Deferred " Jan Kara
2026-09-11 8:51 ` [PATCH v2 3/5] fs: Basic infrastructure for offloading " Jan Kara
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=20260923200927.1834507-1-agruenba@redhat.com \
--to=agruenba@redhat.com \
--cc=brauner@kernel.org \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=xyzzy@yandex-team.ru \
/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