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 439AC2F7478; Wed, 25 Feb 2026 06:59:38 +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=1772002778; cv=none; b=cWE9PT3ZUuSofT7M0Z0FeEMgzymK8C1Wwj0np93mqCciLGUBX5VO3t2FhrskNmifbhwoY4gG8uZkb9ZWH1wk6SKWNm4g5CzIz8ItHK+/eJoy1/8IraBpjDMo3xYijfa025AM+gvldk6vGzlyi8WlBZLD1ief7z7kHes5/T9+FK8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772002778; c=relaxed/simple; bh=QECNRYnKIoFTD8Y+3RnOJOVHWkYtPSu88TZ5lbayHAE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TaTB2b1wPS0iobWPoO3DVVdNDzupa76BTtSks3vRDWXJSj5mMIUiXnLBJ6uIf1+cGO6GM3Jsgb6lU5iMtZTH5KUgNR33vXF8KHP4Dda5RPYjuT9BGZBuFxDoderXFouaNlVltnHXm2tftks7UjXMLlQO6DGA2RjqVeWlzrCU40I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=VBeuSv5I; 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="VBeuSv5I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A5C8C116D0; Wed, 25 Feb 2026 06:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1772002778; bh=QECNRYnKIoFTD8Y+3RnOJOVHWkYtPSu88TZ5lbayHAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VBeuSv5IUWXYmKfPLGqmuM2/cV2I7oxicC8xTfETjG6AwJYAIQ1MN7ruHbzpVymIW MxO7CnfCA6zviYCoFjFy0gprAO2tXhjHD2WMH5GHyrjHD91V0eDY/Z3yHm9naa89aP HJ6sUQ8GieY3SaGmp8yhn1AC8NpfefkU8BCSE+w4= 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 Subject: [PATCH 6.18 616/641] ext4: drop extent cache when splitting extent fails Date: Tue, 24 Feb 2026 17:25:42 -0800 Message-ID: <20260225012403.437364610@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260225012348.915798704@linuxfoundation.org> References: <20260225012348.915798704@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhang Yi commit 79b592e8f1b435796cbc2722190368e3e8ffd7a1 upstream. 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: Greg Kroah-Hartman --- fs/ext4/extents.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -3267,7 +3267,7 @@ static struct ext4_ext_path *ext4_split_ 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. @@ -3281,7 +3281,7 @@ static struct ext4_ext_path *ext4_split_ 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; @@ -3358,6 +3358,10 @@ out: 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; }