diff options
author | Christoph Hellwig <hch@lst.de> | 2009-08-31 19:58:21 -0400 |
---|---|---|
committer | Felix Blyakher <felixb@sgi.com> | 2009-09-01 13:45:39 -0400 |
commit | 2187550525d7bcb8c87689e4eca41b1955bf9ac3 (patch) | |
tree | 1538be459d9d37a9daf537885e93a3cf20ee49c8 /fs/xfs/xfs_ialloc.c | |
parent | 4254b0bbb1c0826b7443ffa593576696bc591aa2 (diff) |
xfs: rationalize xfs_inobt_lookup*
Currenly we have a xfs_inobt_lookup* variant for each comparism direction,
and all these get all three fields of the inobt records passed, while the
common case is just looking for the inode number and we have only marginally
more callers than xfs_inobt_lookup* variants.
So opencode a direct call to xfs_btree_lookup for the single case where we
need all fields, and replace xfs_inobt_lookup* with a xfs_inobt_looku that
just takes the inode number and the direction for all other callers.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Alex Elder <aelder@sgi.com>
Signed-off-by: Felix Blyakher <felixb@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_ialloc.c')
-rw-r--r-- | fs/xfs/xfs_ialloc.c | 77 |
1 files changed, 22 insertions, 55 deletions
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c index 7679c1633053..748637cd70ff 100644 --- a/fs/xfs/xfs_ialloc.c +++ b/fs/xfs/xfs_ialloc.c | |||
@@ -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 | STATIC int /* error */ | 62 | STATIC int /* error */ |
63 | xfs_inobt_lookup_eq( | 63 | xfs_inobt_lookup( |
64 | struct xfs_btree_cur *cur, /* btree cursor */ | 64 | struct xfs_btree_cur *cur, /* btree cursor */ |
65 | xfs_agino_t ino, /* starting inode of chunk */ | 65 | xfs_agino_t ino, /* starting inode of chunk */ |
66 | __int32_t fcnt, /* free inode count */ | 66 | xfs_lookup_t dir, /* <=, >=, == */ |
67 | xfs_inofree_t free, /* free inode mask */ | ||
68 | int *stat) /* success/failure */ | 67 | int *stat) /* success/failure */ |
69 | { | 68 | { |
70 | cur->bc_rec.i.ir_startino = ino; | 69 | cur->bc_rec.i.ir_startino = ino; |
71 | cur->bc_rec.i.ir_freecount = fcnt; | 70 | cur->bc_rec.i.ir_freecount = 0; |
72 | cur->bc_rec.i.ir_free = free; | 71 | cur->bc_rec.i.ir_free = 0; |
73 | return xfs_btree_lookup(cur, XFS_LOOKUP_EQ, stat); | 72 | return xfs_btree_lookup(cur, dir, 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); | ||
110 | } | 73 | } |
111 | 74 | ||
112 | /* | 75 | /* |
@@ -162,7 +125,7 @@ xfs_check_agi_freecount( | |||
162 | int error; | 125 | int error; |
163 | int i; | 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 | if (error) | 129 | if (error) |
167 | return error; | 130 | return error; |
168 | 131 | ||
@@ -431,13 +394,17 @@ xfs_ialloc_ag_alloc( | |||
431 | for (thisino = newino; | 394 | for (thisino = newino; |
432 | thisino < newino + newlen; | 395 | thisino < newino + newlen; |
433 | thisino += XFS_INODES_PER_CHUNK) { | 396 | thisino += XFS_INODES_PER_CHUNK) { |
434 | if ((error = xfs_inobt_lookup_eq(cur, thisino, | 397 | cur->bc_rec.i.ir_startino = thisino; |
435 | XFS_INODES_PER_CHUNK, XFS_INOBT_ALL_FREE, &i))) { | 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 | xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); | 402 | xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); |
437 | return error; | 403 | return error; |
438 | } | 404 | } |
439 | ASSERT(i == 0); | 405 | ASSERT(i == 0); |
440 | if ((error = xfs_btree_insert(cur, &i))) { | 406 | error = xfs_btree_insert(cur, &i); |
407 | if (error) { | ||
441 | xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); | 408 | xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); |
442 | return error; | 409 | return error; |
443 | } | 410 | } |
@@ -818,7 +785,7 @@ nextag: | |||
818 | int doneleft; /* done, to the left */ | 785 | int doneleft; /* done, to the left */ |
819 | int doneright; /* done, to the right */ | 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 | if (error) | 789 | if (error) |
823 | goto error0; | 790 | goto error0; |
824 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); | 791 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); |
@@ -904,8 +871,8 @@ nextag: | |||
904 | * See if the most recently allocated block has any free. | 871 | * See if the most recently allocated block has any free. |
905 | */ | 872 | */ |
906 | else if (be32_to_cpu(agi->agi_newino) != NULLAGINO) { | 873 | else if (be32_to_cpu(agi->agi_newino) != NULLAGINO) { |
907 | error = xfs_inobt_lookup_eq(cur, be32_to_cpu(agi->agi_newino), | 874 | error = xfs_inobt_lookup(cur, be32_to_cpu(agi->agi_newino), |
908 | 0, 0, &i); | 875 | XFS_LOOKUP_EQ, &i); |
909 | if (error) | 876 | if (error) |
910 | goto error0; | 877 | goto error0; |
911 | 878 | ||
@@ -926,7 +893,7 @@ nextag: | |||
926 | /* | 893 | /* |
927 | * None left in the last group, search the whole AG | 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 | if (error) | 897 | if (error) |
931 | goto error0; | 898 | goto error0; |
932 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); | 899 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); |
@@ -1065,9 +1032,9 @@ xfs_difree( | |||
1065 | /* | 1032 | /* |
1066 | * Look for the entry describing this inode. | 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 | cmn_err(CE_WARN, | 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 | error, mp->m_fsname); | 1038 | error, mp->m_fsname); |
1072 | goto error0; | 1039 | goto error0; |
1073 | } | 1040 | } |
@@ -1277,10 +1244,10 @@ xfs_imap( | |||
1277 | } | 1244 | } |
1278 | 1245 | ||
1279 | cur = xfs_inobt_init_cursor(mp, tp, agbp, agno); | 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 | if (error) { | 1248 | if (error) { |
1282 | xfs_fs_cmn_err(CE_ALERT, mp, "xfs_imap: " | 1249 | xfs_fs_cmn_err(CE_ALERT, mp, "xfs_imap: " |
1283 | "xfs_inobt_lookup_le() failed"); | 1250 | "xfs_inobt_lookup() failed"); |
1284 | goto error0; | 1251 | goto error0; |
1285 | } | 1252 | } |
1286 | 1253 | ||