* [PATCH 14/21] add get_maxrecs btree operation
@ 2008-07-29 19:31 Christoph Hellwig
2008-07-30 5:34 ` Dave Chinner
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2008-07-29 19:31 UTC (permalink / raw)
To: xfs
[-- Attachment #1: xfs-btree-get_maxrecs-method --]
[-- Type: text/plain, Size: 5477 bytes --]
Factor xfs_btree_maxrecs into a per-btree operation.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: linux-2.6-xfs/fs/xfs/xfs_btree.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_btree.c 2008-07-24 08:58:28.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_btree.c 2008-07-24 09:01:57.000000000 +0200
@@ -52,31 +52,6 @@ const __uint32_t xfs_magics[XFS_BTNUM_MA
};
/*
- * Checking routine: return maxrecs for the block.
- */
-STATIC int /* number of records fitting in block */
-xfs_btree_maxrecs(
- xfs_btree_cur_t *cur, /* btree cursor */
- xfs_btree_block_t *block) /* generic btree block pointer */
-{
- switch (cur->bc_btnum) {
- case XFS_BTNUM_BNO:
- case XFS_BTNUM_CNT:
- return (int)XFS_ALLOC_BLOCK_MAXRECS(
- be16_to_cpu(block->bb_h.bb_level), cur);
- case XFS_BTNUM_BMAP:
- return (int)XFS_BMAP_BLOCK_IMAXRECS(
- be16_to_cpu(block->bb_h.bb_level), cur);
- case XFS_BTNUM_INO:
- return (int)XFS_INOBT_BLOCK_MAXRECS(
- be16_to_cpu(block->bb_h.bb_level), cur);
- default:
- ASSERT(0);
- return 0;
- }
-}
-
-/*
* External routines.
*/
@@ -208,7 +183,7 @@ xfs_btree_check_lblock(
be32_to_cpu(block->bb_magic) == xfs_magics[cur->bc_btnum] &&
be16_to_cpu(block->bb_level) == level &&
be16_to_cpu(block->bb_numrecs) <=
- xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) &&
+ cur->bc_ops->get_maxrecs(cur, level) &&
block->bb_leftsib &&
(be64_to_cpu(block->bb_leftsib) == NULLDFSBNO ||
XFS_FSB_SANITY_CHECK(mp, be64_to_cpu(block->bb_leftsib))) &&
@@ -245,7 +220,7 @@ xfs_btree_check_sblock(
be32_to_cpu(block->bb_magic) == xfs_magics[cur->bc_btnum] &&
be16_to_cpu(block->bb_level) == level &&
be16_to_cpu(block->bb_numrecs) <=
- xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) &&
+ cur->bc_ops->get_maxrecs(cur, level) &&
(be32_to_cpu(block->bb_leftsib) == NULLAGBLOCK ||
be32_to_cpu(block->bb_leftsib) < agflen) &&
block->bb_leftsib &&
Index: linux-2.6-xfs/fs/xfs/xfs_btree.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_btree.h 2008-07-24 08:57:24.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_btree.h 2008-07-24 08:58:17.000000000 +0200
@@ -204,6 +204,9 @@ struct xfs_btree_ops {
union xfs_btree_rec *(*rec_addr)(struct xfs_btree_cur *cur, int index,
struct xfs_btree_block *block);
+ /* records in block/level */
+ int (*get_maxrecs)(struct xfs_btree_cur *cur, int level);
+
/* init values of btree structures */
void (*init_key_from_rec)(struct xfs_btree_cur *cur,
union xfs_btree_key *key,
Index: linux-2.6-xfs/fs/xfs/xfs_alloc_btree.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_alloc_btree.c 2008-07-24 09:03:09.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_alloc_btree.c 2008-07-24 09:04:29.000000000 +0200
@@ -1655,6 +1655,14 @@ xfs_allocbt_update_lastrec(
xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp, XFS_AGF_LONGEST);
}
+STATIC int
+xfs_allocbt_get_maxrecs(
+ struct xfs_btree_cur *cur,
+ int level)
+{
+ return cur->bc_mp->m_alloc_mxr[level != 0];
+}
+
STATIC void
xfs_allocbt_init_key_from_rec(
struct xfs_btree_cur *cur,
@@ -1889,6 +1897,7 @@ xfs_allocbt_trace_record(
static const struct xfs_btree_ops xfs_allocbt_ops = {
.dup_cursor = xfs_allocbt_dup_cursor,
.update_lastrec = xfs_allocbt_update_lastrec,
+ .get_maxrecs = xfs_allocbt_get_maxrecs,
.init_key_from_rec = xfs_allocbt_init_key_from_rec,
.init_ptr_from_cur = xfs_allocbt_init_ptr_from_cur,
.ptr_addr = xfs_allocbt_ptr_addr,
Index: linux-2.6-xfs/fs/xfs/xfs_bmap_btree.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_bmap_btree.c 2008-07-24 09:04:44.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_bmap_btree.c 2008-07-24 09:08:34.000000000 +0200
@@ -1953,6 +1953,14 @@ xfs_bmbt_get_root_from_inode(
return (struct xfs_btree_block *)ifp->if_broot;
}
+STATIC int
+xfs_bmbt_get_maxrecs(
+ struct xfs_btree_cur *cur,
+ int level)
+{
+ return XFS_BMAP_BLOCK_IMAXRECS(level, cur);
+}
+
STATIC void
xfs_bmbt_init_key_from_rec(
struct xfs_btree_cur *cur,
@@ -2182,6 +2190,7 @@ static const struct xfs_btree_ops xfs_bm
.get_root_from_inode = xfs_bmbt_get_root_from_inode,
.init_key_from_rec = xfs_bmbt_init_key_from_rec,
.init_ptr_from_cur = xfs_bmbt_init_ptr_from_cur,
+ .get_maxrecs = xfs_bmbt_get_maxrecs,
.ptr_addr = xfs_bmbt_ptr_addr,
.key_addr = xfs_bmbt_key_addr,
.rec_addr = xfs_bmbt_rec_addr,
Index: linux-2.6-xfs/fs/xfs/xfs_ialloc_btree.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_ialloc_btree.c 2008-07-24 09:06:55.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_ialloc_btree.c 2008-07-24 09:08:06.000000000 +0200
@@ -1516,6 +1516,14 @@ xfs_inobt_dup_cursor(
cur->bc_private.a.agbp, cur->bc_private.a.agno);
}
+STATIC int
+xfs_inobt_get_maxrecs(
+ struct xfs_btree_cur *cur,
+ int level)
+{
+ return cur->bc_mp->m_inobt_mxr[level != 0];
+}
+
STATIC void
xfs_inobt_init_key_from_rec(
struct xfs_btree_cur *cur,
@@ -1725,6 +1733,7 @@ xfs_inobt_trace_record(
static const struct xfs_btree_ops xfs_inobt_ops = {
.dup_cursor = xfs_inobt_dup_cursor,
+ .get_maxrecs = xfs_inobt_get_maxrecs,
.init_key_from_rec = xfs_inobt_init_key_from_rec,
.init_ptr_from_cur = xfs_inobt_init_ptr_from_cur,
.ptr_addr = xfs_inobt_ptr_addr,
--
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH 14/21] add get_maxrecs btree operation
2008-07-29 19:31 [PATCH 14/21] add get_maxrecs btree operation Christoph Hellwig
@ 2008-07-30 5:34 ` Dave Chinner
2008-08-01 19:46 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Dave Chinner @ 2008-07-30 5:34 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: xfs
On Tue, Jul 29, 2008 at 09:31:21PM +0200, Christoph Hellwig wrote:
> Factor xfs_btree_maxrecs into a per-btree operation.
>
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
->get_maxrecs was extracted out of my original patchset, right?
I didn't apply it to removing xfs_btree_maxrecs(), though. Good
idea. Looks fine to me.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 14/21] add get_maxrecs btree operation
2008-07-30 5:34 ` Dave Chinner
@ 2008-08-01 19:46 ` Christoph Hellwig
0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2008-08-01 19:46 UTC (permalink / raw)
To: Christoph Hellwig, xfs
On Wed, Jul 30, 2008 at 03:34:55PM +1000, Dave Chinner wrote:
> On Tue, Jul 29, 2008 at 09:31:21PM +0200, Christoph Hellwig wrote:
> > Factor xfs_btree_maxrecs into a per-btree operation.
> >
> >
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> ->get_maxrecs was extracted out of my original patchset, right?
>
> I didn't apply it to removing xfs_btree_maxrecs(), though. Good
> idea. Looks fine to me.
Yeah, should have added a comment that this has been taken from the
big patch.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-08-01 19:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-29 19:31 [PATCH 14/21] add get_maxrecs btree operation Christoph Hellwig
2008-07-30 5:34 ` Dave Chinner
2008-08-01 19:46 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox