@@ -5663,25 +5663,21 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
5663
5663
int e1_len , e2_len , len ;
5664
5664
int split = 0 ;
5665
5665
5666
- path1 = ext4_find_extent (inode1 , lblk1 , NULL , EXT4_EX_NOCACHE );
5666
+ path1 = ext4_find_extent (inode1 , lblk1 , path1 , EXT4_EX_NOCACHE );
5667
5667
if (IS_ERR (path1 )) {
5668
5668
* erp = PTR_ERR (path1 );
5669
- path1 = NULL ;
5670
- finish :
5671
- count = 0 ;
5672
- goto repeat ;
5669
+ goto errout ;
5673
5670
}
5674
- path2 = ext4_find_extent (inode2 , lblk2 , NULL , EXT4_EX_NOCACHE );
5671
+ path2 = ext4_find_extent (inode2 , lblk2 , path2 , EXT4_EX_NOCACHE );
5675
5672
if (IS_ERR (path2 )) {
5676
5673
* erp = PTR_ERR (path2 );
5677
- path2 = NULL ;
5678
- goto finish ;
5674
+ goto errout ;
5679
5675
}
5680
5676
ex1 = path1 [path1 -> p_depth ].p_ext ;
5681
5677
ex2 = path2 [path2 -> p_depth ].p_ext ;
5682
5678
/* Do we have something to swap ? */
5683
5679
if (unlikely (!ex2 || !ex1 ))
5684
- goto finish ;
5680
+ goto errout ;
5685
5681
5686
5682
e1_blk = le32_to_cpu (ex1 -> ee_block );
5687
5683
e2_blk = le32_to_cpu (ex2 -> ee_block );
@@ -5703,7 +5699,7 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
5703
5699
next2 = e2_blk ;
5704
5700
/* Do we have something to swap */
5705
5701
if (next1 == EXT_MAX_BLOCKS || next2 == EXT_MAX_BLOCKS )
5706
- goto finish ;
5702
+ goto errout ;
5707
5703
/* Move to the rightest boundary */
5708
5704
len = next1 - lblk1 ;
5709
5705
if (len < next2 - lblk2 )
@@ -5713,7 +5709,7 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
5713
5709
lblk1 += len ;
5714
5710
lblk2 += len ;
5715
5711
count -= len ;
5716
- goto repeat ;
5712
+ continue ;
5717
5713
}
5718
5714
5719
5715
/* Prepare left boundary */
@@ -5723,7 +5719,7 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
5723
5719
path1 , lblk1 , 0 );
5724
5720
if (IS_ERR (path1 )) {
5725
5721
* erp = PTR_ERR (path1 );
5726
- goto finish ;
5722
+ goto errout ;
5727
5723
}
5728
5724
}
5729
5725
if (e2_blk < lblk2 ) {
@@ -5732,13 +5728,13 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
5732
5728
path2 , lblk2 , 0 );
5733
5729
if (IS_ERR (path2 )) {
5734
5730
* erp = PTR_ERR (path2 );
5735
- goto finish ;
5731
+ goto errout ;
5736
5732
}
5737
5733
}
5738
5734
/* ext4_split_extent_at() may result in leaf extent split,
5739
5735
* path must to be revalidated. */
5740
5736
if (split )
5741
- goto repeat ;
5737
+ continue ;
5742
5738
5743
5739
/* Prepare right boundary */
5744
5740
len = count ;
@@ -5753,7 +5749,7 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
5753
5749
path1 , lblk1 + len , 0 );
5754
5750
if (IS_ERR (path1 )) {
5755
5751
* erp = PTR_ERR (path1 );
5756
- goto finish ;
5752
+ goto errout ;
5757
5753
}
5758
5754
}
5759
5755
if (len != e2_len ) {
@@ -5762,21 +5758,21 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
5762
5758
path2 , lblk2 + len , 0 );
5763
5759
if (IS_ERR (path2 )) {
5764
5760
* erp = PTR_ERR (path2 );
5765
- goto finish ;
5761
+ goto errout ;
5766
5762
}
5767
5763
}
5768
5764
/* ext4_split_extent_at() may result in leaf extent split,
5769
5765
* path must to be revalidated. */
5770
5766
if (split )
5771
- goto repeat ;
5767
+ continue ;
5772
5768
5773
5769
BUG_ON (e2_len != e1_len );
5774
5770
* erp = ext4_ext_get_access (handle , inode1 , path1 + path1 -> p_depth );
5775
5771
if (unlikely (* erp ))
5776
- goto finish ;
5772
+ goto errout ;
5777
5773
* erp = ext4_ext_get_access (handle , inode2 , path2 + path2 -> p_depth );
5778
5774
if (unlikely (* erp ))
5779
- goto finish ;
5775
+ goto errout ;
5780
5776
5781
5777
/* Both extents are fully inside boundaries. Swap it now */
5782
5778
tmp_ex = * ex1 ;
@@ -5794,7 +5790,7 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
5794
5790
* erp = ext4_ext_dirty (handle , inode2 , path2 +
5795
5791
path2 -> p_depth );
5796
5792
if (unlikely (* erp ))
5797
- goto finish ;
5793
+ goto errout ;
5798
5794
* erp = ext4_ext_dirty (handle , inode1 , path1 +
5799
5795
path1 -> p_depth );
5800
5796
/*
@@ -5804,17 +5800,17 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
5804
5800
* aborted anyway.
5805
5801
*/
5806
5802
if (unlikely (* erp ))
5807
- goto finish ;
5803
+ goto errout ;
5804
+
5808
5805
lblk1 += len ;
5809
5806
lblk2 += len ;
5810
5807
replaced_count += len ;
5811
5808
count -= len ;
5812
-
5813
- repeat :
5814
- ext4_free_ext_path (path1 );
5815
- ext4_free_ext_path (path2 );
5816
- path1 = path2 = NULL ;
5817
5809
}
5810
+
5811
+ errout :
5812
+ ext4_free_ext_path (path1 );
5813
+ ext4_free_ext_path (path2 );
5818
5814
return replaced_count ;
5819
5815
}
5820
5816
0 commit comments