From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0E36370D6E; Mon, 23 Mar 2026 14:54:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774277643; cv=none; b=s2gyHNS//bMwzqwq82qkIo7FUp66vHaXw7TyRe/1+HocFrC4tRFSrhP3JL2YQUBUnwZ4wL17uaMlVzvC5zrhfl8F4wahR7yaSJWOw4dhTg5Cbsu8c1DowhbMxVOdFkZriuZofAUauLlkTtmBQzXnht3htGYKucXwEf250Edt3sI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774277643; c=relaxed/simple; bh=COgQoufovMOs1AF6UTlvknWupYudhfS2gs3G7xoC4pI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oF4g/smM1gqBafaSx4jveWwyIulDVAmd0sW2uSSzPX+A78Bkz/2wKos3YSxO5W/IL4hXefTwqiIm14M4Mk+RnSaqUA6+OE+kZtscPTJHJB8gqrp7A6sRibqCBSaejoBDskhZWXEQmY5l8znDbrBKh8dP5oebsuCjJNvbDtjYFfw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=RbFKr0hO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="RbFKr0hO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72057C4CEF7; Mon, 23 Mar 2026 14:54:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774277642; bh=COgQoufovMOs1AF6UTlvknWupYudhfS2gs3G7xoC4pI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RbFKr0hOEbbxKv2wO+gkFDWyvGnjICt8lKg7+D/XBbrkekO+AvSDUaI6fHeZYMSVf uSnKM2hFZny2pwCOZwPYoGVqy1yGC/5a99eSUYkLbXowKXSsGBGWwM4pERAQejfFr9 WnobIF9QU5OpwKp6QROTJ5T9h4e9pAaTvGT3UhOw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhang Yi , Baokun Li , stable@kernel.org, Ojaswin Mujoo , Theodore Tso , Sasha Levin Subject: [PATCH 6.6 058/567] ext4: drop extent cache when splitting extent fails Date: Mon, 23 Mar 2026 14:39:38 +0100 Message-ID: <20260323134535.249060200@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260323134533.749096647@linuxfoundation.org> References: <20260323134533.749096647@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhang Yi [ 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 Reviewed-by: Baokun Li Cc: stable@kernel.org Reviewed-by: Ojaswin Mujoo Message-ID: <20251129103247.686136-8-yi.zhang@huaweicloud.com> Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- 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 2818d297ce464..b7e9cbe832121 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -3250,7 +3250,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. @@ -3264,7 +3264,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; @@ -3341,6 +3341,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