From: Jan Kara <jack@suse.cz>
To: Ted Tso <tytso@mit.edu>
Cc: <linux-ext4@vger.kernel.org>,
Baokun Li <libaokun@linux.alibaba.com>,
Zhang Yi <yi.zhang@huawei.com>,
Ojaswin Mujoo <ojaswin@linux.ibm.com>,
Ritesh Harjani <ritesh.list@gmail.com>, Jan Kara <jack@suse.cz>
Subject: [PATCH 2/3] ext4: Fix transaction overflow during writeback
Date: Wed, 5 Aug 2026 17:35:48 +0200 [thread overview]
Message-ID: <20260805153605.166545-5-jack@suse.cz> (raw)
In-Reply-To: <20260805153202.29814-1-jack@suse.cz>
Commit 95ad8ee45cdb ("ext4: correct the reserved credits for extent
conversion") was correct to note that we need to reserve enough credits
for all extents possibly underlying a large folio. However it was too
eager to reduce the number of reserved credits. Extent conversion may
not only need to touch several leaf extent blocks, it may also need to
split extents - for example a single large unwritten extent may need to
be split into many small written ones in case of sparse folio dirtying.
This can thus result not only in extent leaf modifications but also in a
need to allocate new extent tree nodes. As a result the reserved
transaction credits were not sufficient in some corner cases. Use
ext4_meta_trans_blocks() for correct upper bound credit estimate.
Fixes: 95ad8ee45cdb ("ext4: correct the reserved credits for extent conversion")
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext4/inode.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index f324a54f1dae..ddce319e53c5 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2852,10 +2852,10 @@ static int ext4_do_writepages(struct mpage_da_data *mpd)
if (ext4_should_dioread_nolock(inode)) {
int bpf = ext4_journal_blocks_per_folio(inode);
/*
- * We may need to convert up to one extent per block in
- * the folio and we may dirty the inode.
+ * We may need to convert up to one extent per block in the
+ * folio.
*/
- rsv_blocks = 1 + ext4_ext_index_trans_blocks(inode, bpf);
+ rsv_blocks = ext4_meta_trans_blocks(inode, bpf, bpf, 0);
}
if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
--
2.51.0
next prev parent reply other threads:[~2026-08-05 15:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 15:35 [PATCH 0/3] ext4: Fix credit estimates for extent tree modifications Jan Kara
2026-08-05 15:35 ` [PATCH 1/3] ext4: Teach ext4_meta_trans_blocks() about number of allocated extents Jan Kara
2026-08-06 18:09 ` Ojaswin Mujoo
2026-08-07 2:59 ` Zhang Yi
2026-08-07 5:59 ` Ojaswin Mujoo
2026-08-07 7:05 ` Zhang Yi
2026-08-07 7:28 ` Ojaswin Mujoo
2026-08-05 15:35 ` Jan Kara [this message]
2026-08-07 3:36 ` [PATCH 2/3] ext4: Fix transaction overflow during writeback Zhang Yi
2026-08-07 8:40 ` Ojaswin Mujoo
2026-08-05 15:35 ` [PATCH 3/3] ext4: Fix estimate extent index blocks in ext4_ext_index_trans_blocks() Jan Kara
2026-08-07 4:46 ` Zhang Yi
2026-08-07 6:37 ` Ojaswin Mujoo
2026-08-17 11:39 ` Jan Kara
2026-08-17 15:04 ` Ojaswin Mujoo
2026-08-10 1:33 ` [PATCH 0/3] ext4: Fix credit estimates for extent tree modifications Theodore Ts'o
2026-08-14 6:51 ` Ojaswin Mujoo
2026-08-17 23:31 ` Theodore Tso
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=20260805153605.166545-5-jack@suse.cz \
--to=jack@suse.cz \
--cc=libaokun@linux.alibaba.com \
--cc=linux-ext4@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
--cc=yi.zhang@huawei.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.