34
34
xfs_rmap_lookup_le (
35
35
struct xfs_btree_cur * cur ,
36
36
xfs_agblock_t bno ,
37
- xfs_extlen_t len ,
38
37
uint64_t owner ,
39
38
uint64_t offset ,
40
39
unsigned int flags ,
40
+ struct xfs_rmap_irec * irec ,
41
41
int * stat )
42
42
{
43
+ int get_stat = 0 ;
44
+ int error ;
45
+
43
46
cur -> bc_rec .r .rm_startblock = bno ;
44
- cur -> bc_rec .r .rm_blockcount = len ;
47
+ cur -> bc_rec .r .rm_blockcount = 0 ;
45
48
cur -> bc_rec .r .rm_owner = owner ;
46
49
cur -> bc_rec .r .rm_offset = offset ;
47
50
cur -> bc_rec .r .rm_flags = flags ;
48
- return xfs_btree_lookup (cur , XFS_LOOKUP_LE , stat );
51
+
52
+ error = xfs_btree_lookup (cur , XFS_LOOKUP_LE , stat );
53
+ if (error || !(* stat ) || !irec )
54
+ return error ;
55
+
56
+ error = xfs_rmap_get_rec (cur , irec , & get_stat );
57
+ if (error )
58
+ return error ;
59
+ if (!get_stat )
60
+ return - EFSCORRUPTED ;
61
+
62
+ return 0 ;
49
63
}
50
64
51
65
/*
@@ -510,21 +524,14 @@ xfs_rmap_unmap(
510
524
* for the AG headers at rm_startblock == 0 created by mkfs/growfs that
511
525
* will not ever be removed from the tree.
512
526
*/
513
- error = xfs_rmap_lookup_le (cur , bno , len , owner , offset , flags , & i );
527
+ error = xfs_rmap_lookup_le (cur , bno , owner , offset , flags , & ltrec , & i );
514
528
if (error )
515
529
goto out_error ;
516
530
if (XFS_IS_CORRUPT (mp , i != 1 )) {
517
531
error = - EFSCORRUPTED ;
518
532
goto out_error ;
519
533
}
520
534
521
- error = xfs_rmap_get_rec (cur , & ltrec , & i );
522
- if (error )
523
- goto out_error ;
524
- if (XFS_IS_CORRUPT (mp , i != 1 )) {
525
- error = - EFSCORRUPTED ;
526
- goto out_error ;
527
- }
528
535
trace_xfs_rmap_lookup_le_range_result (cur -> bc_mp ,
529
536
cur -> bc_ag .pag -> pag_agno , ltrec .rm_startblock ,
530
537
ltrec .rm_blockcount , ltrec .rm_owner ,
@@ -786,18 +793,11 @@ xfs_rmap_map(
786
793
* record for our insertion point. This will also give us the record for
787
794
* start block contiguity tests.
788
795
*/
789
- error = xfs_rmap_lookup_le (cur , bno , len , owner , offset , flags ,
796
+ error = xfs_rmap_lookup_le (cur , bno , owner , offset , flags , & ltrec ,
790
797
& have_lt );
791
798
if (error )
792
799
goto out_error ;
793
800
if (have_lt ) {
794
- error = xfs_rmap_get_rec (cur , & ltrec , & have_lt );
795
- if (error )
796
- goto out_error ;
797
- if (XFS_IS_CORRUPT (mp , have_lt != 1 )) {
798
- error = - EFSCORRUPTED ;
799
- goto out_error ;
800
- }
801
801
trace_xfs_rmap_lookup_le_range_result (cur -> bc_mp ,
802
802
cur -> bc_ag .pag -> pag_agno , ltrec .rm_startblock ,
803
803
ltrec .rm_blockcount , ltrec .rm_owner ,
@@ -1022,21 +1022,14 @@ xfs_rmap_convert(
1022
1022
* record for our insertion point. This will also give us the record for
1023
1023
* start block contiguity tests.
1024
1024
*/
1025
- error = xfs_rmap_lookup_le (cur , bno , len , owner , offset , oldext , & i );
1025
+ error = xfs_rmap_lookup_le (cur , bno , owner , offset , oldext , & PREV , & i );
1026
1026
if (error )
1027
1027
goto done ;
1028
1028
if (XFS_IS_CORRUPT (mp , i != 1 )) {
1029
1029
error = - EFSCORRUPTED ;
1030
1030
goto done ;
1031
1031
}
1032
1032
1033
- error = xfs_rmap_get_rec (cur , & PREV , & i );
1034
- if (error )
1035
- goto done ;
1036
- if (XFS_IS_CORRUPT (mp , i != 1 )) {
1037
- error = - EFSCORRUPTED ;
1038
- goto done ;
1039
- }
1040
1033
trace_xfs_rmap_lookup_le_range_result (cur -> bc_mp ,
1041
1034
cur -> bc_ag .pag -> pag_agno , PREV .rm_startblock ,
1042
1035
PREV .rm_blockcount , PREV .rm_owner ,
@@ -1140,7 +1133,7 @@ xfs_rmap_convert(
1140
1133
_RET_IP_ );
1141
1134
1142
1135
/* reset the cursor back to PREV */
1143
- error = xfs_rmap_lookup_le (cur , bno , len , owner , offset , oldext , & i );
1136
+ error = xfs_rmap_lookup_le (cur , bno , owner , offset , oldext , NULL , & i );
1144
1137
if (error )
1145
1138
goto done ;
1146
1139
if (XFS_IS_CORRUPT (mp , i != 1 )) {
@@ -2677,7 +2670,7 @@ xfs_rmap_record_exists(
2677
2670
ASSERT (XFS_RMAP_NON_INODE_OWNER (owner ) ||
2678
2671
(flags & XFS_RMAP_BMBT_BLOCK ));
2679
2672
2680
- error = xfs_rmap_lookup_le (cur , bno , len , owner , offset , flags ,
2673
+ error = xfs_rmap_lookup_le (cur , bno , owner , offset , flags , & irec ,
2681
2674
& has_record );
2682
2675
if (error )
2683
2676
return error ;
@@ -2686,14 +2679,6 @@ xfs_rmap_record_exists(
2686
2679
return 0 ;
2687
2680
}
2688
2681
2689
- error = xfs_rmap_get_rec (cur , & irec , & has_record );
2690
- if (error )
2691
- return error ;
2692
- if (!has_record ) {
2693
- * has_rmap = false;
2694
- return 0 ;
2695
- }
2696
-
2697
2682
* has_rmap = (irec .rm_owner == owner && irec .rm_startblock <= bno &&
2698
2683
irec .rm_startblock + irec .rm_blockcount >= bno + len );
2699
2684
return 0 ;
0 commit comments