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 37CCB29AAFA for ; Wed, 25 Feb 2026 02:57:33 +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=1771988253; cv=none; b=l/XtFebdILWpoy4RBKxac3OUkZwX3AwHj38E3rk+qWvp9zlxW/QBdmjSg0rQEEa7qd+nsPbySwtk8S7zYGsJSQLjnF9IU8AzguOQrw4WCmfkQQ7DLzmtRJdpED2Y0h1FzHJpYt/w7y0HXAYhuWSWpkjBxwRlHmlPxnJcv6XdXhQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771988253; c=relaxed/simple; bh=m2nHBsN9YUCg/Uo6Y95EWfzLyt2sxTa0o/3ER9j0JgQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cWUs++FVMY2DGldEOlFS6zHGIz83G60XnPsNe8nkCcwqLqzgz3+4CeNKvcmxw5pAGhX1uxw8ToTXVFc8FnU/yFMAd8XrPNzOZFXFowrTISiGgiUbGfQeEsJKezk5HTCgnIPIHgAJosBs5dWyPosvZPJlaiHFPsaasSgUFP2TFCE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j97hUp9c; 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="j97hUp9c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B235C19422; Wed, 25 Feb 2026 02:57:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771988252; bh=m2nHBsN9YUCg/Uo6Y95EWfzLyt2sxTa0o/3ER9j0JgQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j97hUp9cC7fR6Jsnr4+HpdmgGBI4LdgljAUEeG/c6kMxVUz6D7+t/Pdu9SXvkUPhQ 5m4otCwKBpYVVWCdhomyJ9Oc46UEe0AzmpZQfS2+wzIBtwMj3QR1OM5C/TMV2Ct4Rz V4N6pgfGNOy92a68L32GEL2oVA87TctXWGYHzK04wriE5p4OB0nteJAlv22vQQW3RF YUkrQY/n7tDIY6d2PZmhQ3GBZzIT77e71L1kNTf0Ym6KeM3WSHM6uG1zIcPppg5RjH 7GrxMoQjix5/j6IGwTiZb5KYVy4URIf0aHfC2ly/lGgedmaVbqLdHBPsw2tl+Hli2z U09ZiAQ62sSQQ== 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/6] ext4: get rid of ppath in ext4_ext_create_new_leaf() Date: Tue, 24 Feb 2026 21:57:25 -0500 Message-ID: <20260225025729.3839073-2-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260225025729.3839073-1-sashal@kernel.org> References: <2026022438-resample-unlit-c02b@gregkh> <20260225025729.3839073-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: 1bf6974822d1 ("ext4: don't zero the entire extent if EXT4_EXT_DATA_PARTIAL_VALID1") 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