Skip to content

Commit 8d5ad7b

Browse files
LiBaokun96tytso
authored andcommitted
ext4: get rid of ppath in ext4_convert_unwritten_extents_endio()
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_convert_unwritten_extents_endio(), 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 <[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 225057b commit 8d5ad7b

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

fs/ext4/extents.c

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3746,12 +3746,11 @@ static struct ext4_ext_path *ext4_split_convert_extents(handle_t *handle,
37463746
allocated);
37473747
}
37483748

3749-
static int ext4_convert_unwritten_extents_endio(handle_t *handle,
3750-
struct inode *inode,
3751-
struct ext4_map_blocks *map,
3752-
struct ext4_ext_path **ppath)
3749+
static struct ext4_ext_path *
3750+
ext4_convert_unwritten_extents_endio(handle_t *handle, struct inode *inode,
3751+
struct ext4_map_blocks *map,
3752+
struct ext4_ext_path *path)
37533753
{
3754-
struct ext4_ext_path *path = *ppath;
37553754
struct ext4_extent *ex;
37563755
ext4_lblk_t ee_block;
37573756
unsigned int ee_len;
@@ -3781,24 +3780,19 @@ static int ext4_convert_unwritten_extents_endio(handle_t *handle,
37813780
#endif
37823781
path = ext4_split_convert_extents(handle, inode, map, path,
37833782
EXT4_GET_BLOCKS_CONVERT, NULL);
3784-
if (IS_ERR(path)) {
3785-
*ppath = NULL;
3786-
return PTR_ERR(path);
3787-
}
3783+
if (IS_ERR(path))
3784+
return path;
37883785

37893786
path = ext4_find_extent(inode, map->m_lblk, path, 0);
3790-
if (IS_ERR(path)) {
3791-
*ppath = NULL;
3792-
return PTR_ERR(path);
3793-
}
3794-
*ppath = path;
3787+
if (IS_ERR(path))
3788+
return path;
37953789
depth = ext_depth(inode);
37963790
ex = path[depth].p_ext;
37973791
}
37983792

37993793
err = ext4_ext_get_access(handle, inode, path + depth);
38003794
if (err)
3801-
goto out;
3795+
goto errout;
38023796
/* first mark the extent as initialized */
38033797
ext4_ext_mark_initialized(ex);
38043798

@@ -3809,9 +3803,15 @@ static int ext4_convert_unwritten_extents_endio(handle_t *handle,
38093803

38103804
/* Mark modified extent as dirty */
38113805
err = ext4_ext_dirty(handle, inode, path + path->p_depth);
3812-
out:
3806+
if (err)
3807+
goto errout;
3808+
38133809
ext4_ext_show_leaf(inode, path);
3814-
return err;
3810+
return path;
3811+
3812+
errout:
3813+
ext4_free_ext_path(path);
3814+
return ERR_PTR(err);
38153815
}
38163816

38173817
static int
@@ -3939,10 +3939,13 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode,
39393939
}
39403940
/* IO end_io complete, convert the filled extent to written */
39413941
if (flags & EXT4_GET_BLOCKS_CONVERT) {
3942-
err = ext4_convert_unwritten_extents_endio(handle, inode, map,
3943-
ppath);
3944-
if (err < 0)
3942+
*ppath = ext4_convert_unwritten_extents_endio(handle, inode,
3943+
map, *ppath);
3944+
if (IS_ERR(*ppath)) {
3945+
err = PTR_ERR(*ppath);
3946+
*ppath = NULL;
39453947
goto out2;
3948+
}
39463949
ext4_update_inode_fsync_trans(handle, inode, 1);
39473950
goto map_out;
39483951
}

0 commit comments

Comments
 (0)