From: Christoph Hellwig <hch@lst.de>
To: xfs@oss.sgi.com
Subject: [PATCH 14/21] add get_maxrecs btree operation
Date: Tue, 29 Jul 2008 21:31:21 +0200 [thread overview]
Message-ID: <20080729193121.GO19104@lst.de> (raw)
[-- 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,
--
next reply other threads:[~2008-07-29 19:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-29 19:31 Christoph Hellwig [this message]
2008-07-30 5:34 ` [PATCH 14/21] add get_maxrecs btree operation Dave Chinner
2008-08-01 19:46 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080729193121.GO19104@lst.de \
--to=hch@lst.de \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox