From: sashiko-bot@kernel.org
To: "Ojaswin Mujoo" <ojaswin@linux.ibm.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
Subject: Re: [PATCH v2 02/13] ext4: introduce CONVERT_PENDING extent status type
Date: Fri, 27 Nov 2026 15:58:33 +0000 [thread overview]
Message-ID: <sashiko-outbox-237799@kernel.org> (raw)
In-Reply-To: <20261127-ext4-endio-zero-bug-v2-2-4106968e4d15@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ext4: double reservation update on ENOMEM retry in
ext4_es_insert_extent()
--
commit 574b0ce6804297f971eb1e0a8136bb02463b4f9a
Author: Ojaswin Mujoo <ojaswin@linux.ibm.com>
ext4: introduce CONVERT_PENDING extent status type
This commit adds the EXTENT_STATUS_CONVERT_PENDING extent status type to
track unwritten extents undergoing disk I/O before endio converts them to
written.
> diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
> index b7fb8502f9d46..28528f19be1df 100644
> --- a/fs/ext4/extents_status.c
> +++ b/fs/ext4/extents_status.c
> @@ -529,6 +529,9 @@ static inline bool ext4_es_must_keep(struct extent_status *es)
> if (ext4_es_is_delayed(es))
> return true;
>
> + if (ext4_es_is_convert_pending(es))
> + return true;
> +
> return false;
> }
[Severity: Medium]
Can making EXTENT_STATUS_CONVERT_PENDING a must-keep extent cause
ext4_es_insert_extent() to call ext4_da_update_reserve_space() twice with
the same resv_used count on an -ENOMEM retry?
Previously, ext4_es_must_keep() only returned true for delayed extents,
which are not inserted through ext4_es_insert_extent(), so err2 == -ENOMEM
was always cleared to 0. Now, when ext4_es_insert_extent() replaces a
delayed extent with a convert-pending extent, __es_remove_extent() removes
the delayed extent and sets resv_used > 0. If __es_insert_extent() then
fails its initial GFP_ATOMIC allocation with -ENOMEM, execution jumps to
error: and updates the reservation before retrying:
fs/ext4/extents_status.c:ext4_es_insert_extent() {
...
err1 = __es_remove_extent(inode, lblk, end, 0, &resv_used, NULL, es1);
if (err1 != 0)
goto error;
...
err2 = __es_insert_extent(inode, &newes, es2);
if (err2 == -ENOMEM && !ext4_es_must_keep(&newes))
err2 = 0;
if (err2 != 0)
goto error;
...
error:
write_unlock(&EXT4_I(inode)->i_es_lock);
...
resv_used += pending;
if (resv_used)
ext4_da_update_reserve_space(inode, resv_used,
delalloc_reserve_used);
if (err1 || err2 || err3 < 0)
goto retry;
}
On the retry pass, no extents remain in [lblk, end], so
__es_remove_extent() returns 0 early without writing *reserved, leaving
resv_used at its value from the first pass. After __es_insert_extent()
succeeds with the preallocated es2, ext4_da_update_reserve_space() runs a
second time with the stale resv_used, underflowing i_reserved_data_blocks
(triggering WARN_ON(1)) and double-claiming or double-releasing quota.
Resetting resv_used = 0 (and pending = 0) before goto retry would avoid
applying the reservation update twice.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127-ext4-endio-zero-bug-v2-0-4106968e4d15@linux.ibm.com?part=2
next prev parent reply other threads:[~2026-11-27 15:58 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 15:10 [PATCH v2 00/13] ext4: fix endio zeroout corruption by tracking to-be-converted unwritten IOs Ojaswin Mujoo
2026-11-27 15:10 ` [PATCH v2 01/13] ext4: disable zeroout fallback in ext4_split_extent() Ojaswin Mujoo
2026-11-27 15:10 ` [PATCH v2 02/13] ext4: introduce CONVERT_PENDING extent status type Ojaswin Mujoo
2026-11-27 15:58 ` sashiko-bot [this message]
2026-11-27 15:10 ` [PATCH v2 03/13] ext4: preserve convert pending extents when adding unwrit extents to es cache Ojaswin Mujoo
2026-12-01 12:54 ` Zhang Yi
2026-11-27 15:10 ` [PATCH v2 04/13] ext4: add es helper to convert unwrit to convert pending without changing i_es_seq Ojaswin Mujoo
2026-11-27 16:46 ` sashiko-bot
2026-11-27 15:10 ` [PATCH v2 05/13] ext4: add support to track convert pending ranges in ext4_map_blocks() Ojaswin Mujoo
2026-11-27 17:19 ` sashiko-bot
2026-11-27 15:10 ` [PATCH v2 06/13] ext4: add tracking for unwritten to-be-converted ranges in dio write path Ojaswin Mujoo
2026-11-27 17:48 ` sashiko-bot
2026-11-27 15:10 ` [PATCH v2 07/13] ext4: add tracking for unwritten to-be-converted ranges in non iomap buffered path Ojaswin Mujoo
2026-11-27 18:17 ` sashiko-bot
2026-11-27 15:10 ` [PATCH v2 08/13] ext4: add tracking for unwritten to-be-converted ranges in " Ojaswin Mujoo
2026-11-27 18:30 ` sashiko-bot
2026-11-27 15:10 ` [PATCH v2 09/13] ext4: don't zeroout if conv pending ranges are present Ojaswin Mujoo
2026-11-27 15:10 ` [PATCH v2 10/13] ext4: add tracepoints for extent split and convert Ojaswin Mujoo
2026-11-27 15:10 ` [PATCH v2 11/13] ext4: update extent status cache when zeroing extents Ojaswin Mujoo
2026-11-27 19:32 ` sashiko-bot
2026-11-27 15:10 ` [PATCH v2 12/13] ext4: don't drop the extents in case extent split fails Ojaswin Mujoo
2026-11-27 15:11 ` [PATCH v2 13/13] ext4: re-enable zeroout fallback Ojaswin Mujoo
2026-11-27 20:20 ` sashiko-bot
2026-11-27 20:20 ` [PATCH v2 00/13] ext4: fix endio zeroout corruption by tracking to-be-converted unwritten IOs 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-237799@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=ojaswin@linux.ibm.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.