Commit 973b8319 authored by Darrick J. Wong's avatar Darrick J. Wong Committed by Dave Chinner

xfs: remove the get*keys and update_keys btree ops pointers

These are internal btree functions; we don't need them to be
dispatched via function pointers.  Make them static again and
just check the overlapped flag to figure out what we need to
do.  The strategy behind this patch was suggested by Christoph.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Suggested-by: default avatarChristoph Hellwig <hch@infradead.org>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 1c0607ac
...@@ -403,10 +403,6 @@ static const struct xfs_btree_ops xfs_allocbt_ops = { ...@@ -403,10 +403,6 @@ static const struct xfs_btree_ops xfs_allocbt_ops = {
.keys_inorder = xfs_allocbt_keys_inorder, .keys_inorder = xfs_allocbt_keys_inorder,
.recs_inorder = xfs_allocbt_recs_inorder, .recs_inorder = xfs_allocbt_recs_inorder,
#endif #endif
.get_leaf_keys = xfs_btree_get_leaf_keys,
.get_node_keys = xfs_btree_get_node_keys,
.update_keys = xfs_btree_update_keys,
}; };
/* /*
......
...@@ -763,10 +763,6 @@ static const struct xfs_btree_ops xfs_bmbt_ops = { ...@@ -763,10 +763,6 @@ static const struct xfs_btree_ops xfs_bmbt_ops = {
.keys_inorder = xfs_bmbt_keys_inorder, .keys_inorder = xfs_bmbt_keys_inorder,
.recs_inorder = xfs_bmbt_recs_inorder, .recs_inorder = xfs_bmbt_recs_inorder,
#endif #endif
.get_leaf_keys = xfs_btree_get_leaf_keys,
.get_node_keys = xfs_btree_get_node_keys,
.update_keys = xfs_btree_update_keys,
}; };
/* /*
......
...@@ -1951,29 +1951,6 @@ xfs_btree_lookup( ...@@ -1951,29 +1951,6 @@ xfs_btree_lookup(
return error; return error;
} }
/* Determine the low key of a leaf block (simple) */
void
xfs_btree_get_leaf_keys(
struct xfs_btree_cur *cur,
struct xfs_btree_block *block,
union xfs_btree_key *key)
{
union xfs_btree_rec *rec;
rec = xfs_btree_rec_addr(cur, 1, block);
cur->bc_ops->init_key_from_rec(key, rec);
}
/* Determine the low key of a node block (simple) */
void
xfs_btree_get_node_keys(
struct xfs_btree_cur *cur,
struct xfs_btree_block *block,
union xfs_btree_key *key)
{
memcpy(key, xfs_btree_key_addr(cur, 1, block), cur->bc_ops->key_len);
}
/* Find the high key storage area from a regular key. */ /* Find the high key storage area from a regular key. */
STATIC union xfs_btree_key * STATIC union xfs_btree_key *
xfs_btree_high_key_from_key( xfs_btree_high_key_from_key(
...@@ -1985,48 +1962,51 @@ xfs_btree_high_key_from_key( ...@@ -1985,48 +1962,51 @@ xfs_btree_high_key_from_key(
(cur->bc_ops->key_len / 2)); (cur->bc_ops->key_len / 2));
} }
/* Determine the low and high keys of a leaf block (overlapped) */ /* Determine the low (and high if overlapped) keys of a leaf block */
void STATIC void
xfs_btree_get_leaf_keys_overlapped( xfs_btree_get_leaf_keys(
struct xfs_btree_cur *cur, struct xfs_btree_cur *cur,
struct xfs_btree_block *block, struct xfs_btree_block *block,
union xfs_btree_key *key) union xfs_btree_key *key)
{ {
int n;
union xfs_btree_rec *rec;
union xfs_btree_key max_hkey; union xfs_btree_key max_hkey;
union xfs_btree_key hkey; union xfs_btree_key hkey;
union xfs_btree_rec *rec;
union xfs_btree_key *high; union xfs_btree_key *high;
int n;
ASSERT(cur->bc_flags & XFS_BTREE_OVERLAPPING);
rec = xfs_btree_rec_addr(cur, 1, block); rec = xfs_btree_rec_addr(cur, 1, block);
cur->bc_ops->init_key_from_rec(key, rec); cur->bc_ops->init_key_from_rec(key, rec);
if (cur->bc_flags & XFS_BTREE_OVERLAPPING) {
cur->bc_ops->init_high_key_from_rec(&max_hkey, rec); cur->bc_ops->init_high_key_from_rec(&max_hkey, rec);
for (n = 2; n <= xfs_btree_get_numrecs(block); n++) { for (n = 2; n <= xfs_btree_get_numrecs(block); n++) {
rec = xfs_btree_rec_addr(cur, n, block); rec = xfs_btree_rec_addr(cur, n, block);
cur->bc_ops->init_high_key_from_rec(&hkey, rec); cur->bc_ops->init_high_key_from_rec(&hkey, rec);
if (cur->bc_ops->diff_two_keys(cur, &hkey, &max_hkey) > 0) if (cur->bc_ops->diff_two_keys(cur, &hkey, &max_hkey)
> 0)
max_hkey = hkey; max_hkey = hkey;
} }
high = xfs_btree_high_key_from_key(cur, key); high = xfs_btree_high_key_from_key(cur, key);
memcpy(high, &max_hkey, cur->bc_ops->key_len / 2); memcpy(high, &max_hkey, cur->bc_ops->key_len / 2);
}
} }
/* Determine the low and high keys of a node block (overlapped) */ /* Determine the low (and high if overlapped) keys of a node block */
void STATIC void
xfs_btree_get_node_keys_overlapped( xfs_btree_get_node_keys(
struct xfs_btree_cur *cur, struct xfs_btree_cur *cur,
struct xfs_btree_block *block, struct xfs_btree_block *block,
union xfs_btree_key *key) union xfs_btree_key *key)
{ {
int n;
union xfs_btree_key *hkey; union xfs_btree_key *hkey;
union xfs_btree_key *max_hkey; union xfs_btree_key *max_hkey;
union xfs_btree_key *high; union xfs_btree_key *high;
int n;
ASSERT(cur->bc_flags & XFS_BTREE_OVERLAPPING); if (cur->bc_flags & XFS_BTREE_OVERLAPPING) {
memcpy(key, xfs_btree_key_addr(cur, 1, block), memcpy(key, xfs_btree_key_addr(cur, 1, block),
cur->bc_ops->key_len / 2); cur->bc_ops->key_len / 2);
...@@ -2039,6 +2019,10 @@ xfs_btree_get_node_keys_overlapped( ...@@ -2039,6 +2019,10 @@ xfs_btree_get_node_keys_overlapped(
high = xfs_btree_high_key_from_key(cur, key); high = xfs_btree_high_key_from_key(cur, key);
memcpy(high, max_hkey, cur->bc_ops->key_len / 2); memcpy(high, max_hkey, cur->bc_ops->key_len / 2);
} else {
memcpy(key, xfs_btree_key_addr(cur, 1, block),
cur->bc_ops->key_len);
}
} }
/* Derive the keys for any btree block. */ /* Derive the keys for any btree block. */
...@@ -2049,9 +2033,9 @@ xfs_btree_get_keys( ...@@ -2049,9 +2033,9 @@ xfs_btree_get_keys(
union xfs_btree_key *key) union xfs_btree_key *key)
{ {
if (be16_to_cpu(block->bb_level) == 0) if (be16_to_cpu(block->bb_level) == 0)
cur->bc_ops->get_leaf_keys(cur, block, key); xfs_btree_get_leaf_keys(cur, block, key);
else else
cur->bc_ops->get_node_keys(cur, block, key); xfs_btree_get_node_keys(cur, block, key);
} }
/* /*
...@@ -2125,28 +2109,12 @@ __xfs_btree_updkeys( ...@@ -2125,28 +2109,12 @@ __xfs_btree_updkeys(
xfs_btree_log_keys(cur, bp, ptr, ptr); xfs_btree_log_keys(cur, bp, ptr, ptr);
if (level + 1 >= cur->bc_nlevels) if (level + 1 >= cur->bc_nlevels)
break; break;
cur->bc_ops->get_node_keys(cur, block, lkey); xfs_btree_get_node_keys(cur, block, lkey);
} }
return 0; return 0;
} }
/*
* Update all the keys from some level in cursor back to the root, stopping
* when we find a key pair that don't need updating.
*/
int
xfs_btree_update_keys_overlapped(
struct xfs_btree_cur *cur,
int level)
{
struct xfs_buf *bp;
struct xfs_btree_block *block;
block = xfs_btree_get_block(cur, level, &bp);
return __xfs_btree_updkeys(cur, level, block, bp, false);
}
/* Update all the keys from some level in cursor back to the root. */ /* Update all the keys from some level in cursor back to the root. */
STATIC int STATIC int
xfs_btree_updkeys_force( xfs_btree_updkeys_force(
...@@ -2163,7 +2131,7 @@ xfs_btree_updkeys_force( ...@@ -2163,7 +2131,7 @@ xfs_btree_updkeys_force(
/* /*
* Update the parent keys of the given level, progressing towards the root. * Update the parent keys of the given level, progressing towards the root.
*/ */
int STATIC int
xfs_btree_update_keys( xfs_btree_update_keys(
struct xfs_btree_cur *cur, struct xfs_btree_cur *cur,
int level) int level)
...@@ -2174,20 +2142,21 @@ xfs_btree_update_keys( ...@@ -2174,20 +2142,21 @@ xfs_btree_update_keys(
union xfs_btree_key key; union xfs_btree_key key;
int ptr; int ptr;
ASSERT(!(cur->bc_flags & XFS_BTREE_OVERLAPPING)); ASSERT(level >= 0);
block = xfs_btree_get_block(cur, level, &bp);
if (cur->bc_flags & XFS_BTREE_OVERLAPPING)
return __xfs_btree_updkeys(cur, level, block, bp, false);
XFS_BTREE_TRACE_CURSOR(cur, XBT_ENTRY); XFS_BTREE_TRACE_CURSOR(cur, XBT_ENTRY);
XFS_BTREE_TRACE_ARGIK(cur, level, keyp); XFS_BTREE_TRACE_ARGIK(cur, level, keyp);
ASSERT(level >= 0);
/* /*
* Go up the tree from this level toward the root. * Go up the tree from this level toward the root.
* At each level, update the key value to the value input. * At each level, update the key value to the value input.
* Stop when we reach a level where the cursor isn't pointing * Stop when we reach a level where the cursor isn't pointing
* at the first entry in the block. * at the first entry in the block.
*/ */
block = xfs_btree_get_block(cur, level, &bp);
xfs_btree_get_keys(cur, block, &key); xfs_btree_get_keys(cur, block, &key);
for (level++, ptr = 1; ptr == 1 && level < cur->bc_nlevels; level++) { for (level++, ptr = 1; ptr == 1 && level < cur->bc_nlevels; level++) {
#ifdef DEBUG #ifdef DEBUG
...@@ -2257,7 +2226,7 @@ xfs_btree_update( ...@@ -2257,7 +2226,7 @@ xfs_btree_update(
/* Pass new key value up to our parent. */ /* Pass new key value up to our parent. */
if (xfs_btree_needs_key_update(cur, ptr)) { if (xfs_btree_needs_key_update(cur, ptr)) {
error = cur->bc_ops->update_keys(cur, 0); error = xfs_btree_update_keys(cur, 0);
if (error) if (error)
goto error0; goto error0;
} }
...@@ -2447,13 +2416,13 @@ xfs_btree_lshift( ...@@ -2447,13 +2416,13 @@ xfs_btree_lshift(
goto error1; goto error1;
/* Update the parent keys of the right block. */ /* Update the parent keys of the right block. */
error = cur->bc_ops->update_keys(cur, level); error = xfs_btree_update_keys(cur, level);
if (error) if (error)
goto error1; goto error1;
/* Update the parent high keys of the left block, if needed. */ /* Update the parent high keys of the left block, if needed. */
if (tcur->bc_flags & XFS_BTREE_OVERLAPPING) { if (tcur->bc_flags & XFS_BTREE_OVERLAPPING) {
error = tcur->bc_ops->update_keys(tcur, level); error = xfs_btree_update_keys(tcur, level);
if (error) if (error)
goto error1; goto error1;
} }
...@@ -2633,13 +2602,13 @@ xfs_btree_rshift( ...@@ -2633,13 +2602,13 @@ xfs_btree_rshift(
/* Update the parent high keys of the left block, if needed. */ /* Update the parent high keys of the left block, if needed. */
if (cur->bc_flags & XFS_BTREE_OVERLAPPING) { if (cur->bc_flags & XFS_BTREE_OVERLAPPING) {
error = cur->bc_ops->update_keys(cur, level); error = xfs_btree_update_keys(cur, level);
if (error) if (error)
goto error1; goto error1;
} }
/* Update the parent keys of the right block. */ /* Update the parent keys of the right block. */
error = cur->bc_ops->update_keys(tcur, level); error = xfs_btree_update_keys(tcur, level);
if (error) if (error)
goto error1; goto error1;
...@@ -2778,7 +2747,7 @@ __xfs_btree_split( ...@@ -2778,7 +2747,7 @@ __xfs_btree_split(
xfs_btree_log_ptrs(cur, rbp, 1, rrecs); xfs_btree_log_ptrs(cur, rbp, 1, rrecs);
/* Stash the keys of the new block for later insertion. */ /* Stash the keys of the new block for later insertion. */
cur->bc_ops->get_node_keys(cur, right, key); xfs_btree_get_node_keys(cur, right, key);
} else { } else {
/* It's a leaf. Move records. */ /* It's a leaf. Move records. */
union xfs_btree_rec *lrp; /* left record pointer */ union xfs_btree_rec *lrp; /* left record pointer */
...@@ -2792,7 +2761,7 @@ __xfs_btree_split( ...@@ -2792,7 +2761,7 @@ __xfs_btree_split(
xfs_btree_log_recs(cur, rbp, 1, rrecs); xfs_btree_log_recs(cur, rbp, 1, rrecs);
/* Stash the keys of the new block for later insertion. */ /* Stash the keys of the new block for later insertion. */
cur->bc_ops->get_leaf_keys(cur, right, key); xfs_btree_get_leaf_keys(cur, right, key);
} }
/* /*
...@@ -2822,7 +2791,7 @@ __xfs_btree_split( ...@@ -2822,7 +2791,7 @@ __xfs_btree_split(
/* Update the parent high keys of the left block, if needed. */ /* Update the parent high keys of the left block, if needed. */
if (cur->bc_flags & XFS_BTREE_OVERLAPPING) { if (cur->bc_flags & XFS_BTREE_OVERLAPPING) {
error = cur->bc_ops->update_keys(cur, level); error = xfs_btree_update_keys(cur, level);
if (error) if (error)
goto error0; goto error0;
} }
...@@ -3143,9 +3112,9 @@ xfs_btree_new_root( ...@@ -3143,9 +3112,9 @@ xfs_btree_new_root(
* Get the keys for the left block's keys and put them directly * Get the keys for the left block's keys and put them directly
* in the parent block. Do the same for the right block. * in the parent block. Do the same for the right block.
*/ */
cur->bc_ops->get_node_keys(cur, left, xfs_btree_get_node_keys(cur, left,
xfs_btree_key_addr(cur, 1, new)); xfs_btree_key_addr(cur, 1, new));
cur->bc_ops->get_node_keys(cur, right, xfs_btree_get_node_keys(cur, right,
xfs_btree_key_addr(cur, 2, new)); xfs_btree_key_addr(cur, 2, new));
} else { } else {
/* /*
...@@ -3153,9 +3122,9 @@ xfs_btree_new_root( ...@@ -3153,9 +3122,9 @@ xfs_btree_new_root(
* directly in the parent block. Do the same for the right * directly in the parent block. Do the same for the right
* block. * block.
*/ */
cur->bc_ops->get_leaf_keys(cur, left, xfs_btree_get_leaf_keys(cur, left,
xfs_btree_key_addr(cur, 1, new)); xfs_btree_key_addr(cur, 1, new));
cur->bc_ops->get_leaf_keys(cur, right, xfs_btree_get_leaf_keys(cur, right,
xfs_btree_key_addr(cur, 2, new)); xfs_btree_key_addr(cur, 2, new));
} }
xfs_btree_log_keys(cur, nbp, 1, 2); xfs_btree_log_keys(cur, nbp, 1, 2);
...@@ -3434,7 +3403,7 @@ xfs_btree_insrec( ...@@ -3434,7 +3403,7 @@ xfs_btree_insrec(
if (bp && bp->b_bn != old_bn) { if (bp && bp->b_bn != old_bn) {
xfs_btree_get_keys(cur, block, lkey); xfs_btree_get_keys(cur, block, lkey);
} else if (xfs_btree_needs_key_update(cur, optr)) { } else if (xfs_btree_needs_key_update(cur, optr)) {
error = cur->bc_ops->update_keys(cur, level); error = xfs_btree_update_keys(cur, level);
if (error) if (error)
goto error0; goto error0;
} }
...@@ -3880,7 +3849,7 @@ xfs_btree_delrec( ...@@ -3880,7 +3849,7 @@ xfs_btree_delrec(
* key values above us in the tree. * key values above us in the tree.
*/ */
if (xfs_btree_needs_key_update(cur, ptr)) { if (xfs_btree_needs_key_update(cur, ptr)) {
error = cur->bc_ops->update_keys(cur, level); error = xfs_btree_update_keys(cur, level);
if (error) if (error)
goto error0; goto error0;
} }
......
...@@ -214,19 +214,6 @@ struct xfs_btree_ops { ...@@ -214,19 +214,6 @@ struct xfs_btree_ops {
union xfs_btree_rec *r1, union xfs_btree_rec *r1,
union xfs_btree_rec *r2); union xfs_btree_rec *r2);
#endif #endif
/* derive the low & high keys from the records in a leaf block */
void (*get_leaf_keys)(struct xfs_btree_cur *cur,
struct xfs_btree_block *block,
union xfs_btree_key *key);
/* derive the low & high keys from the keys in a node block */
void (*get_node_keys)(struct xfs_btree_cur *cur,
struct xfs_btree_block *block,
union xfs_btree_key *key);
/* update the parent keys of given btree level */
int (*update_keys)(struct xfs_btree_cur *cur, int level);
}; };
/* /*
...@@ -527,17 +514,6 @@ bool xfs_btree_sblock_verify(struct xfs_buf *bp, unsigned int max_recs); ...@@ -527,17 +514,6 @@ bool xfs_btree_sblock_verify(struct xfs_buf *bp, unsigned int max_recs);
uint xfs_btree_compute_maxlevels(struct xfs_mount *mp, uint *limits, uint xfs_btree_compute_maxlevels(struct xfs_mount *mp, uint *limits,
unsigned long len); unsigned long len);
void xfs_btree_get_leaf_keys(struct xfs_btree_cur *cur,
struct xfs_btree_block *block, union xfs_btree_key *key);
void xfs_btree_get_node_keys(struct xfs_btree_cur *cur,
struct xfs_btree_block *block, union xfs_btree_key *key);
int xfs_btree_update_keys(struct xfs_btree_cur *cur, int level);
void xfs_btree_get_leaf_keys_overlapped(struct xfs_btree_cur *cur,
struct xfs_btree_block *block, union xfs_btree_key *key);
void xfs_btree_get_node_keys_overlapped(struct xfs_btree_cur *cur,
struct xfs_btree_block *block, union xfs_btree_key *key);
int xfs_btree_update_keys_overlapped(struct xfs_btree_cur *cur, int level);
/* return codes */ /* return codes */
#define XFS_BTREE_QUERY_RANGE_CONTINUE 0 /* keep iterating */ #define XFS_BTREE_QUERY_RANGE_CONTINUE 0 /* keep iterating */
#define XFS_BTREE_QUERY_RANGE_ABORT 1 /* stop iterating */ #define XFS_BTREE_QUERY_RANGE_ABORT 1 /* stop iterating */
......
...@@ -320,10 +320,6 @@ static const struct xfs_btree_ops xfs_inobt_ops = { ...@@ -320,10 +320,6 @@ static const struct xfs_btree_ops xfs_inobt_ops = {
.keys_inorder = xfs_inobt_keys_inorder, .keys_inorder = xfs_inobt_keys_inorder,
.recs_inorder = xfs_inobt_recs_inorder, .recs_inorder = xfs_inobt_recs_inorder,
#endif #endif
.get_leaf_keys = xfs_btree_get_leaf_keys,
.get_node_keys = xfs_btree_get_node_keys,
.update_keys = xfs_btree_update_keys,
}; };
static const struct xfs_btree_ops xfs_finobt_ops = { static const struct xfs_btree_ops xfs_finobt_ops = {
...@@ -345,10 +341,6 @@ static const struct xfs_btree_ops xfs_finobt_ops = { ...@@ -345,10 +341,6 @@ static const struct xfs_btree_ops xfs_finobt_ops = {
.keys_inorder = xfs_inobt_keys_inorder, .keys_inorder = xfs_inobt_keys_inorder,
.recs_inorder = xfs_inobt_recs_inorder, .recs_inorder = xfs_inobt_recs_inorder,
#endif #endif
.get_leaf_keys = xfs_btree_get_leaf_keys,
.get_node_keys = xfs_btree_get_node_keys,
.update_keys = xfs_btree_update_keys,
}; };
/* /*
......
...@@ -453,10 +453,6 @@ static const struct xfs_btree_ops xfs_rmapbt_ops = { ...@@ -453,10 +453,6 @@ static const struct xfs_btree_ops xfs_rmapbt_ops = {
.keys_inorder = xfs_rmapbt_keys_inorder, .keys_inorder = xfs_rmapbt_keys_inorder,
.recs_inorder = xfs_rmapbt_recs_inorder, .recs_inorder = xfs_rmapbt_recs_inorder,
#endif #endif
.get_leaf_keys = xfs_btree_get_leaf_keys_overlapped,
.get_node_keys = xfs_btree_get_node_keys_overlapped,
.update_keys = xfs_btree_update_keys_overlapped,
}; };
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment