@@ -5663,25 +5663,21 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
56635663 int e1_len , e2_len , len ;
56645664 int split = 0 ;
56655665
5666- path1 = ext4_find_extent (inode1 , lblk1 , NULL , EXT4_EX_NOCACHE );
5666+ path1 = ext4_find_extent (inode1 , lblk1 , path1 , EXT4_EX_NOCACHE );
56675667 if (IS_ERR (path1 )) {
56685668 * erp = PTR_ERR (path1 );
5669- path1 = NULL ;
5670- finish :
5671- count = 0 ;
5672- goto repeat ;
5669+ goto errout ;
56735670 }
5674- path2 = ext4_find_extent (inode2 , lblk2 , NULL , EXT4_EX_NOCACHE );
5671+ path2 = ext4_find_extent (inode2 , lblk2 , path2 , EXT4_EX_NOCACHE );
56755672 if (IS_ERR (path2 )) {
56765673 * erp = PTR_ERR (path2 );
5677- path2 = NULL ;
5678- goto finish ;
5674+ goto errout ;
56795675 }
56805676 ex1 = path1 [path1 -> p_depth ].p_ext ;
56815677 ex2 = path2 [path2 -> p_depth ].p_ext ;
56825678 /* Do we have something to swap ? */
56835679 if (unlikely (!ex2 || !ex1 ))
5684- goto finish ;
5680+ goto errout ;
56855681
56865682 e1_blk = le32_to_cpu (ex1 -> ee_block );
56875683 e2_blk = le32_to_cpu (ex2 -> ee_block );
@@ -5703,7 +5699,7 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
57035699 next2 = e2_blk ;
57045700 /* Do we have something to swap */
57055701 if (next1 == EXT_MAX_BLOCKS || next2 == EXT_MAX_BLOCKS )
5706- goto finish ;
5702+ goto errout ;
57075703 /* Move to the rightest boundary */
57085704 len = next1 - lblk1 ;
57095705 if (len < next2 - lblk2 )
@@ -5713,7 +5709,7 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
57135709 lblk1 += len ;
57145710 lblk2 += len ;
57155711 count -= len ;
5716- goto repeat ;
5712+ continue ;
57175713 }
57185714
57195715 /* Prepare left boundary */
@@ -5723,7 +5719,7 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
57235719 path1 , lblk1 , 0 );
57245720 if (IS_ERR (path1 )) {
57255721 * erp = PTR_ERR (path1 );
5726- goto finish ;
5722+ goto errout ;
57275723 }
57285724 }
57295725 if (e2_blk < lblk2 ) {
@@ -5732,13 +5728,13 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
57325728 path2 , lblk2 , 0 );
57335729 if (IS_ERR (path2 )) {
57345730 * erp = PTR_ERR (path2 );
5735- goto finish ;
5731+ goto errout ;
57365732 }
57375733 }
57385734 /* ext4_split_extent_at() may result in leaf extent split,
57395735 * path must to be revalidated. */
57405736 if (split )
5741- goto repeat ;
5737+ continue ;
57425738
57435739 /* Prepare right boundary */
57445740 len = count ;
@@ -5753,7 +5749,7 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
57535749 path1 , lblk1 + len , 0 );
57545750 if (IS_ERR (path1 )) {
57555751 * erp = PTR_ERR (path1 );
5756- goto finish ;
5752+ goto errout ;
57575753 }
57585754 }
57595755 if (len != e2_len ) {
@@ -5762,21 +5758,21 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
57625758 path2 , lblk2 + len , 0 );
57635759 if (IS_ERR (path2 )) {
57645760 * erp = PTR_ERR (path2 );
5765- goto finish ;
5761+ goto errout ;
57665762 }
57675763 }
57685764 /* ext4_split_extent_at() may result in leaf extent split,
57695765 * path must to be revalidated. */
57705766 if (split )
5771- goto repeat ;
5767+ continue ;
57725768
57735769 BUG_ON (e2_len != e1_len );
57745770 * erp = ext4_ext_get_access (handle , inode1 , path1 + path1 -> p_depth );
57755771 if (unlikely (* erp ))
5776- goto finish ;
5772+ goto errout ;
57775773 * erp = ext4_ext_get_access (handle , inode2 , path2 + path2 -> p_depth );
57785774 if (unlikely (* erp ))
5779- goto finish ;
5775+ goto errout ;
57805776
57815777 /* Both extents are fully inside boundaries. Swap it now */
57825778 tmp_ex = * ex1 ;
@@ -5794,7 +5790,7 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
57945790 * erp = ext4_ext_dirty (handle , inode2 , path2 +
57955791 path2 -> p_depth );
57965792 if (unlikely (* erp ))
5797- goto finish ;
5793+ goto errout ;
57985794 * erp = ext4_ext_dirty (handle , inode1 , path1 +
57995795 path1 -> p_depth );
58005796 /*
@@ -5804,17 +5800,17 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
58045800 * aborted anyway.
58055801 */
58065802 if (unlikely (* erp ))
5807- goto finish ;
5803+ goto errout ;
5804+
58085805 lblk1 += len ;
58095806 lblk2 += len ;
58105807 replaced_count += len ;
58115808 count -= len ;
5812-
5813- repeat :
5814- ext4_free_ext_path (path1 );
5815- ext4_free_ext_path (path2 );
5816- path1 = path2 = NULL ;
58175809 }
5810+
5811+ errout :
5812+ ext4_free_ext_path (path1 );
5813+ ext4_free_ext_path (path2 );
58185814 return replaced_count ;
58195815}
58205816
0 commit comments