aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_ialloc.c77
-rw-r--r--fs/xfs/xfs_ialloc.h14
-rw-r--r--fs/xfs/xfs_itable.c12
3 files changed, 32 insertions, 71 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 */
62STATIC int /* error */ 62STATIC int /* error */
63xfs_inobt_lookup_eq( 63xfs_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 */
80int /* error */
81xfs_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 */
98int /* error */
99xfs_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
diff --git a/fs/xfs/xfs_ialloc.h b/fs/xfs/xfs_ialloc.h
index 52e72fe7e411..bb5385475e1f 100644
--- a/fs/xfs/xfs_ialloc.h
+++ b/fs/xfs/xfs_ialloc.h
@@ -150,18 +150,10 @@ xfs_ialloc_pagi_init(
150 xfs_agnumber_t agno); /* allocation group number */ 150 xfs_agnumber_t agno); /* allocation group number */
151 151
152/* 152/*
153 * Lookup the first record greater than or equal to ino 153 * Lookup a record by ino in the btree given by cur.
154 * in the btree given by cur.
155 */ 154 */
156int xfs_inobt_lookup_ge(struct xfs_btree_cur *cur, xfs_agino_t ino, 155int xfs_inobt_lookup(struct xfs_btree_cur *cur, xfs_agino_t ino,
157 __int32_t fcnt, xfs_inofree_t free, int *stat); 156 xfs_lookup_t dir, int *stat);
158
159/*
160 * Lookup the first record less than or equal to ino
161 * in the btree given by cur.
162 */
163int xfs_inobt_lookup_le(struct xfs_btree_cur *cur, xfs_agino_t ino,
164 __int32_t fcnt, xfs_inofree_t free, int *stat);
165 157
166/* 158/*
167 * Get the data from the pointed-to record. 159 * Get the data from the pointed-to record.
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 3ec13e8a8c54..b68f9107e26c 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -444,7 +444,8 @@ xfs_bulkstat(
444 /* 444 /*
445 * Lookup the inode chunk that this inode lives in. 445 * Lookup the inode chunk that this inode lives in.
446 */ 446 */
447 error = xfs_inobt_lookup_le(cur, agino, 0, 0, &tmp); 447 error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_LE,
448 &tmp);
448 if (!error && /* no I/O error */ 449 if (!error && /* no I/O error */
449 tmp && /* lookup succeeded */ 450 tmp && /* lookup succeeded */
450 /* got the record, should always work */ 451 /* got the record, should always work */
@@ -492,7 +493,7 @@ xfs_bulkstat(
492 /* 493 /*
493 * Start of ag. Lookup the first inode chunk. 494 * Start of ag. Lookup the first inode chunk.
494 */ 495 */
495 error = xfs_inobt_lookup_ge(cur, 0, 0, 0, &tmp); 496 error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &tmp);
496 icount = 0; 497 icount = 0;
497 } 498 }
498 /* 499 /*
@@ -511,8 +512,8 @@ xfs_bulkstat(
511 if (XFS_AGINO_TO_AGBNO(mp, agino) >= 512 if (XFS_AGINO_TO_AGBNO(mp, agino) >=
512 be32_to_cpu(agi->agi_length)) 513 be32_to_cpu(agi->agi_length))
513 break; 514 break;
514 error = xfs_inobt_lookup_ge(cur, agino, 0, 0, 515 error = xfs_inobt_lookup(cur, agino,
515 &tmp); 516 XFS_LOOKUP_GE, &tmp);
516 cond_resched(); 517 cond_resched();
517 } 518 }
518 /* 519 /*
@@ -858,7 +859,8 @@ xfs_inumbers(
858 continue; 859 continue;
859 } 860 }
860 cur = xfs_inobt_init_cursor(mp, NULL, agbp, agno); 861 cur = xfs_inobt_init_cursor(mp, NULL, agbp, agno);
861 error = xfs_inobt_lookup_ge(cur, agino, 0, 0, &tmp); 862 error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_GE,
863 &tmp);
862 if (error) { 864 if (error) {
863 xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); 865 xfs_btree_del_cursor(cur, XFS_BTREE_ERROR);
864 cur = NULL; 866 cur = NULL;