From: Jan Kara <jack@suse.cz>
To: <linux-fsdevel@vger.kernel.org>
Cc: <linux-mm@kvack.org>, Matthew Wilcox <willy@infradead.org>,
Jan Kara <jack@suse.cz>
Subject: [PATCH 4/4] ext4: Defer inode reclaim if it has preallocations
Date: Wed, 29 Apr 2026 20:00:54 +0200 [thread overview]
Message-ID: <20260429180056.29598-8-jack@suse.cz> (raw)
In-Reply-To: <20260429174850.18223-1-jack@suse.cz>
When we have to free preallocations during inode eviction, we need to
load block bitmaps and run transaction to modify them. This takes time
and also requires GFP_NOFAIL allocations. Mark inodes with preallocated
blocks as needing offloading of inode reclaim to a workqueue so that we
don't block reclaim for long and potentially deadlock MM subsystem.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext4/mballoc.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index ed1bd00e11cd..4de3cfa4e648 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -3114,6 +3114,13 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
if (ac->ac_prefetch_nr)
ext4_mb_prefetch_fini(sb, ac->ac_prefetch_grp, ac->ac_prefetch_nr);
+ /*
+ * Freeing preallocations requires loading bitmaps and running
+ * transactions. Defer inode reclaim to a workqueue.
+ */
+ if (!RB_EMPTY_ROOT(&EXT4_I(ac->ac_inode)->i_prealloc_node))
+ mark_inode_reclaim_deferred(ac->ac_inode);
+
return err;
}
--
2.51.0
prev parent reply other threads:[~2026-04-29 18:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 18:00 [PATCH RFC 0/4] fs: Deferred inode reclaim Jan Kara
2026-04-29 18:00 ` [PATCH 1/4] fs: Avoid inode dirtying on last iput Jan Kara
2026-04-29 18:00 ` [PATCH 2/4] fs: Basic infrastructure for offloading inode reclaim Jan Kara
2026-04-29 18:00 ` [PATCH 3/4] fs: Add throttling to deferred " Jan Kara
2026-04-29 18:00 ` Jan Kara [this message]
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=20260429180056.29598-8-jack@suse.cz \
--to=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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