@@ -4884,11 +4884,9 @@ static int ext4_fiemap_check_ranges(struct inode *inode, u64 start, u64 *len)
4884
4884
return 0 ;
4885
4885
}
4886
4886
4887
- static int _ext4_fiemap (struct inode * inode , struct fiemap_extent_info * fieinfo ,
4888
- __u64 start , __u64 len , bool from_es_cache )
4887
+ int ext4_fiemap (struct inode * inode , struct fiemap_extent_info * fieinfo ,
4888
+ u64 start , u64 len )
4889
4889
{
4890
- ext4_lblk_t start_blk ;
4891
- u32 ext4_fiemap_flags = FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR ;
4892
4890
int error = 0 ;
4893
4891
4894
4892
if (fieinfo -> fi_flags & FIEMAP_FLAG_CACHE ) {
@@ -4898,10 +4896,7 @@ static int _ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
4898
4896
fieinfo -> fi_flags &= ~FIEMAP_FLAG_CACHE ;
4899
4897
}
4900
4898
4901
- if (from_es_cache )
4902
- ext4_fiemap_flags &= FIEMAP_FLAG_XATTR ;
4903
-
4904
- if (fiemap_check_flags (fieinfo , ext4_fiemap_flags ))
4899
+ if (fiemap_check_flags (fieinfo , FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR ))
4905
4900
return - EBADR ;
4906
4901
4907
4902
/*
@@ -4915,40 +4910,20 @@ static int _ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
4915
4910
4916
4911
if (fieinfo -> fi_flags & FIEMAP_FLAG_XATTR ) {
4917
4912
fieinfo -> fi_flags &= ~FIEMAP_FLAG_XATTR ;
4918
- error = iomap_fiemap (inode , fieinfo , start , len ,
4919
- & ext4_iomap_xattr_ops );
4920
- } else if (!from_es_cache ) {
4921
- error = iomap_fiemap (inode , fieinfo , start , len ,
4922
- & ext4_iomap_report_ops );
4923
- } else {
4924
- ext4_lblk_t len_blks ;
4925
- __u64 last_blk ;
4926
-
4927
- start_blk = start >> inode -> i_sb -> s_blocksize_bits ;
4928
- last_blk = (start + len - 1 ) >> inode -> i_sb -> s_blocksize_bits ;
4929
- if (last_blk >= EXT_MAX_BLOCKS )
4930
- last_blk = EXT_MAX_BLOCKS - 1 ;
4931
- len_blks = ((ext4_lblk_t ) last_blk ) - start_blk + 1 ;
4932
-
4933
- /*
4934
- * Walk the extent tree gathering extent information
4935
- * and pushing extents back to the user.
4936
- */
4937
- error = ext4_fill_es_cache_info (inode , start_blk , len_blks ,
4938
- fieinfo );
4913
+ return iomap_fiemap (inode , fieinfo , start , len ,
4914
+ & ext4_iomap_xattr_ops );
4939
4915
}
4940
- return error ;
4941
- }
4942
4916
4943
- int ext4_fiemap (struct inode * inode , struct fiemap_extent_info * fieinfo ,
4944
- __u64 start , __u64 len )
4945
- {
4946
- return _ext4_fiemap (inode , fieinfo , start , len , false);
4917
+ return iomap_fiemap (inode , fieinfo , start , len , & ext4_iomap_report_ops );
4947
4918
}
4948
4919
4949
4920
int ext4_get_es_cache (struct inode * inode , struct fiemap_extent_info * fieinfo ,
4950
4921
__u64 start , __u64 len )
4951
4922
{
4923
+ ext4_lblk_t start_blk , len_blks ;
4924
+ __u64 last_blk ;
4925
+ int error = 0 ;
4926
+
4952
4927
if (ext4_has_inline_data (inode )) {
4953
4928
int has_inline ;
4954
4929
@@ -4959,9 +4934,32 @@ int ext4_get_es_cache(struct inode *inode, struct fiemap_extent_info *fieinfo,
4959
4934
return 0 ;
4960
4935
}
4961
4936
4962
- return _ext4_fiemap (inode , fieinfo , start , len , true);
4963
- }
4937
+ if (fieinfo -> fi_flags & FIEMAP_FLAG_CACHE ) {
4938
+ error = ext4_ext_precache (inode );
4939
+ if (error )
4940
+ return error ;
4941
+ fieinfo -> fi_flags &= ~FIEMAP_FLAG_CACHE ;
4942
+ }
4943
+
4944
+ if (fiemap_check_flags (fieinfo , FIEMAP_FLAG_SYNC ))
4945
+ return - EBADR ;
4964
4946
4947
+ error = ext4_fiemap_check_ranges (inode , start , & len );
4948
+ if (error )
4949
+ return error ;
4950
+
4951
+ start_blk = start >> inode -> i_sb -> s_blocksize_bits ;
4952
+ last_blk = (start + len - 1 ) >> inode -> i_sb -> s_blocksize_bits ;
4953
+ if (last_blk >= EXT_MAX_BLOCKS )
4954
+ last_blk = EXT_MAX_BLOCKS - 1 ;
4955
+ len_blks = ((ext4_lblk_t ) last_blk ) - start_blk + 1 ;
4956
+
4957
+ /*
4958
+ * Walk the extent tree gathering extent information
4959
+ * and pushing extents back to the user.
4960
+ */
4961
+ return ext4_fill_es_cache_info (inode , start_blk , len_blks , fieinfo );
4962
+ }
4965
4963
4966
4964
/*
4967
4965
* ext4_access_path:
0 commit comments