@@ -57,56 +57,19 @@ xfs_ialloc_cluster_alignment(
57
57
}
58
58
59
59
/*
60
- * Lookup the record equal to ino in the btree given by cur.
60
+ * Lookup a record by ino in the btree given by cur.
61
61
*/
62
62
STATIC int /* error */
63
- xfs_inobt_lookup_eq (
63
+ xfs_inobt_lookup (
64
64
struct xfs_btree_cur * cur , /* btree cursor */
65
65
xfs_agino_t ino , /* starting inode of chunk */
66
- __int32_t fcnt , /* free inode count */
67
- xfs_inofree_t free , /* free inode mask */
66
+ xfs_lookup_t dir , /* <=, >=, == */
68
67
int * stat ) /* success/failure */
69
68
{
70
69
cur -> bc_rec .i .ir_startino = ino ;
71
- cur -> bc_rec .i .ir_freecount = fcnt ;
72
- cur -> bc_rec .i .ir_free = free ;
73
- return xfs_btree_lookup (cur , XFS_LOOKUP_EQ , stat );
74
- }
75
-
76
- /*
77
- * Lookup the first record greater than or equal to ino
78
- * in the btree given by cur.
79
- */
80
- int /* error */
81
- xfs_inobt_lookup_ge (
82
- struct xfs_btree_cur * cur , /* btree cursor */
83
- xfs_agino_t ino , /* starting inode of chunk */
84
- __int32_t fcnt , /* free inode count */
85
- xfs_inofree_t free , /* free inode mask */
86
- int * stat ) /* success/failure */
87
- {
88
- cur -> bc_rec .i .ir_startino = ino ;
89
- cur -> bc_rec .i .ir_freecount = fcnt ;
90
- cur -> bc_rec .i .ir_free = free ;
91
- return xfs_btree_lookup (cur , XFS_LOOKUP_GE , stat );
92
- }
93
-
94
- /*
95
- * Lookup the first record less than or equal to ino
96
- * in the btree given by cur.
97
- */
98
- int /* error */
99
- xfs_inobt_lookup_le (
100
- struct xfs_btree_cur * cur , /* btree cursor */
101
- xfs_agino_t ino , /* starting inode of chunk */
102
- __int32_t fcnt , /* free inode count */
103
- xfs_inofree_t free , /* free inode mask */
104
- int * stat ) /* success/failure */
105
- {
106
- cur -> bc_rec .i .ir_startino = ino ;
107
- cur -> bc_rec .i .ir_freecount = fcnt ;
108
- cur -> bc_rec .i .ir_free = free ;
109
- return xfs_btree_lookup (cur , XFS_LOOKUP_LE , stat );
70
+ cur -> bc_rec .i .ir_freecount = 0 ;
71
+ cur -> bc_rec .i .ir_free = 0 ;
72
+ return xfs_btree_lookup (cur , dir , stat );
110
73
}
111
74
112
75
/*
@@ -162,7 +125,7 @@ xfs_check_agi_freecount(
162
125
int error ;
163
126
int i ;
164
127
165
- error = xfs_inobt_lookup_ge (cur , 0 , 0 , 0 , & i );
128
+ error = xfs_inobt_lookup (cur , 0 , XFS_LOOKUP_GE , & i );
166
129
if (error )
167
130
return error ;
168
131
@@ -431,13 +394,17 @@ xfs_ialloc_ag_alloc(
431
394
for (thisino = newino ;
432
395
thisino < newino + newlen ;
433
396
thisino += XFS_INODES_PER_CHUNK ) {
434
- if ((error = xfs_inobt_lookup_eq (cur , thisino ,
435
- XFS_INODES_PER_CHUNK , XFS_INOBT_ALL_FREE , & i ))) {
397
+ cur -> bc_rec .i .ir_startino = thisino ;
398
+ cur -> bc_rec .i .ir_freecount = XFS_INODES_PER_CHUNK ;
399
+ cur -> bc_rec .i .ir_free = XFS_INOBT_ALL_FREE ;
400
+ error = xfs_btree_lookup (cur , XFS_LOOKUP_EQ , & i );
401
+ if (error ) {
436
402
xfs_btree_del_cursor (cur , XFS_BTREE_ERROR );
437
403
return error ;
438
404
}
439
405
ASSERT (i == 0 );
440
- if ((error = xfs_btree_insert (cur , & i ))) {
406
+ error = xfs_btree_insert (cur , & i );
407
+ if (error ) {
441
408
xfs_btree_del_cursor (cur , XFS_BTREE_ERROR );
442
409
return error ;
443
410
}
@@ -818,7 +785,7 @@ xfs_dialloc(
818
785
int doneleft ; /* done, to the left */
819
786
int doneright ; /* done, to the right */
820
787
821
- error = xfs_inobt_lookup_le (cur , pagino , 0 , 0 , & i );
788
+ error = xfs_inobt_lookup (cur , pagino , XFS_LOOKUP_LE , & i );
822
789
if (error )
823
790
goto error0 ;
824
791
XFS_WANT_CORRUPTED_GOTO (i == 1 , error0 );
@@ -904,8 +871,8 @@ xfs_dialloc(
904
871
* See if the most recently allocated block has any free.
905
872
*/
906
873
else if (be32_to_cpu (agi -> agi_newino ) != NULLAGINO ) {
907
- error = xfs_inobt_lookup_eq (cur , be32_to_cpu (agi -> agi_newino ),
908
- 0 , 0 , & i );
874
+ error = xfs_inobt_lookup (cur , be32_to_cpu (agi -> agi_newino ),
875
+ XFS_LOOKUP_EQ , & i );
909
876
if (error )
910
877
goto error0 ;
911
878
@@ -926,7 +893,7 @@ xfs_dialloc(
926
893
/*
927
894
* None left in the last group, search the whole AG
928
895
*/
929
- error = xfs_inobt_lookup_ge (cur , 0 , 0 , 0 , & i );
896
+ error = xfs_inobt_lookup (cur , 0 , XFS_LOOKUP_GE , & i );
930
897
if (error )
931
898
goto error0 ;
932
899
XFS_WANT_CORRUPTED_GOTO (i == 1 , error0 );
@@ -1065,9 +1032,9 @@ xfs_difree(
1065
1032
/*
1066
1033
* Look for the entry describing this inode.
1067
1034
*/
1068
- if ((error = xfs_inobt_lookup_le (cur , agino , 0 , 0 , & i ))) {
1035
+ if ((error = xfs_inobt_lookup (cur , agino , XFS_LOOKUP_LE , & i ))) {
1069
1036
cmn_err (CE_WARN ,
1070
- "xfs_difree: xfs_inobt_lookup_le returned() an error %d on %s. Returning error." ,
1037
+ "xfs_difree: xfs_inobt_lookup returned() an error %d on %s. Returning error." ,
1071
1038
error , mp -> m_fsname );
1072
1039
goto error0 ;
1073
1040
}
@@ -1277,10 +1244,10 @@ xfs_imap(
1277
1244
}
1278
1245
1279
1246
cur = xfs_inobt_init_cursor (mp , tp , agbp , agno );
1280
- error = xfs_inobt_lookup_le (cur , agino , 0 , 0 , & i );
1247
+ error = xfs_inobt_lookup (cur , agino , XFS_LOOKUP_LE , & i );
1281
1248
if (error ) {
1282
1249
xfs_fs_cmn_err (CE_ALERT , mp , "xfs_imap: "
1283
- "xfs_inobt_lookup_le () failed" );
1250
+ "xfs_inobt_lookup () failed" );
1284
1251
goto error0 ;
1285
1252
}
1286
1253
0 commit comments