All of lore.kernel.org
 help / color / mirror / Atom feed
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 11/13] ext4: update extent status cache when zeroing extents
Date: Fri, 27 Nov 2026 19:32:50 +0000	[thread overview]
Message-ID: <sashiko-outbox-238163@kernel.org> (raw)
In-Reply-To: <20261127-ext4-endio-zero-bug-v2-11-4106968e4d15@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] ext4: premature extent status update before ext4_ext_dirty()
- [Medium] ext4: partial ES update in ext4_split_extent_zeroout() causes
  cache conflict
--

commit 0cf9a9536a99953085924a6638817aafc21bee09
Author: Ojaswin Mujoo <ojaswin@linux.ibm.com>

ext4: update extent status cache when zeroing extents

This commit records zeroed sub-ranges during the extent split zeroout
fallback and inserts them as written into the extent status tree once the
extent is marked initialized.

> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 0f5d9f3c42a9b..e8ebc518e58ba 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -3341,8 +3341,15 @@ static int ext4_split_extent_zeroout(handle_t *handle, struct inode *inode,
>  	ext4_lblk_t ee_block;
>  	uint64_t lblk, pblk, len;
>  	int is_unwrit;
> -	int err = 0;
> +	int err = 0, i, nr_zeroed = 0;
>  	loff_t map_end, ex_end;
> +	/*
> +	 * zeroed[] is used to record ranges successfully zeroed so only these
> +	 * can be added to the cache
> +	 */
> +	struct {
> +		uint64_t lblk, len, pblk;
> +	} zeroed[2];

[ ... ]

> @@ -3450,6 +3469,11 @@ static int ext4_split_extent_zeroout(handle_t *handle, struct inode *inode,
>  
>  	ext4_ext_mark_initialized(ex);
>  
> +	for (i = 0; i < nr_zeroed; i++)
> +		ext4_es_insert_extent(inode, zeroed[i].lblk, zeroed[i].len,
> +				      zeroed[i].pblk, EXTENT_STATUS_WRITTEN,
> +				      false);

[Severity: Medium]
Can updating only the zeroed[] sub-ranges in i_es_tree cause a cache
conflict when ext4_split_convert_extents() re-reads the extent?

ext4_ext_mark_initialized(ex) initializes the entire on-disk extent,
while the mapped sub-range [map->m_lblk, map->m_lblk + map->m_len) stays
unwritten in i_es_tree until the end of ext4_split_convert_extents().
Once commit "ext4: don't drop the extents in case extent split fails"
and commit "ext4: re-enable zeroout fallback" in this series keep the
extent in i_es_tree across a failed split, a caller without
EXT4_EX_NOCACHE (such as ext4_ext_convert_to_initialized()) on a
depth == 0 inode hits ext4_find_extent() -> ext4_cache_extents() ->
ext4_es_cache_extent() at the convert label before i_es_tree is updated
for the full extent:

fs/ext4/extents.c:ext4_split_convert_extents() {
    ...
convert:
	path = ext4_find_extent(inode, map->m_lblk, path, flags);
	if (IS_ERR(path))
		return path;
    ...
	if (!(flags & EXT4_EX_NOCACHE))
		ext4_es_insert_extent(inode, le32_to_cpu(ex->ee_block),
				      ext4_ext_get_actual_len(ex),
				      ext4_ext_pblock(ex),
				      ext4_ext_is_unwritten(ex) ?
					      EXTENT_STATUS_UNWRITTEN :
					      EXTENT_STATUS_WRITTEN,
				      false);
}

Caching the newly initialized on-disk extent conflicts with the still
unwritten mapped sub-range in i_es_tree and triggers an
"ES cache extent failed" warning via ext4_warning_inode().

> +
>  	err = ext4_ext_dirty(handle, inode, path + depth);
>  	if (err)
>  		return err;

[Severity: Medium]
Should the ext4_es_insert_extent() loop run after ext4_ext_dirty()
succeeds?

If ext4_ext_dirty() fails, zeroed[] has already been marked
EXTENT_STATUS_WRITTEN in i_es_tree even though the zeroout fallback
aborts.  In addition, when depth > 0, ext4_ext_get_access() clears
BH_Verified on path[depth].p_bh and ext4_ext_mark_initialized(ex) mutates
ex->ee_len before ext4_ext_dirty() recomputes the extent block checksum
and restores BH_Verified.  With ES_AGGRESSIVE_TEST enabled,
ext4_es_insert_extent() -> ext4_es_insert_extent_ext_check() ->
ext4_find_extent() re-reads the unverified leaf block with a stale
checksum and triggers a false -EFSBADCRC filesystem error.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261127-ext4-endio-zero-bug-v2-0-4106968e4d15@linux.ibm.com?part=11

  reply	other threads:[~2026-11-27 19:32 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
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 [this message]
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-238163@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.