From: sashiko-bot@kernel.org
To: "Xing Ma" <maxing.lan@bytedance.com>, linux-ext4@vger.kernel.org
Cc: tytso@mit.edu
Subject: Re: [PATCH v3 2/2] ext4: track truncated block range in ext4_truncate() for fast commit
Date: Mon, 30 Nov 2026 23:28:18 +0000 [thread overview]
Message-ID: <sashiko-outbox-242240@kernel.org> (raw)
In-Reply-To: <20261201070558.4017023-3-maxing.lan@bytedance.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ext4: range mismatch between ext4_truncate_down() and
ext4_ext_truncate()
--
commit e0b0a96d89503d8b723098577fe6474607943c18
Author: Xing Ma <maxing.lan@bytedance.com>
ext4: track truncated block range in ext4_truncate() for fast commit
This commit inserts an EXTENT_STATUS_HOLE entry in ext4_ext_truncate() and
calls ext4_fc_track_range() in ext4_truncate() so that truncated ranges are
tracked for fast commit.
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index b65b0261ee5c3..a47b56e3cbe9c 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -4608,6 +4608,11 @@ int ext4_ext_truncate(handle_t *handle, struct inode *inode)
> memalloc_retry_wait(GFP_ATOMIC);
> goto retry_remove_space;
> }
> + if (!err && inode->i_nlink && test_opt2(sb, JOURNAL_FAST_COMMIT) &&
> + last_block < EXT_MAX_BLOCKS)
> + ext4_es_insert_extent(inode, last_block,
> + EXT_MAX_BLOCKS - last_block, ~0,
> + EXTENT_STATUS_HOLE, 0);
> return err;
> }
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 07a62d8569d31..78823397d4245 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -5608,6 +5608,16 @@ int ext4_truncate(struct inode *inode)
> if (err)
> goto out_stop;
>
> + if (!ext4_handle_is_aborted(handle)) {
> + ext4_lblk_t last_block;
> +
> + last_block = (inode->i_size + inode->i_sb->s_blocksize - 1)
> + >> inode->i_blkbits;
> + if (last_block < EXT_MAX_BLOCKS)
> + ext4_fc_track_range(handle, inode, last_block,
> + EXT_MAX_BLOCKS - 1);
> + }
[Severity: Medium]
When shrinking a file to a non-zero size, doesn't ext4_truncate_down() still
leave i_fc_lblk_start set to last_block - 1 while ext4_ext_truncate() only
inserts the EXTENT_STATUS_HOLE entry starting at last_block?
In ext4_truncate_down(), start_lblk is computed before calling
ext4_truncate():
fs/ext4/inode.c:ext4_truncate_down() {
...
start_lblk = newsize > 0 ? (newsize - 1) >> inode->i_blkbits : 0;
ext4_fc_track_range(handle, inode, start_lblk, EXT_MAX_BLOCKS - 1);
...
}
For any newsize > 0, start_lblk is last_block - 1 (for example, truncating to
a block-aligned 4K gives start_lblk = 0 and last_block = 1). When both
handles run in the same transaction, __track_range() merges the two ranges
with min(ei->i_fc_lblk_start, __arg->start), keeping i_fc_lblk_start at
last_block - 1.
If block last_block - 1 is not already cached in i_es_tree (such as on a
block-aligned truncate where ext4_block_zero_eof() is skipped and its extent
was not queried or was reclaimed), ext4_fc_snapshot_inode_data() starts
scanning at last_block - 1, hits EXT4_FC_SNAP_ERR_ES_MISS, and falls back to
a full journal commit.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201070558.4017023-1-maxing.lan@bytedance.com?part=2
next prev parent reply other threads:[~2026-11-30 23:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 23:05 [PATCH v3 0/2] ext4: fix fast commit orphan inode replay and truncate range tracking Xing Ma
2026-11-30 23:05 ` [PATCH v3 1/2] ext4: fall back to full commit for unlinked or orphan inodes in fast commit Xing Ma
2026-11-30 23:06 ` [PATCH v3 2/2] ext4: track truncated block range in ext4_truncate() for " Xing Ma
2026-11-30 23:28 ` sashiko-bot [this message]
2026-11-30 23:28 ` [PATCH v3 0/2] ext4: fix fast commit orphan inode replay and truncate range tracking sashiko-bot
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=sashiko-outbox-242240@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=maxing.lan@bytedance.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tytso@mit.edu \
/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.