aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2008-10-30 01:55:23 -0400
committerLachlan McIlroy <lachlan@sgi.com>2008-10-30 01:55:23 -0400
commitce5e42db421a41b1ad0cfd68c6058566b963e14b (patch)
tree7723f47e468c6b933a89361462c04436fe617cda
parent8c4ed633e65d0bd0a25d45aad9b4646e3236cad7 (diff)
[XFS] add get_maxrecs btree operation
Factor xfs_btree_maxrecs into a per-btree operation. The get_maxrecs method is based on a patch from Dave Chinner. SGI-PV: 985583 SGI-Modid: xfs-linux-melb:xfs-kern:32188a Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com> Signed-off-by: Bill O'Donnell <billodo@sgi.com> Signed-off-by: David Chinner <david@fromorbit.com>
-rw-r--r--fs/xfs/xfs_alloc_btree.c9
-rw-r--r--fs/xfs/xfs_bmap_btree.c9
-rw-r--r--fs/xfs/xfs_btree.c29
-rw-r--r--fs/xfs/xfs_btree.h3
-rw-r--r--fs/xfs/xfs_ialloc_btree.c9
5 files changed, 32 insertions, 27 deletions
diff --git a/fs/xfs/xfs_alloc_btree.c b/fs/xfs/xfs_alloc_btree.c
index 9c91dfcb6f29..1f268b6f4362 100644
--- a/fs/xfs/xfs_alloc_btree.c
+++ b/fs/xfs/xfs_alloc_btree.c
@@ -2219,6 +2219,14 @@ xfs_allocbt_dup_cursor(
2219 cur->bc_btnum); 2219 cur->bc_btnum);
2220} 2220}
2221 2221
2222STATIC int
2223xfs_allocbt_get_maxrecs(
2224 struct xfs_btree_cur *cur,
2225 int level)
2226{
2227 return cur->bc_mp->m_alloc_mxr[level != 0];
2228}
2229
2222#ifdef XFS_BTREE_TRACE 2230#ifdef XFS_BTREE_TRACE
2223ktrace_t *xfs_allocbt_trace_buf; 2231ktrace_t *xfs_allocbt_trace_buf;
2224 2232
@@ -2287,6 +2295,7 @@ xfs_allocbt_trace_record(
2287 2295
2288static const struct xfs_btree_ops xfs_allocbt_ops = { 2296static const struct xfs_btree_ops xfs_allocbt_ops = {
2289 .dup_cursor = xfs_allocbt_dup_cursor, 2297 .dup_cursor = xfs_allocbt_dup_cursor,
2298 .get_maxrecs = xfs_allocbt_get_maxrecs,
2290 2299
2291#ifdef XFS_BTREE_TRACE 2300#ifdef XFS_BTREE_TRACE
2292 .trace_enter = xfs_allocbt_trace_enter, 2301 .trace_enter = xfs_allocbt_trace_enter,
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c
index 16f2fde6433d..bdcfbea1e062 100644
--- a/fs/xfs/xfs_bmap_btree.c
+++ b/fs/xfs/xfs_bmap_btree.c
@@ -2415,6 +2415,14 @@ xfs_bmbt_dup_cursor(
2415 return new; 2415 return new;
2416} 2416}
2417 2417
2418STATIC int
2419xfs_bmbt_get_maxrecs(
2420 struct xfs_btree_cur *cur,
2421 int level)
2422{
2423 return XFS_BMAP_BLOCK_IMAXRECS(level, cur);
2424}
2425
2418#ifdef XFS_BTREE_TRACE 2426#ifdef XFS_BTREE_TRACE
2419ktrace_t *xfs_bmbt_trace_buf; 2427ktrace_t *xfs_bmbt_trace_buf;
2420 2428
@@ -2502,6 +2510,7 @@ xfs_bmbt_trace_record(
2502 2510
2503static const struct xfs_btree_ops xfs_bmbt_ops = { 2511static const struct xfs_btree_ops xfs_bmbt_ops = {
2504 .dup_cursor = xfs_bmbt_dup_cursor, 2512 .dup_cursor = xfs_bmbt_dup_cursor,
2513 .get_maxrecs = xfs_bmbt_get_maxrecs,
2505 2514
2506#ifdef XFS_BTREE_TRACE 2515#ifdef XFS_BTREE_TRACE
2507 .trace_enter = xfs_bmbt_trace_enter, 2516 .trace_enter = xfs_bmbt_trace_enter,
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c
index 966d58d50fad..893e86f2ad57 100644
--- a/fs/xfs/xfs_btree.c
+++ b/fs/xfs/xfs_btree.c
@@ -51,31 +51,6 @@ const __uint32_t xfs_magics[XFS_BTNUM_MAX] = {
51}; 51};
52 52
53/* 53/*
54 * Checking routine: return maxrecs for the block.
55 */
56STATIC int /* number of records fitting in block */
57xfs_btree_maxrecs(
58 xfs_btree_cur_t *cur, /* btree cursor */
59 xfs_btree_block_t *block) /* generic btree block pointer */
60{
61 switch (cur->bc_btnum) {
62 case XFS_BTNUM_BNO:
63 case XFS_BTNUM_CNT:
64 return (int)XFS_ALLOC_BLOCK_MAXRECS(
65 be16_to_cpu(block->bb_level), cur);
66 case XFS_BTNUM_BMAP:
67 return (int)XFS_BMAP_BLOCK_IMAXRECS(
68 be16_to_cpu(block->bb_level), cur);
69 case XFS_BTNUM_INO:
70 return (int)XFS_INOBT_BLOCK_MAXRECS(
71 be16_to_cpu(block->bb_level), cur);
72 default:
73 ASSERT(0);
74 return 0;
75 }
76}
77
78/*
79 * External routines. 54 * External routines.
80 */ 55 */
81 56
@@ -207,7 +182,7 @@ xfs_btree_check_lblock(
207 be32_to_cpu(block->bb_magic) == xfs_magics[cur->bc_btnum] && 182 be32_to_cpu(block->bb_magic) == xfs_magics[cur->bc_btnum] &&
208 be16_to_cpu(block->bb_level) == level && 183 be16_to_cpu(block->bb_level) == level &&
209 be16_to_cpu(block->bb_numrecs) <= 184 be16_to_cpu(block->bb_numrecs) <=
210 xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) && 185 cur->bc_ops->get_maxrecs(cur, level) &&
211 block->bb_leftsib && 186 block->bb_leftsib &&
212 (be64_to_cpu(block->bb_leftsib) == NULLDFSBNO || 187 (be64_to_cpu(block->bb_leftsib) == NULLDFSBNO ||
213 XFS_FSB_SANITY_CHECK(mp, be64_to_cpu(block->bb_leftsib))) && 188 XFS_FSB_SANITY_CHECK(mp, be64_to_cpu(block->bb_leftsib))) &&
@@ -245,7 +220,7 @@ xfs_btree_check_sblock(
245 be32_to_cpu(block->bb_magic) == xfs_magics[cur->bc_btnum] && 220 be32_to_cpu(block->bb_magic) == xfs_magics[cur->bc_btnum] &&
246 be16_to_cpu(block->bb_level) == level && 221 be16_to_cpu(block->bb_level) == level &&
247 be16_to_cpu(block->bb_numrecs) <= 222 be16_to_cpu(block->bb_numrecs) <=
248 xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) && 223 cur->bc_ops->get_maxrecs(cur, level) &&
249 (be32_to_cpu(block->bb_leftsib) == NULLAGBLOCK || 224 (be32_to_cpu(block->bb_leftsib) == NULLAGBLOCK ||
250 be32_to_cpu(block->bb_leftsib) < agflen) && 225 be32_to_cpu(block->bb_leftsib) < agflen) &&
251 block->bb_leftsib && 226 block->bb_leftsib &&
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h
index 0647a0eff0de..5398cd0d4d4d 100644
--- a/fs/xfs/xfs_btree.h
+++ b/fs/xfs/xfs_btree.h
@@ -183,6 +183,9 @@ struct xfs_btree_ops {
183 /* cursor operations */ 183 /* cursor operations */
184 struct xfs_btree_cur *(*dup_cursor)(struct xfs_btree_cur *); 184 struct xfs_btree_cur *(*dup_cursor)(struct xfs_btree_cur *);
185 185
186 /* records in block/level */
187 int (*get_maxrecs)(struct xfs_btree_cur *cur, int level);
188
186 /* btree tracing */ 189 /* btree tracing */
187#ifdef XFS_BTREE_TRACE 190#ifdef XFS_BTREE_TRACE
188 void (*trace_enter)(struct xfs_btree_cur *, const char *, 191 void (*trace_enter)(struct xfs_btree_cur *, const char *,
diff --git a/fs/xfs/xfs_ialloc_btree.c b/fs/xfs/xfs_ialloc_btree.c
index fc99524b17af..18867f1aacac 100644
--- a/fs/xfs/xfs_ialloc_btree.c
+++ b/fs/xfs/xfs_ialloc_btree.c
@@ -2085,6 +2085,14 @@ xfs_inobt_dup_cursor(
2085 cur->bc_private.a.agbp, cur->bc_private.a.agno); 2085 cur->bc_private.a.agbp, cur->bc_private.a.agno);
2086} 2086}
2087 2087
2088STATIC int
2089xfs_inobt_get_maxrecs(
2090 struct xfs_btree_cur *cur,
2091 int level)
2092{
2093 return cur->bc_mp->m_inobt_mxr[level != 0];
2094}
2095
2088#ifdef XFS_BTREE_TRACE 2096#ifdef XFS_BTREE_TRACE
2089ktrace_t *xfs_inobt_trace_buf; 2097ktrace_t *xfs_inobt_trace_buf;
2090 2098
@@ -2153,6 +2161,7 @@ xfs_inobt_trace_record(
2153 2161
2154static const struct xfs_btree_ops xfs_inobt_ops = { 2162static const struct xfs_btree_ops xfs_inobt_ops = {
2155 .dup_cursor = xfs_inobt_dup_cursor, 2163 .dup_cursor = xfs_inobt_dup_cursor,
2164 .get_maxrecs = xfs_inobt_get_maxrecs,
2156 2165
2157#ifdef XFS_BTREE_TRACE 2166#ifdef XFS_BTREE_TRACE
2158 .trace_enter = xfs_inobt_trace_enter, 2167 .trace_enter = xfs_inobt_trace_enter,