Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 213249
b: refs/heads/master
c: c0e59e1
h: refs/heads/master
i:
  213247: bf2821d
v: v3
  • Loading branch information
Christoph Hellwig authored and Alex Elder committed Oct 18, 2010
1 parent d005934 commit 1126b10
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 89 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: acecf1b5d8a846bf818bf74df454330f0b444b0a
refs/heads/master: c0e59e1ac0a106bbab93404024bb6e7927ad9d6d
33 changes: 0 additions & 33 deletions trunk/fs/xfs/xfs_alloc_btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,38 +280,6 @@ xfs_allocbt_key_diff(
return (__int64_t)be32_to_cpu(kp->ar_startblock) - rec->ar_startblock;
}

STATIC int
xfs_allocbt_kill_root(
struct xfs_btree_cur *cur,
struct xfs_buf *bp,
int level,
union xfs_btree_ptr *newroot)
{
int error;

XFS_BTREE_TRACE_CURSOR(cur, XBT_ENTRY);
XFS_BTREE_STATS_INC(cur, killroot);

/*
* Update the root pointer, decreasing the level by 1 and then
* free the old root.
*/
xfs_allocbt_set_root(cur, newroot, -1);
error = xfs_allocbt_free_block(cur, bp);
if (error) {
XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
return error;
}

XFS_BTREE_STATS_INC(cur, free);

xfs_btree_setbuf(cur, level, NULL);
cur->bc_nlevels--;

XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
return 0;
}

#ifdef DEBUG
STATIC int
xfs_allocbt_keys_inorder(
Expand Down Expand Up @@ -423,7 +391,6 @@ static const struct xfs_btree_ops xfs_allocbt_ops = {

.dup_cursor = xfs_allocbt_dup_cursor,
.set_root = xfs_allocbt_set_root,
.kill_root = xfs_allocbt_kill_root,
.alloc_block = xfs_allocbt_alloc_block,
.free_block = xfs_allocbt_free_block,
.update_lastrec = xfs_allocbt_update_lastrec,
Expand Down
52 changes: 43 additions & 9 deletions trunk/fs/xfs/xfs_btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ xfs_btree_del_cursor(
*/
for (i = 0; i < cur->bc_nlevels; i++) {
if (cur->bc_bufs[i])
xfs_btree_setbuf(cur, i, NULL);
xfs_trans_brelse(cur->bc_tp, cur->bc_bufs[i]);
else if (!error)
break;
}
Expand Down Expand Up @@ -763,22 +763,19 @@ xfs_btree_readahead(
* Set the buffer for level "lev" in the cursor to bp, releasing
* any previous buffer.
*/
void
STATIC void
xfs_btree_setbuf(
xfs_btree_cur_t *cur, /* btree cursor */
int lev, /* level in btree */
xfs_buf_t *bp) /* new buffer to set */
{
struct xfs_btree_block *b; /* btree block */
xfs_buf_t *obp; /* old buffer pointer */

obp = cur->bc_bufs[lev];
if (obp)
xfs_trans_brelse(cur->bc_tp, obp);
if (cur->bc_bufs[lev])
xfs_trans_brelse(cur->bc_tp, cur->bc_bufs[lev]);
cur->bc_bufs[lev] = bp;
cur->bc_ra[lev] = 0;
if (!bp)
return;

b = XFS_BUF_TO_BLOCK(bp);
if (cur->bc_flags & XFS_BTREE_LONG_PTRS) {
if (be64_to_cpu(b->bb_u.l.bb_leftsib) == NULLDFSBNO)
Expand Down Expand Up @@ -3011,6 +3008,43 @@ xfs_btree_kill_iroot(
return 0;
}

/*
* Kill the current root node, and replace it with it's only child node.
*/
STATIC int
xfs_btree_kill_root(
struct xfs_btree_cur *cur,
struct xfs_buf *bp,
int level,
union xfs_btree_ptr *newroot)
{
int error;

XFS_BTREE_TRACE_CURSOR(cur, XBT_ENTRY);
XFS_BTREE_STATS_INC(cur, killroot);

/*
* Update the root pointer, decreasing the level by 1 and then
* free the old root.
*/
cur->bc_ops->set_root(cur, newroot, -1);

error = cur->bc_ops->free_block(cur, bp);
if (error) {
XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
return error;
}

XFS_BTREE_STATS_INC(cur, free);

cur->bc_bufs[level] = NULL;
cur->bc_ra[level] = 0;
cur->bc_nlevels--;

XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
return 0;
}

STATIC int
xfs_btree_dec_cursor(
struct xfs_btree_cur *cur,
Expand Down Expand Up @@ -3195,7 +3229,7 @@ xfs_btree_delrec(
* Make it the new root of the btree.
*/
pp = xfs_btree_ptr_addr(cur, 1, block);
error = cur->bc_ops->kill_root(cur, bp, level, pp);
error = xfs_btree_kill_root(cur, bp, level, pp);
if (error)
goto error0;
} else if (level > 0) {
Expand Down
14 changes: 1 addition & 13 deletions trunk/fs/xfs/xfs_btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ struct xfs_btree_ops {

/* update btree root pointer */
void (*set_root)(struct xfs_btree_cur *cur,
union xfs_btree_ptr *nptr, int level_change);
int (*kill_root)(struct xfs_btree_cur *cur, struct xfs_buf *bp,
int level, union xfs_btree_ptr *newroot);
union xfs_btree_ptr *nptr, int level_change);

/* block allocation / freeing */
int (*alloc_block)(struct xfs_btree_cur *cur,
Expand Down Expand Up @@ -399,16 +397,6 @@ xfs_btree_reada_bufs(
xfs_agblock_t agbno, /* allocation group block number */
xfs_extlen_t count); /* count of filesystem blocks */

/*
* Set the buffer for level "lev" in the cursor to bp, releasing
* any previous buffer.
*/
void
xfs_btree_setbuf(
xfs_btree_cur_t *cur, /* btree cursor */
int lev, /* level in btree */
struct xfs_buf *bp); /* new buffer to set */


/*
* Common btree core entry points.
Expand Down
33 changes: 0 additions & 33 deletions trunk/fs/xfs/xfs_ialloc_btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,38 +183,6 @@ xfs_inobt_key_diff(
cur->bc_rec.i.ir_startino;
}

STATIC int
xfs_inobt_kill_root(
struct xfs_btree_cur *cur,
struct xfs_buf *bp,
int level,
union xfs_btree_ptr *newroot)
{
int error;

XFS_BTREE_TRACE_CURSOR(cur, XBT_ENTRY);
XFS_BTREE_STATS_INC(cur, killroot);

/*
* Update the root pointer, decreasing the level by 1 and then
* free the old root.
*/
xfs_inobt_set_root(cur, newroot, -1);
error = xfs_inobt_free_block(cur, bp);
if (error) {
XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
return error;
}

XFS_BTREE_STATS_INC(cur, free);

cur->bc_bufs[level] = NULL;
cur->bc_nlevels--;

XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
return 0;
}

#ifdef DEBUG
STATIC int
xfs_inobt_keys_inorder(
Expand Down Expand Up @@ -309,7 +277,6 @@ static const struct xfs_btree_ops xfs_inobt_ops = {

.dup_cursor = xfs_inobt_dup_cursor,
.set_root = xfs_inobt_set_root,
.kill_root = xfs_inobt_kill_root,
.alloc_block = xfs_inobt_alloc_block,
.free_block = xfs_inobt_free_block,
.get_minrecs = xfs_inobt_get_minrecs,
Expand Down

0 comments on commit 1126b10

Please sign in to comment.