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 ED0ED2BDC13 for ; Wed, 25 Feb 2026 03:42:28 +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=1771990949; cv=none; b=K0+b3TDKh8ZkUq8gzk98SXoSS5CzsqsxzRFkFxRUE/SbFid6GeA8E94DRHNYmM3D+nr2hVCbMi4TaHGwH/1di1pqUCseq7LvvlgQYfiOdytltxdRi5w8Jgn7edECxm9f8Y7+ZbZFsMVZYl2CFUxFdx45xs5Bdr3mU3CxqQHExKs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771990949; c=relaxed/simple; bh=LkHwemKWjnwkHBom2agN2rR/+akoNW3zaiT1WHoCsq0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=koBU9kAe54blv5DCau6j0Q/te66bfnn0nG3gqaH/++OuFQjPzT3Xcuyflas0UwziYA84g5pBE/f4rmanblzWEaNG3NMPhZvTbeT9upcQfqOORqNRyu0PfY/alsRAq1ob8pV/ep+MfMpEJSnJrutYp9U37TvUTlf6RpzYEnLwsgU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oBoAtppL; 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="oBoAtppL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39150C19421; Wed, 25 Feb 2026 03:42:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771990948; bh=LkHwemKWjnwkHBom2agN2rR/+akoNW3zaiT1WHoCsq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oBoAtppLfzm3ok66jYnvEhvHunzffHKqEy1L0RDoIms1WWmPKS/R5/wDBU1UNCJi/ 7yvLtd85RwlDR9NAcLh+UoQzVpFERJrqQtPWaB+Aiw13S39gpzcC1UtbAHta3BMl9Q AtWw+sgzDMeQ0XZ4noc7TYB04e5QAY1vwoVZtR3wRs+fl0A6lR62g9tGt7ZGO4cLjk rLdHew8XGdcVBgh8mw06FQS/oR/mh9AKGXM8leLin9K0MjpCswelO3+IWbWwZL0qlG dRhCRO8WGkzqHc1Zx6Gjfo+LRlBdZlhyXf9MtqXFrtflwEY8F8hVh9q2NgP6KWvP4j MugUKsIifKgTw== From: Sasha Levin To: stable@vger.kernel.org Cc: Baokun Li , Jan Kara , Ojaswin Mujoo , Theodore Ts'o , Sasha Levin Subject: [PATCH 6.6.y 2/5] ext4: get rid of ppath in ext4_ext_create_new_leaf() Date: Tue, 24 Feb 2026 22:42:22 -0500 Message-ID: <20260225034225.3893579-2-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260225034225.3893579-1-sashal@kernel.org> References: <2026022428-ranged-scrabble-b28b@gregkh> <20260225034225.3893579-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: Baokun Li [ Upstream commit a000bc8678cc2bb10a5b80b4e991e77c7b4612fd ] The use of path and ppath is now very confusing, so to make the code more readable, pass path between functions uniformly, and get rid of ppath. To get rid of the ppath in ext4_ext_create_new_leaf(), the following is done here: * Free the extents path when an error is encountered. * Its caller needs to update ppath if it uses ppath. No functional changes. Signed-off-by: Baokun Li Reviewed-by: Jan Kara Reviewed-by: Ojaswin Mujoo Tested-by: Ojaswin Mujoo Link: https://patch.msgid.link/20240822023545.1994557-14-libaokun@huaweicloud.com Signed-off-by: Theodore Ts'o Stable-dep-of: 79b592e8f1b4 ("ext4: drop extent cache when splitting extent fails") Signed-off-by: Sasha Levin --- fs/ext4/extents.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 9644a9203152c..27db7c752dafd 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -1392,13 +1392,12 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode, * finds empty index and adds new leaf. * if no free index is found, then it requests in-depth growing. */ -static int ext4_ext_create_new_leaf(handle_t *handle, struct inode *inode, - unsigned int mb_flags, - unsigned int gb_flags, - struct ext4_ext_path **ppath, - struct ext4_extent *newext) +static struct ext4_ext_path * +ext4_ext_create_new_leaf(handle_t *handle, struct inode *inode, + unsigned int mb_flags, unsigned int gb_flags, + struct ext4_ext_path *path, + struct ext4_extent *newext) { - struct ext4_ext_path *path = *ppath; struct ext4_ext_path *curp; int depth, i, err = 0; @@ -1419,28 +1418,25 @@ static int ext4_ext_create_new_leaf(handle_t *handle, struct inode *inode, * entry: create all needed subtree and add new leaf */ err = ext4_ext_split(handle, inode, mb_flags, path, newext, i); if (err) - goto out; + goto errout; /* refill path */ path = ext4_find_extent(inode, (ext4_lblk_t)le32_to_cpu(newext->ee_block), path, gb_flags); - if (IS_ERR(path)) - err = PTR_ERR(path); + return path; } else { /* tree is full, time to grow in depth */ err = ext4_ext_grow_indepth(handle, inode, mb_flags); if (err) - goto out; + goto errout; /* refill path */ path = ext4_find_extent(inode, (ext4_lblk_t)le32_to_cpu(newext->ee_block), path, gb_flags); - if (IS_ERR(path)) { - err = PTR_ERR(path); - goto out; - } + if (IS_ERR(path)) + return path; /* * only first (depth 0 -> 1) produces free space; @@ -1452,9 +1448,11 @@ static int ext4_ext_create_new_leaf(handle_t *handle, struct inode *inode, goto repeat; } } -out: - *ppath = IS_ERR(path) ? NULL : path; - return err; + return path; + +errout: + ext4_free_ext_path(path); + return ERR_PTR(err); } /* @@ -2097,11 +2095,14 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode, */ if (gb_flags & EXT4_GET_BLOCKS_METADATA_NOFAIL) mb_flags |= EXT4_MB_USE_RESERVED; - err = ext4_ext_create_new_leaf(handle, inode, mb_flags, gb_flags, - ppath, newext); - if (err) + path = ext4_ext_create_new_leaf(handle, inode, mb_flags, gb_flags, + path, newext); + if (IS_ERR(path)) { + *ppath = NULL; + err = PTR_ERR(path); goto cleanup; - path = *ppath; + } + *ppath = path; depth = ext_depth(inode); eh = path[depth].p_hdr; -- 2.51.0