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 949FB34F49A for ; Wed, 25 Feb 2026 13:23:00 +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=1772025780; cv=none; b=H8SSB3LJ3gbrEDo8XAdN+5jwOu1OYXJ4tEFIACivue82bUOAHF5oLxtGjgzXRiN5ZUeLOEqIEvGPh0rOv6TlfEbEryO1gXG0rclINHOsBGPg+UQZV/geisV2JXTFVKQmA/pZrAhhtKptbwvFqpcSiYVYZZxTbNcY6uukWBLwsk0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772025780; c=relaxed/simple; bh=IkhQBdz0Cfak7HkfTBSOnR/e+loyobCIap58GfNd2aQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s1kn1I/nAqvfgjrtETVvBnGp0pYUdsE+S9kN53hXKO8wluFTX3ITJcYKTzcVyItgYQX32j5bBrjdGi1vs84kiRIfPfcuEFoel098WimRIq5oH8iqnDRFa4rHn0f3M8e3GDjxs4HMM42fOfQNpmVwquBvIcmkSTwhpQktgpp3nJ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HXrA5crc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HXrA5crc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73A4DC116D0; Wed, 25 Feb 2026 13:22:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772025780; bh=IkhQBdz0Cfak7HkfTBSOnR/e+loyobCIap58GfNd2aQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HXrA5crclGFttBuJLofj1xazJD0+o4+bVc6YciQj05zGU/x06bIEIJNJKml/XjWii TtOxRxZaPErYaWazz9rQ5Z/cDMojpm/bzck4x50O0p5DHhsVJYICzpR0gSpmffcnAp ZFN1O0nTp0FhdN1LO0g0AudkaiR0K4X0BgF6Qbrq0kAZuL81O00sCEw/mxtOoCH9Jl yKK/YEzXE1o96hZWF4ytqIv472iDc2XEk8JMcf1i9LybRo0sYWqWrGPBKmgyH3QU7P 1khrDGafDxAgo2WPLP2rYarh13+rdt2qB4QdauZiIfQgVSi9rVK91/k+fW3HBhZ2pV JuK8cpM9l5mtA== From: Sasha Levin To: stable@vger.kernel.org Cc: Zhang Yi , Baokun Li , stable@kernel.org, Ojaswin Mujoo , Theodore Ts'o , Sasha Levin Subject: [PATCH 6.1.y 6/6] ext4: drop extent cache when splitting extent fails Date: Wed, 25 Feb 2026 08:22:53 -0500 Message-ID: <20260225132253.222588-6-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260225132253.222588-1-sashal@kernel.org> References: <2026022428-arrogant-refill-c828@gregkh> <20260225132253.222588-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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