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 06/13] ext4: add tracking for unwritten to-be-converted ranges in dio write path
Date: Fri, 27 Nov 2026 17:48:50 +0000	[thread overview]
Message-ID: <sashiko-outbox-238015@kernel.org> (raw)
In-Reply-To: <20261127-ext4-endio-zero-bug-v2-6-4106968e4d15@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] ext4: fragmented CONVERT_PENDING es entries break atomic DIO
  writes
--

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

ext4: add tracking for unwritten to-be-converted ranges in dio write path

This commit passes EXT4_GET_BLOCKS_CONVERT_PENDING in the direct I/O write
mapping paths to track unwritten ranges in the extent status tree while
I/O is in flight, and adds ext4_clear_convert_pending().

> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 3e4c0e1396ab1..4aafd0aaea699 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
[ ... ]
> @@ -4012,7 +4043,8 @@ static int ext4_iomap_alloc(struct inode *inode, struct ext4_map_blocks *map,
>  	else if (EXT4_LBLK_TO_B(inode, map->m_lblk) >= i_size_read(inode))
>  		m_flags = EXT4_GET_BLOCKS_CREATE;
>  	else if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
> -		m_flags = EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT;
> +		m_flags = EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT |
> +			  EXT4_GET_BLOCKS_CONVERT_PENDING;
>  
>  	if (flags & IOMAP_ATOMIC)
>  		ret = ext4_map_blocks_atomic_write(handle, inode, map, m_flags,
> @@ -4082,7 +4114,10 @@ int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
>  		 * especially in multi-threaded overwrite requests.
>  		 */
>  		if (offset + length <= i_size_read(inode)) {
> -			ret = ext4_map_blocks(NULL, inode, &map, 0);
> +			ret = ext4_map_blocks(NULL, inode, &map,
> +					      (flags & IOMAP_DAX) ?
> +					      0 :
> +					      EXT4_GET_BLOCKS_CONVERT_PENDING);
>  			/*
>  			 * For DAX we convert extents to initialized ones before
>  			 * copying the data, otherwise we do it after I/O so

[Severity: High]
Can marking sub-ranges as EXTENT_STATUS_CONVERT_PENDING split a contiguous
on-disk unwritten extent in i_es_tree and break multi-block IOMAP_ATOMIC
writes?

ext4_es_can_be_merged() rejects merging whenever either entry is
convert-pending or the status types differ.  When a sub-range of a
contiguous unwritten extent is marked EXTENT_STATUS_CONVERT_PENDING (from
a concurrent sub-range DIO write, an earlier failed DIO write, or an
IOMAP_NOWAIT lookup that marks a partial unwritten prefix here before
failing with -EAGAIN in ext4_iomap_alloc()), i_es_tree splits the cached
extent into separate entries.

A subsequent multi-block IOMAP_ATOMIC write across that range hits only
the first entry in ext4_es_lookup_extent(), clamping map.m_len to a value
smaller than orig_mlen.  In ext4_iomap_begin(), ret == orig_mlen fails and
skips the fast path (causing RWF_ATOMIC | RWF_NOWAIT on a fully allocated
unwritten extent to fail with -EAGAIN in ext4_iomap_alloc()).

For blocking IOMAP_ATOMIC writes, ext4_map_blocks_atomic_write() also sees
ret < m_len, treats the contiguous on-disk unwritten extent as a mixed
mapping, forces a transaction commit, and falls back to
ext4_map_blocks_atomic_write_slow().  That slow path maps with
EXT4_GET_BLOCKS_CREATE_ZERO, which converts the unwritten blocks to
initialized and synchronously writes zeroes to disk via
ext4_issue_zeroout() before the atomic write BIO is submitted, overwriting
any concurrent in-flight DIO write on the CONVERT_PENDING range.

In addition, if concurrent sub-range DIO lookups split an in-flight atomic
write's unwritten range into more than two CONVERT_PENDING entries in
i_es_tree, the loop in ext4_convert_unwritten_extents_atomic() clamps each
ext4_map_blocks() call to a single ES fragment and performs more than the
two extent conversions for which it reserved journal credits.

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

  reply	other threads:[~2026-11-27 17:48 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 [this message]
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-238015@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.