From: Zhang Yi <yi.zhang@huaweicloud.com>
To: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Cc: Theodore Ts'o <tytso@mit.edu>,
Andreas Dilger <adilger.kernel@dilger.ca>,
Baokun Li <libaokun@linux.alibaba.com>, Jan Kara <jack@suse.cz>,
"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 02/13] ext4: introduce CONVERT_PENDING extent status type
Date: Wed, 2 Dec 2026 14:53:37 +0800 [thread overview]
Message-ID: <2edb1915-214d-4b53-ba90-a62fb511037d@huaweicloud.com> (raw)
In-Reply-To: <20261127-ext4-endio-zero-bug-v2-2-4106968e4d15@linux.ibm.com>
On 11/27/2026 11:10 PM, Ojaswin Mujoo wrote:
> Add support to track ranges that are in an unwritten state but actaully
> cover valid data. These are the unwritten ranges which have an in progress
> disk IO, but are not yet converted to written via endio handling.
>
> Upcoming patches will use this extent type to avoid zerooing out such
> ranges during endio extent splitting, because they cover valid data.
>
> The lifecycle of an extent undergoing write is now as follows:
>
> 1. Say we start with an extent (0,10,unwrit) which is also cached in es.
>
> Ondisk: [0,10,unwrit]
> es cache: [0,10,unwrit]
>
> 2. We perform a write to (0, 5):
>
> Ondisk: [0,10,unwrit]
> es cache: [0,5,conv_pending][5,10,unwrit]
>
> 3. IO is finished and endio handler converts (0,5) to written:
>
> ondisk: [0,5,writ][5,10,unwrit]
> es cache: [0,5,writ][5,10,unwrit]
>
> An extent of CONVERT_PENDING type will behave similar to an UNWRITTEN
> extent for most of the purposes like read. Just that we will take special
> care in es cache to make sure the conv_pending range is not split or merged
> so that we don't lose the status. Similarly, it also can't be evicted from
> memory because we don't want to lost the status.
>
> Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
> ---
> fs/ext4/extents_status-test.c | 8 ++++----
> fs/ext4/extents_status.c | 18 ++++++++++++++++++
> fs/ext4/extents_status.h | 11 ++++++++++-
> include/trace/events/ext4.h | 4 +++-
> 4 files changed, 35 insertions(+), 6 deletions(-)
>
> diff --git a/fs/ext4/extents_status-test.c b/fs/ext4/extents_status-test.c
> index 825d12513e4a..014475bae07c 100644
> --- a/fs/ext4/extents_status-test.c
> +++ b/fs/ext4/extents_status-test.c
> @@ -452,13 +452,13 @@ static void test_es_bitfield_written_and_unwritten_encoding(struct kunit *test)
> static void test_es_bitfield_delayed_and_hole_encoding(struct kunit *test)
> {
> struct extent_status es = {};
> - /* 59-bit physical block field (64 - 5 status bits) all ones */
> - const ext4_fsblk_t max_59bit_pblk = 0x07ffffffffffffffULL;
> + /* 58-bit physical block field (64 - 6 status bits) all ones */
> + const ext4_fsblk_t max_pblk = ~ES_MASK;
>
> ext4_es_store_pblock_status(&es, ~0ULL, EXTENT_STATUS_DELAYED);
> KUNIT_EXPECT_TRUE(test, ext4_es_is_delayed(&es));
> KUNIT_EXPECT_FALSE(test, ext4_es_is_mapped(&es));
> - KUNIT_EXPECT_EQ(test, ext4_es_pblock(&es), max_59bit_pblk);
> + KUNIT_EXPECT_EQ(test, ext4_es_pblock(&es), max_pblk);
> KUNIT_EXPECT_EQ(test, ext4_es_show_pblock(&es), 0ULL);
>
> ext4_es_store_pblock_status(&es, 0ULL, EXTENT_STATUS_HOLE);
> @@ -472,7 +472,7 @@ test_es_bitfield_referenced_and_pblock_update_preserve_state(struct kunit *test)
> {
> struct extent_status es = {};
> const ext4_fsblk_t initial_pblk = 0x123456789abcULL;
> - const ext4_fsblk_t updated_pblk = 0x07ffffffffffffffULL;
> + const ext4_fsblk_t updated_pblk = ~ES_MASK;
>
> ext4_es_store_pblock_status(&es, initial_pblk, EXTENT_STATUS_WRITTEN);
>
> diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
> index b7fb8502f9d4..28528f19be1d 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;
> }
>
> @@ -594,6 +597,12 @@ static int ext4_es_can_be_merged(struct extent_status *es1,
> if (ext4_es_type(es1) != ext4_es_type(es2))
> return 0;
>
> + /*
> + * Don't merge block range that's about to get converted to written.
> + */
> + if (ext4_es_is_convert_pending(es1))
> + return 0;
Why can't we merge two consecutive pending extents? AFAIK, we should
only need to ensure they are not merged with normal unwritten extents,
right?
Thanks,
Yi.
next prev parent reply other threads:[~2026-12-02 6:53 UTC|newest]
Thread overview: 17+ 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-12-02 6:53 ` Zhang Yi [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 15:10 ` [PATCH v2 05/13] ext4: add support to track convert pending ranges in ext4_map_blocks() Ojaswin Mujoo
2026-12-02 11:03 ` Zhang Yi
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 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 15:10 ` [PATCH v2 08/13] ext4: add tracking for unwritten to-be-converted ranges in " Ojaswin Mujoo
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 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
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=2edb1915-214d-4b53-ba90-a62fb511037d@huaweicloud.com \
--to=yi.zhang@huaweicloud.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=libaokun@linux.alibaba.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®