@@ -884,11 +884,10 @@ void ext4_ext_tree_init(handle_t *handle, struct inode *inode)
884884
885885struct ext4_ext_path *
886886ext4_find_extent (struct inode * inode , ext4_lblk_t block ,
887- struct ext4_ext_path * * orig_path , int flags )
887+ struct ext4_ext_path * path , int flags )
888888{
889889 struct ext4_extent_header * eh ;
890890 struct buffer_head * bh ;
891- struct ext4_ext_path * path = orig_path ? * orig_path : NULL ;
892891 short int depth , i , ppos = 0 ;
893892 int ret ;
894893 gfp_t gfp_flags = GFP_NOFS ;
@@ -909,7 +908,7 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block,
909908 ext4_ext_drop_refs (path );
910909 if (depth > path [0 ].p_maxdepth ) {
911910 kfree (path );
912- * orig_path = path = NULL ;
911+ path = NULL ;
913912 }
914913 }
915914 if (!path ) {
@@ -960,14 +959,10 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block,
960959
961960 ext4_ext_show_path (inode , path );
962961
963- if (orig_path )
964- * orig_path = path ;
965962 return path ;
966963
967964err :
968965 ext4_free_ext_path (path );
969- if (orig_path )
970- * orig_path = NULL ;
971966 return ERR_PTR (ret );
972967}
973968
@@ -1432,7 +1427,7 @@ static int ext4_ext_create_new_leaf(handle_t *handle, struct inode *inode,
14321427 /* refill path */
14331428 path = ext4_find_extent (inode ,
14341429 (ext4_lblk_t )le32_to_cpu (newext -> ee_block ),
1435- ppath , gb_flags );
1430+ path , gb_flags );
14361431 if (IS_ERR (path ))
14371432 err = PTR_ERR (path );
14381433 } else {
@@ -1444,7 +1439,7 @@ static int ext4_ext_create_new_leaf(handle_t *handle, struct inode *inode,
14441439 /* refill path */
14451440 path = ext4_find_extent (inode ,
14461441 (ext4_lblk_t )le32_to_cpu (newext -> ee_block ),
1447- ppath , gb_flags );
1442+ path , gb_flags );
14481443 if (IS_ERR (path )) {
14491444 err = PTR_ERR (path );
14501445 goto out ;
@@ -1460,8 +1455,8 @@ static int ext4_ext_create_new_leaf(handle_t *handle, struct inode *inode,
14601455 goto repeat ;
14611456 }
14621457 }
1463-
14641458out :
1459+ * ppath = IS_ERR (path ) ? NULL : path ;
14651460 return err ;
14661461}
14671462
@@ -3263,15 +3258,17 @@ static int ext4_split_extent_at(handle_t *handle,
32633258 * WARN_ON may be triggered in ext4_da_update_reserve_space() due to
32643259 * an incorrect ee_len causing the i_reserved_data_blocks exception.
32653260 */
3266- path = ext4_find_extent (inode , ee_block , ppath ,
3261+ path = ext4_find_extent (inode , ee_block , * ppath ,
32673262 flags | EXT4_EX_NOFAIL );
32683263 if (IS_ERR (path )) {
32693264 EXT4_ERROR_INODE (inode , "Failed split extent on %u, err %ld" ,
32703265 split , PTR_ERR (path ));
3266+ * ppath = NULL ;
32713267 return PTR_ERR (path );
32723268 }
32733269 depth = ext_depth (inode );
32743270 ex = path [depth ].p_ext ;
3271+ * ppath = path ;
32753272
32763273 if (EXT4_EXT_MAY_ZEROOUT & split_flag ) {
32773274 if (split_flag & (EXT4_EXT_DATA_VALID1 |EXT4_EXT_DATA_VALID2 )) {
@@ -3381,9 +3378,12 @@ static int ext4_split_extent(handle_t *handle,
33813378 * Update path is required because previous ext4_split_extent_at() may
33823379 * result in split of original leaf or extent zeroout.
33833380 */
3384- path = ext4_find_extent (inode , map -> m_lblk , ppath , flags );
3385- if (IS_ERR (path ))
3381+ path = ext4_find_extent (inode , map -> m_lblk , * ppath , flags );
3382+ if (IS_ERR (path )) {
3383+ * ppath = NULL ;
33863384 return PTR_ERR (path );
3385+ }
3386+ * ppath = path ;
33873387 depth = ext_depth (inode );
33883388 ex = path [depth ].p_ext ;
33893389 if (!ex ) {
@@ -3769,9 +3769,12 @@ static int ext4_convert_unwritten_extents_endio(handle_t *handle,
37693769 EXT4_GET_BLOCKS_CONVERT );
37703770 if (err < 0 )
37713771 return err ;
3772- path = ext4_find_extent (inode , map -> m_lblk , ppath , 0 );
3773- if (IS_ERR (path ))
3772+ path = ext4_find_extent (inode , map -> m_lblk , * ppath , 0 );
3773+ if (IS_ERR (path )) {
3774+ * ppath = NULL ;
37743775 return PTR_ERR (path );
3776+ }
3777+ * ppath = path ;
37753778 depth = ext_depth (inode );
37763779 ex = path [depth ].p_ext ;
37773780 }
@@ -3827,9 +3830,12 @@ convert_initialized_extent(handle_t *handle, struct inode *inode,
38273830 EXT4_GET_BLOCKS_CONVERT_UNWRITTEN );
38283831 if (err < 0 )
38293832 return err ;
3830- path = ext4_find_extent (inode , map -> m_lblk , ppath , 0 );
3831- if (IS_ERR (path ))
3833+ path = ext4_find_extent (inode , map -> m_lblk , * ppath , 0 );
3834+ if (IS_ERR (path )) {
3835+ * ppath = NULL ;
38323836 return PTR_ERR (path );
3837+ }
3838+ * ppath = path ;
38333839 depth = ext_depth (inode );
38343840 ex = path [depth ].p_ext ;
38353841 if (!ex ) {
@@ -5190,7 +5196,7 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
51905196 * won't be shifted beyond EXT_MAX_BLOCKS.
51915197 */
51925198 if (SHIFT == SHIFT_LEFT ) {
5193- path = ext4_find_extent (inode , start - 1 , & path ,
5199+ path = ext4_find_extent (inode , start - 1 , path ,
51945200 EXT4_EX_NOCACHE );
51955201 if (IS_ERR (path ))
51965202 return PTR_ERR (path );
@@ -5239,7 +5245,7 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
52395245 * becomes NULL to indicate the end of the loop.
52405246 */
52415247 while (iterator && start <= stop ) {
5242- path = ext4_find_extent (inode , * iterator , & path ,
5248+ path = ext4_find_extent (inode , * iterator , path ,
52435249 EXT4_EX_NOCACHE );
52445250 if (IS_ERR (path ))
52455251 return PTR_ERR (path );
@@ -5821,11 +5827,8 @@ int ext4_clu_mapped(struct inode *inode, ext4_lblk_t lclu)
58215827
58225828 /* search for the extent closest to the first block in the cluster */
58235829 path = ext4_find_extent (inode , EXT4_C2B (sbi , lclu ), NULL , 0 );
5824- if (IS_ERR (path )) {
5825- err = PTR_ERR (path );
5826- path = NULL ;
5827- goto out ;
5828- }
5830+ if (IS_ERR (path ))
5831+ return PTR_ERR (path );
58295832
58305833 depth = ext_depth (inode );
58315834
@@ -5909,7 +5912,7 @@ int ext4_ext_replay_update_ex(struct inode *inode, ext4_lblk_t start,
59095912 if (ret )
59105913 goto out ;
59115914
5912- path = ext4_find_extent (inode , start , & path , 0 );
5915+ path = ext4_find_extent (inode , start , path , 0 );
59135916 if (IS_ERR (path ))
59145917 return PTR_ERR (path );
59155918 ex = path [path -> p_depth ].p_ext ;
@@ -5923,7 +5926,7 @@ int ext4_ext_replay_update_ex(struct inode *inode, ext4_lblk_t start,
59235926 if (ret )
59245927 goto out ;
59255928
5926- path = ext4_find_extent (inode , start , & path , 0 );
5929+ path = ext4_find_extent (inode , start , path , 0 );
59275930 if (IS_ERR (path ))
59285931 return PTR_ERR (path );
59295932 ex = path [path -> p_depth ].p_ext ;
0 commit comments