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 3/3] ext4: Fix estimate extent index blocks in ext4_ext_index_trans_blocks()
Date: Wed, 5 Aug 2026 17:35:49 +0200 [thread overview]
Message-ID: <20260805153605.166545-6-jack@suse.cz> (raw)
In-Reply-To: <20260805153202.29814-1-jack@suse.cz>
The estimate of the number of impacted extent tree index blocks could be
one-too-low. If we modify say 2 extents, already two leaf index blocks
could be impacted, not just one the current estimate counts with. Fix
the estimate.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext4/extents.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 44ab246a3176..713b2c098af5 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2427,9 +2427,17 @@ int ext4_ext_index_trans_blocks(struct inode *inode, int extents)
*/
if (extents <= 1)
index = (EXT4_MAX_EXTENT_DEPTH * 2) + extents;
- else
- index = (EXT4_MAX_EXTENT_DEPTH * 3) +
- DIV_ROUND_UP(extents, ext4_ext_space_block(inode, 0));
+ else {
+ int ext_max = ext4_ext_space_block(inode, 0);
+
+ index = EXT4_MAX_EXTENT_DEPTH * 3;
+ /*
+ * Modified extents need not start at the beginning of the
+ * leaf. Already two extents may need two leaf block
+ * modifications...
+ */
+ index += DIV_ROUND_UP(extents + ext_max - 1, ext_max);
+ }
return index;
}
--
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 ` [PATCH 2/3] ext4: Fix transaction overflow during writeback Jan Kara
2026-08-07 3:36 ` Zhang Yi
2026-08-07 8:40 ` Ojaswin Mujoo
2026-08-05 15:35 ` Jan Kara [this message]
2026-08-07 4:46 ` [PATCH 3/3] ext4: Fix estimate extent index blocks in ext4_ext_index_trans_blocks() 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-6-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.