Skip to content

Commit 4191eef

Browse files
LiBaokun96tytso
authored andcommitted
ext4: get rid of ppath in convert_initialized_extent()
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 convert_initialized_extent(), the following is done here: * Free the extents path when an error is encountered. No functional changes. Signed-off-by: Baokun Li <[email protected]> Reviewed-by: Jan Kara <[email protected]> Reviewed-by: Ojaswin Mujoo <[email protected]> Tested-by: Ojaswin Mujoo <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 2ec2e10 commit 4191eef

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

fs/ext4/extents.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3811,13 +3811,12 @@ ext4_convert_unwritten_extents_endio(handle_t *handle, struct inode *inode,
38113811
return ERR_PTR(err);
38123812
}
38133813

3814-
static int
3814+
static struct ext4_ext_path *
38153815
convert_initialized_extent(handle_t *handle, struct inode *inode,
38163816
struct ext4_map_blocks *map,
3817-
struct ext4_ext_path **ppath,
3817+
struct ext4_ext_path *path,
38183818
unsigned int *allocated)
38193819
{
3820-
struct ext4_ext_path *path = *ppath;
38213820
struct ext4_extent *ex;
38223821
ext4_lblk_t ee_block;
38233822
unsigned int ee_len;
@@ -3842,29 +3841,25 @@ convert_initialized_extent(handle_t *handle, struct inode *inode,
38423841
if (ee_block != map->m_lblk || ee_len > map->m_len) {
38433842
path = ext4_split_convert_extents(handle, inode, map, path,
38443843
EXT4_GET_BLOCKS_CONVERT_UNWRITTEN, NULL);
3845-
if (IS_ERR(path)) {
3846-
*ppath = NULL;
3847-
return PTR_ERR(path);
3848-
}
3844+
if (IS_ERR(path))
3845+
return path;
38493846

38503847
path = ext4_find_extent(inode, map->m_lblk, path, 0);
3851-
if (IS_ERR(path)) {
3852-
*ppath = NULL;
3853-
return PTR_ERR(path);
3854-
}
3855-
*ppath = path;
3848+
if (IS_ERR(path))
3849+
return path;
38563850
depth = ext_depth(inode);
38573851
ex = path[depth].p_ext;
38583852
if (!ex) {
38593853
EXT4_ERROR_INODE(inode, "unexpected hole at %lu",
38603854
(unsigned long) map->m_lblk);
3861-
return -EFSCORRUPTED;
3855+
err = -EFSCORRUPTED;
3856+
goto errout;
38623857
}
38633858
}
38643859

38653860
err = ext4_ext_get_access(handle, inode, path + depth);
38663861
if (err)
3867-
return err;
3862+
goto errout;
38683863
/* first mark the extent as unwritten */
38693864
ext4_ext_mark_unwritten(ex);
38703865

@@ -3876,7 +3871,7 @@ convert_initialized_extent(handle_t *handle, struct inode *inode,
38763871
/* Mark modified extent as dirty */
38773872
err = ext4_ext_dirty(handle, inode, path + path->p_depth);
38783873
if (err)
3879-
return err;
3874+
goto errout;
38803875
ext4_ext_show_leaf(inode, path);
38813876

38823877
ext4_update_inode_fsync_trans(handle, inode, 1);
@@ -3885,7 +3880,11 @@ convert_initialized_extent(handle_t *handle, struct inode *inode,
38853880
if (*allocated > map->m_len)
38863881
*allocated = map->m_len;
38873882
map->m_len = *allocated;
3888-
return 0;
3883+
return path;
3884+
3885+
errout:
3886+
ext4_free_ext_path(path);
3887+
return ERR_PTR(err);
38893888
}
38903889

38913890
static struct ext4_ext_path *
@@ -4256,8 +4255,10 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
42564255
*/
42574256
if ((!ext4_ext_is_unwritten(ex)) &&
42584257
(flags & EXT4_GET_BLOCKS_CONVERT_UNWRITTEN)) {
4259-
err = convert_initialized_extent(handle,
4260-
inode, map, &path, &allocated);
4258+
path = convert_initialized_extent(handle,
4259+
inode, map, path, &allocated);
4260+
if (IS_ERR(path))
4261+
err = PTR_ERR(path);
42614262
goto out;
42624263
} else if (!ext4_ext_is_unwritten(ex)) {
42634264
map->m_flags |= EXT4_MAP_MAPPED;

0 commit comments

Comments
 (0)