From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Zhang Yi <yi.zhang@huawei.com>, Baokun Li <libaokun1@huawei.com>,
stable@kernel.org, Ojaswin Mujoo <ojaswin@linux.ibm.com>,
Theodore Ts'o <tytso@mit.edu>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.1.y 6/6] ext4: drop extent cache when splitting extent fails
Date: Wed, 25 Feb 2026 08:22:53 -0500 [thread overview]
Message-ID: <20260225132253.222588-6-sashal@kernel.org> (raw)
In-Reply-To: <20260225132253.222588-1-sashal@kernel.org>
From: Zhang Yi <yi.zhang@huawei.com>
[ Upstream commit 79b592e8f1b435796cbc2722190368e3e8ffd7a1 ]
When the split extent fails, we might leave some extents still being
processed and return an error directly, which will result in stale
extent entries remaining in the extent status tree. So drop all of the
remaining potentially stale extents if the splitting fails.
Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Baokun Li <libaokun1@huawei.com>
Cc: stable@kernel.org
Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Message-ID: <20251129103247.686136-8-yi.zhang@huaweicloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/ext4/extents.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 476fa4bc351a0..90f0610cfbc0c 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3243,7 +3243,7 @@ static struct ext4_ext_path *ext4_split_extent_at(handle_t *handle,
err = PTR_ERR(path);
if (err != -ENOSPC && err != -EDQUOT && err != -ENOMEM)
- return path;
+ goto out_path;
/*
* Get a new path to try to zeroout or fix the extent length.
@@ -3257,7 +3257,7 @@ static struct ext4_ext_path *ext4_split_extent_at(handle_t *handle,
if (IS_ERR(path)) {
EXT4_ERROR_INODE(inode, "Failed split extent on %u, err %ld",
split, PTR_ERR(path));
- return path;
+ goto out_path;
}
depth = ext_depth(inode);
ex = path[depth].p_ext;
@@ -3317,6 +3317,10 @@ static struct ext4_ext_path *ext4_split_extent_at(handle_t *handle,
ext4_free_ext_path(path);
path = ERR_PTR(err);
}
+out_path:
+ if (IS_ERR(path))
+ /* Remove all remaining potentially stale extents. */
+ ext4_es_remove_extent(inode, ee_block, ee_len);
ext4_ext_show_leaf(inode, path);
return path;
}
--
2.51.0
prev parent reply other threads:[~2026-02-25 13:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 21:44 FAILED: patch "[PATCH] ext4: drop extent cache when splitting extent fails" failed to apply to 6.1-stable tree gregkh
2026-02-25 13:22 ` [PATCH 6.1.y 1/6] ext4: make ext4_es_remove_extent() return void Sasha Levin
2026-02-25 13:22 ` [PATCH 6.1.y 2/6] ext4: get rid of ppath in ext4_find_extent() Sasha Levin
2026-02-25 13:22 ` [PATCH 6.1.y 3/6] ext4: get rid of ppath in ext4_ext_create_new_leaf() Sasha Levin
2026-02-25 13:22 ` [PATCH 6.1.y 4/6] ext4: get rid of ppath in ext4_ext_insert_extent() Sasha Levin
2026-02-25 13:22 ` [PATCH 6.1.y 5/6] ext4: get rid of ppath in ext4_split_extent_at() Sasha Levin
2026-02-25 13:22 ` Sasha Levin [this message]
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=20260225132253.222588-6-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=libaokun1@huawei.com \
--cc=ojaswin@linux.ibm.com \
--cc=stable@kernel.org \
--cc=stable@vger.kernel.org \
--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