From: Ojaswin Mujoo <ojaswin@linux.ibm.com>
To: "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>,
Zhang Yi <yi.zhang@huawei.com>
Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 11/13] ext4: update extent status cache when zeroing extents
Date: Fri, 27 Nov 2026 20:40:58 +0530 [thread overview]
Message-ID: <20261127-ext4-endio-zero-bug-v2-11-4106968e4d15@linux.ibm.com> (raw)
In-Reply-To: <20261127-ext4-endio-zero-bug-v2-0-4106968e4d15@linux.ibm.com>
In case of zeroout fallback, make sure to mark the zeroed ranges as written
in the extent status tree. Be careful of only doing so once we are sure the
zeroout has succeeded and we have converted the extent to written.
Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
---
fs/ext4/extents.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 0f5d9f3c42a9..e8ebc518e58b 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];
depth = ext_depth(inode);
ex = path[depth].p_ext;
@@ -3397,6 +3404,10 @@ static int ext4_split_extent_zeroout(handle_t *handle, struct inode *inode,
if (err)
/* ZEROOUT failed, just return original error */
return err;
+
+ zeroed[nr_zeroed].lblk = lblk;
+ zeroed[nr_zeroed].len = len;
+ zeroed[nr_zeroed++].pblk = pblk;
}
/* zeroout right */
@@ -3413,6 +3424,10 @@ static int ext4_split_extent_zeroout(handle_t *handle, struct inode *inode,
if (err)
/* ZEROOUT failed, just return original error */
return err;
+
+ zeroed[nr_zeroed].lblk = lblk;
+ zeroed[nr_zeroed].len = len;
+ zeroed[nr_zeroed++].pblk = pblk;
}
} else if (flags & EXT4_GET_BLOCKS_CONVERT_UNWRITTEN) {
/*
@@ -3435,6 +3450,10 @@ static int ext4_split_extent_zeroout(handle_t *handle, struct inode *inode,
if (err)
/* ZEROOUT failed, just return original error */
return err;
+
+ zeroed[nr_zeroed].lblk = lblk;
+ zeroed[nr_zeroed].len = len;
+ zeroed[nr_zeroed++].pblk = pblk;
} else {
/*
* We no longer perform unwritten to unwritten splits in IO paths.
@@ -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);
+
err = ext4_ext_dirty(handle, inode, path + depth);
if (err)
return err;
--
2.55.0
next prev parent reply other threads:[~2026-11-27 15:12 UTC|newest]
Thread overview: 14+ 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:10 ` [PATCH v2 03/13] ext4: preserve convert pending extents when adding unwrit extents to es cache Ojaswin Mujoo
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-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 ` Ojaswin Mujoo [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
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=20261127-ext4-endio-zero-bug-v2-11-4106968e4d15@linux.ibm.com \
--to=ojaswin@linux.ibm.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=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
--cc=yi.zhang@huawei.com \
/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®