3434xfs_rmap_lookup_le (
3535 struct xfs_btree_cur * cur ,
3636 xfs_agblock_t bno ,
37- xfs_extlen_t len ,
3837 uint64_t owner ,
3938 uint64_t offset ,
4039 unsigned int flags ,
40+ struct xfs_rmap_irec * irec ,
4141 int * stat )
4242{
43+ int get_stat = 0 ;
44+ int error ;
45+
4346 cur -> bc_rec .r .rm_startblock = bno ;
44- cur -> bc_rec .r .rm_blockcount = len ;
47+ cur -> bc_rec .r .rm_blockcount = 0 ;
4548 cur -> bc_rec .r .rm_owner = owner ;
4649 cur -> bc_rec .r .rm_offset = offset ;
4750 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 ;
4963}
5064
5165/*
@@ -510,21 +524,14 @@ xfs_rmap_unmap(
510524 * for the AG headers at rm_startblock == 0 created by mkfs/growfs that
511525 * will not ever be removed from the tree.
512526 */
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 );
514528 if (error )
515529 goto out_error ;
516530 if (XFS_IS_CORRUPT (mp , i != 1 )) {
517531 error = - EFSCORRUPTED ;
518532 goto out_error ;
519533 }
520534
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- }
528535 trace_xfs_rmap_lookup_le_range_result (cur -> bc_mp ,
529536 cur -> bc_ag .pag -> pag_agno , ltrec .rm_startblock ,
530537 ltrec .rm_blockcount , ltrec .rm_owner ,
@@ -786,18 +793,11 @@ xfs_rmap_map(
786793 * record for our insertion point. This will also give us the record for
787794 * start block contiguity tests.
788795 */
789- error = xfs_rmap_lookup_le (cur , bno , len , owner , offset , flags ,
796+ error = xfs_rmap_lookup_le (cur , bno , owner , offset , flags , & ltrec ,
790797 & have_lt );
791798 if (error )
792799 goto out_error ;
793800 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- }
801801 trace_xfs_rmap_lookup_le_range_result (cur -> bc_mp ,
802802 cur -> bc_ag .pag -> pag_agno , ltrec .rm_startblock ,
803803 ltrec .rm_blockcount , ltrec .rm_owner ,
@@ -1022,21 +1022,14 @@ xfs_rmap_convert(
10221022 * record for our insertion point. This will also give us the record for
10231023 * start block contiguity tests.
10241024 */
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 );
10261026 if (error )
10271027 goto done ;
10281028 if (XFS_IS_CORRUPT (mp , i != 1 )) {
10291029 error = - EFSCORRUPTED ;
10301030 goto done ;
10311031 }
10321032
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- }
10401033 trace_xfs_rmap_lookup_le_range_result (cur -> bc_mp ,
10411034 cur -> bc_ag .pag -> pag_agno , PREV .rm_startblock ,
10421035 PREV .rm_blockcount , PREV .rm_owner ,
@@ -1140,7 +1133,7 @@ xfs_rmap_convert(
11401133 _RET_IP_ );
11411134
11421135 /* 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 );
11441137 if (error )
11451138 goto done ;
11461139 if (XFS_IS_CORRUPT (mp , i != 1 )) {
@@ -2677,7 +2670,7 @@ xfs_rmap_record_exists(
26772670 ASSERT (XFS_RMAP_NON_INODE_OWNER (owner ) ||
26782671 (flags & XFS_RMAP_BMBT_BLOCK ));
26792672
2680- error = xfs_rmap_lookup_le (cur , bno , len , owner , offset , flags ,
2673+ error = xfs_rmap_lookup_le (cur , bno , owner , offset , flags , & irec ,
26812674 & has_record );
26822675 if (error )
26832676 return error ;
@@ -2686,14 +2679,6 @@ xfs_rmap_record_exists(
26862679 return 0 ;
26872680 }
26882681
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-
26972682 * has_rmap = (irec .rm_owner == owner && irec .rm_startblock <= bno &&
26982683 irec .rm_startblock + irec .rm_blockcount >= bno + len );
26992684 return 0 ;
0 commit comments