Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 339411
b: refs/heads/master
c: b64f3a3
h: refs/heads/master
i:
  339409: f683d80
  339407: 5692e40
v: v3
  • Loading branch information
Dave Chinner authored and Ben Myers committed Nov 13, 2012
1 parent 99e1130 commit 4dbe2c6
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 34 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: ee73259b401317117e7f5d4834c270b10b12bc8e
refs/heads/master: b64f3a390d3477517cbff7d613e551705540769b
33 changes: 24 additions & 9 deletions trunk/fs/xfs/xfs_btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,18 +853,22 @@ xfs_btree_set_sibling(
}
}

STATIC void
void
xfs_btree_init_block(
struct xfs_btree_cur *cur,
int level,
int numrecs,
struct xfs_btree_block *new) /* new block */
struct xfs_mount *mp,
struct xfs_buf *bp,
__u32 magic,
__u16 level,
__u16 numrecs,
unsigned int flags)
{
new->bb_magic = cpu_to_be32(xfs_magics[cur->bc_btnum]);
struct xfs_btree_block *new = XFS_BUF_TO_BLOCK(bp);

new->bb_magic = cpu_to_be32(magic);
new->bb_level = cpu_to_be16(level);
new->bb_numrecs = cpu_to_be16(numrecs);

if (cur->bc_flags & XFS_BTREE_LONG_PTRS) {
if (flags & XFS_BTREE_LONG_PTRS) {
new->bb_u.l.bb_leftsib = cpu_to_be64(NULLDFSBNO);
new->bb_u.l.bb_rightsib = cpu_to_be64(NULLDFSBNO);
} else {
Expand All @@ -873,6 +877,17 @@ xfs_btree_init_block(
}
}

STATIC void
xfs_btree_init_block_cur(
struct xfs_btree_cur *cur,
int level,
int numrecs,
struct xfs_buf *bp)
{
xfs_btree_init_block(cur->bc_mp, bp, xfs_magics[cur->bc_btnum],
level, numrecs, cur->bc_flags);
}

/*
* Return true if ptr is the last record in the btree and
* we need to track updateѕ to this record. The decision
Expand Down Expand Up @@ -2183,7 +2198,7 @@ xfs_btree_split(
goto error0;

/* Fill in the btree header for the new right block. */
xfs_btree_init_block(cur, xfs_btree_get_level(left), 0, right);
xfs_btree_init_block_cur(cur, xfs_btree_get_level(left), 0, rbp);

/*
* Split the entries between the old and the new block evenly.
Expand Down Expand Up @@ -2492,7 +2507,7 @@ xfs_btree_new_root(
nptr = 2;
}
/* Fill in the new block's btree header and log it. */
xfs_btree_init_block(cur, cur->bc_nlevels, 2, new);
xfs_btree_init_block_cur(cur, cur->bc_nlevels, 2, nbp);
xfs_btree_log_block(cur, nbp, XFS_BB_ALL_BITS);
ASSERT(!xfs_btree_ptr_is_null(cur, &lptr) &&
!xfs_btree_ptr_is_null(cur, &rptr));
Expand Down
11 changes: 11 additions & 0 deletions trunk/fs/xfs/xfs_btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,17 @@ xfs_btree_reada_bufs(
xfs_agblock_t agbno, /* allocation group block number */
xfs_extlen_t count); /* count of filesystem blocks */

/*
* Initialise a new btree block header
*/
void
xfs_btree_init_block(
struct xfs_mount *mp,
struct xfs_buf *bp,
__u32 magic,
__u16 level,
__u16 numrecs,
unsigned int flags);

/*
* Common btree core entry points.
Expand Down
37 changes: 13 additions & 24 deletions trunk/fs/xfs/xfs_fsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ xfs_growfs_data_private(
xfs_extlen_t agsize;
xfs_extlen_t tmpsize;
xfs_alloc_rec_t *arec;
struct xfs_btree_block *block;
xfs_buf_t *bp;
int bucket;
int dpct;
Expand Down Expand Up @@ -263,17 +262,14 @@ xfs_growfs_data_private(
error = ENOMEM;
goto error0;
}
block = XFS_BUF_TO_BLOCK(bp);
memset(block, 0, mp->m_sb.sb_blocksize);
block->bb_magic = cpu_to_be32(XFS_ABTB_MAGIC);
block->bb_level = 0;
block->bb_numrecs = cpu_to_be16(1);
block->bb_u.s.bb_leftsib = cpu_to_be32(NULLAGBLOCK);
block->bb_u.s.bb_rightsib = cpu_to_be32(NULLAGBLOCK);
arec = XFS_ALLOC_REC_ADDR(mp, block, 1);
xfs_buf_zero(bp, 0, BBTOB(bp->b_length));
xfs_btree_init_block(mp, bp, XFS_ABTB_MAGIC, 0, 1, 0);

arec = XFS_ALLOC_REC_ADDR(mp, XFS_BUF_TO_BLOCK(bp), 1);
arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp));
arec->ar_blockcount = cpu_to_be32(
agsize - be32_to_cpu(arec->ar_startblock));

error = xfs_bwrite(bp);
xfs_buf_relse(bp);
if (error)
Expand All @@ -289,18 +285,15 @@ xfs_growfs_data_private(
error = ENOMEM;
goto error0;
}
block = XFS_BUF_TO_BLOCK(bp);
memset(block, 0, mp->m_sb.sb_blocksize);
block->bb_magic = cpu_to_be32(XFS_ABTC_MAGIC);
block->bb_level = 0;
block->bb_numrecs = cpu_to_be16(1);
block->bb_u.s.bb_leftsib = cpu_to_be32(NULLAGBLOCK);
block->bb_u.s.bb_rightsib = cpu_to_be32(NULLAGBLOCK);
arec = XFS_ALLOC_REC_ADDR(mp, block, 1);
xfs_buf_zero(bp, 0, BBTOB(bp->b_length));
xfs_btree_init_block(mp, bp, XFS_ABTC_MAGIC, 0, 1, 0);

arec = XFS_ALLOC_REC_ADDR(mp, XFS_BUF_TO_BLOCK(bp), 1);
arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp));
arec->ar_blockcount = cpu_to_be32(
agsize - be32_to_cpu(arec->ar_startblock));
nfree += be32_to_cpu(arec->ar_blockcount);

error = xfs_bwrite(bp);
xfs_buf_relse(bp);
if (error)
Expand All @@ -316,13 +309,9 @@ xfs_growfs_data_private(
error = ENOMEM;
goto error0;
}
block = XFS_BUF_TO_BLOCK(bp);
memset(block, 0, mp->m_sb.sb_blocksize);
block->bb_magic = cpu_to_be32(XFS_IBT_MAGIC);
block->bb_level = 0;
block->bb_numrecs = 0;
block->bb_u.s.bb_leftsib = cpu_to_be32(NULLAGBLOCK);
block->bb_u.s.bb_rightsib = cpu_to_be32(NULLAGBLOCK);
xfs_buf_zero(bp, 0, BBTOB(bp->b_length));
xfs_btree_init_block(mp, bp, XFS_IBT_MAGIC, 0, 0, 0);

error = xfs_bwrite(bp);
xfs_buf_relse(bp);
if (error)
Expand Down

0 comments on commit 4dbe2c6

Please sign in to comment.