/*
- * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
- *
+ * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
+ *
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
+ *
* Further, this software is distributed without any warranty that it is
* free of the rightful claim of any third person regarding infringement
* or the like. Any license provided herein, whether implied or
* otherwise, applies only to this software file. Patent licenses, if
* any, provided herein do not apply to combinations of this program with
* other software, or any other product whatsoever.
- *
+ *
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc., 59
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
+ *
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
* Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
+ *
+ * http://www.sgi.com
+ *
+ * For further information regarding this notice, see:
+ *
* http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
*/
xfs_agblock_t lbno; /* left block's block number */
xfs_buf_t *lbp; /* left block's buffer pointer */
xfs_alloc_block_t *left; /* left btree block */
- xfs_alloc_key_t *lkp; /* left block key pointer */
- xfs_alloc_ptr_t *lpp; /* left block address pointer */
- int lrecs; /* number of records in left block */
+ xfs_alloc_key_t *lkp=NULL; /* left block key pointer */
+ xfs_alloc_ptr_t *lpp=NULL; /* left block address pointer */
+ int lrecs=0; /* number of records in left block */
xfs_alloc_rec_t *lrp; /* left block record pointer */
xfs_mount_t *mp; /* mount structure */
int ptr; /* index in btree block for this rec */
xfs_alloc_block_t *right; /* right btree block */
xfs_alloc_key_t *rkp; /* right block key pointer */
xfs_alloc_ptr_t *rpp; /* right block address pointer */
- int rrecs; /* number of records in right block */
+ int rrecs=0; /* number of records in right block */
xfs_alloc_rec_t *rrp; /* right block record pointer */
xfs_btree_cur_t *tcur; /* temporary btree cursor */
bp = cur->bc_bufs[level];
block = XFS_BUF_TO_ALLOC_BLOCK(bp);
#ifdef DEBUG
- if (error = xfs_btree_check_sblock(cur, block, level, bp))
+ if ((error = xfs_btree_check_sblock(cur, block, level, bp)))
return error;
#endif
/*
*stat = 0;
return 0;
}
- XFS_STATS_INC(xs_abt_delrec);
+ XFS_STATS_INC(xfsstats.xs_abt_delrec);
/*
* It's a nonleaf. Excise the key and ptr being deleted, by
* sliding the entries past them down one.
lpp = XFS_ALLOC_PTR_ADDR(block, 1, cur);
#ifdef DEBUG
for (i = ptr; i < INT_GET(block->bb_numrecs, ARCH_CONVERT); i++) {
- if (error = xfs_btree_check_sptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))
+ if ((error = xfs_btree_check_sptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level)))
return error;
}
#endif
if (ptr < INT_GET(block->bb_numrecs, ARCH_CONVERT)) {
- ovbcopy(&lkp[ptr], &lkp[ptr - 1],
+ memmove(&lkp[ptr - 1], &lkp[ptr],
(INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr) * sizeof(*lkp)); /* INT_: mem copy */
- ovbcopy(&lpp[ptr], &lpp[ptr - 1],
+ memmove(&lpp[ptr - 1], &lpp[ptr],
(INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr) * sizeof(*lpp)); /* INT_: mem copy */
xfs_alloc_log_ptrs(cur, bp, ptr, INT_GET(block->bb_numrecs, ARCH_CONVERT) - 1);
xfs_alloc_log_keys(cur, bp, ptr, INT_GET(block->bb_numrecs, ARCH_CONVERT) - 1);
else {
lrp = XFS_ALLOC_REC_ADDR(block, 1, cur);
if (ptr < INT_GET(block->bb_numrecs, ARCH_CONVERT)) {
- ovbcopy(&lrp[ptr], &lrp[ptr - 1],
+ memmove(&lrp[ptr - 1], &lrp[ptr],
(INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr) * sizeof(*lrp));
xfs_alloc_log_recs(cur, bp, ptr, INT_GET(block->bb_numrecs, ARCH_CONVERT) - 1);
}
/*
* Put this buffer/block on the ag's freelist.
*/
- if (error = xfs_alloc_put_freelist(cur->bc_tp,
- cur->bc_private.a.agbp, NULL, bno))
+ if ((error = xfs_alloc_put_freelist(cur->bc_tp,
+ cur->bc_private.a.agbp, NULL, bno)))
return error;
+ /*
+ * Since blocks move to the free list without the
+ * coordination used in xfs_bmap_finish, we can't allow
+ * block to be available for reallocation and
+ * non-transaction writing (user data) until we know
+ * that the transaction that moved it to the free list
+ * is permanently on disk. We track the blocks by
+ * declaring these blocks as "busy"; the busy list is
+ * maintained on a per-ag basis and each transaction
+ * records which entries should be removed when the
+ * iclog commits to disk. If a busy block is
+ * allocated, the iclog is pushed up to the LSN
+ * that freed the block.
+ */
+ xfs_alloc_mark_busy(cur->bc_tp,
+ INT_GET(agf->agf_seqno, ARCH_CONVERT), bno, 1);
+
xfs_trans_agbtree_delta(cur->bc_tp, -1);
xfs_alloc_log_agf(cur->bc_tp, cur->bc_private.a.agbp,
XFS_AGF_ROOTS | XFS_AGF_LEVELS);
* Duplicate the cursor so our btree manipulations here won't
* disrupt the next level up.
*/
- if (error = xfs_btree_dup_cursor(cur, &tcur))
+ if ((error = xfs_btree_dup_cursor(cur, &tcur)))
return error;
/*
* If there's a right sibling, see if it's ok to shift an entry
*/
i = xfs_btree_lastrec(tcur, level);
XFS_WANT_CORRUPTED_GOTO(i == 1, error0);
- if (error = xfs_alloc_increment(tcur, level, &i))
+ if ((error = xfs_alloc_increment(tcur, level, &i)))
goto error0;
XFS_WANT_CORRUPTED_GOTO(i == 1, error0);
i = xfs_btree_lastrec(tcur, level);
rbp = tcur->bc_bufs[level];
right = XFS_BUF_TO_ALLOC_BLOCK(rbp);
#ifdef DEBUG
- if (error = xfs_btree_check_sblock(cur, right, level, rbp))
+ if ((error = xfs_btree_check_sblock(cur, right, level, rbp)))
goto error0;
#endif
/*
*/
if (INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1 >=
XFS_ALLOC_BLOCK_MINRECS(level, cur)) {
- if (error = xfs_alloc_lshift(tcur, level, &i))
+ if ((error = xfs_alloc_lshift(tcur, level, &i)))
goto error0;
if (i) {
ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >=
}
/*
* Otherwise, grab the number of records in right for
- * future reference, and fix up the temp cursor to point
+ * future reference, and fix up the temp cursor to point
* to our block again (last record).
*/
rrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT);
if (lbno != NULLAGBLOCK) {
i = xfs_btree_firstrec(tcur, level);
XFS_WANT_CORRUPTED_GOTO(i == 1, error0);
- if (error = xfs_alloc_decrement(tcur, level, &i))
+ if ((error = xfs_alloc_decrement(tcur, level, &i)))
goto error0;
XFS_WANT_CORRUPTED_GOTO(i == 1, error0);
}
*/
i = xfs_btree_firstrec(tcur, level);
XFS_WANT_CORRUPTED_GOTO(i == 1, error0);
- if (error = xfs_alloc_decrement(tcur, level, &i))
+ if ((error = xfs_alloc_decrement(tcur, level, &i)))
goto error0;
XFS_WANT_CORRUPTED_GOTO(i == 1, error0);
xfs_btree_firstrec(tcur, level);
lbp = tcur->bc_bufs[level];
left = XFS_BUF_TO_ALLOC_BLOCK(lbp);
#ifdef DEBUG
- if (error = xfs_btree_check_sblock(cur, left, level, lbp))
+ if ((error = xfs_btree_check_sblock(cur, left, level, lbp)))
goto error0;
#endif
/*
*/
if (INT_GET(left->bb_numrecs, ARCH_CONVERT) - 1 >=
XFS_ALLOC_BLOCK_MINRECS(level, cur)) {
- if (error = xfs_alloc_rshift(tcur, level, &i))
+ if ((error = xfs_alloc_rshift(tcur, level, &i)))
goto error0;
if (i) {
ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >=
rbno = bno;
right = block;
rbp = bp;
- if (error = xfs_btree_read_bufs(mp, cur->bc_tp,
+ if ((error = xfs_btree_read_bufs(mp, cur->bc_tp,
cur->bc_private.a.agno, lbno, 0, &lbp,
- XFS_ALLOC_BTREE_REF))
+ XFS_ALLOC_BTREE_REF)))
return error;
left = XFS_BUF_TO_ALLOC_BLOCK(lbp);
- if (error = xfs_btree_check_sblock(cur, left, level, lbp))
+ if ((error = xfs_btree_check_sblock(cur, left, level, lbp)))
return error;
}
/*
lbno = bno;
left = block;
lbp = bp;
- if (error = xfs_btree_read_bufs(mp, cur->bc_tp,
+ if ((error = xfs_btree_read_bufs(mp, cur->bc_tp,
cur->bc_private.a.agno, rbno, 0, &rbp,
- XFS_ALLOC_BTREE_REF))
+ XFS_ALLOC_BTREE_REF)))
return error;
right = XFS_BUF_TO_ALLOC_BLOCK(rbp);
- if (error = xfs_btree_check_sblock(cur, right, level, rbp))
+ if ((error = xfs_btree_check_sblock(cur, right, level, rbp)))
return error;
}
/*
rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur);
#ifdef DEBUG
for (i = 0; i < INT_GET(right->bb_numrecs, ARCH_CONVERT); i++) {
- if (error = xfs_btree_check_sptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))
+ if ((error = xfs_btree_check_sptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level)))
return error;
}
#endif
- bcopy(rkp, lkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*lkp)); /* INT_: structure copy */
- bcopy(rpp, lpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*lpp)); /* INT_: structure copy */
+ memcpy(lkp, rkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*lkp)); /* INT_: structure copy */
+ memcpy(lpp, rpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*lpp)); /* INT_: structure copy */
xfs_alloc_log_keys(cur, lbp, INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1,
INT_GET(left->bb_numrecs, ARCH_CONVERT) + INT_GET(right->bb_numrecs, ARCH_CONVERT));
xfs_alloc_log_ptrs(cur, lbp, INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1,
*/
lrp = XFS_ALLOC_REC_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1, cur);
rrp = XFS_ALLOC_REC_ADDR(right, 1, cur);
- bcopy(rrp, lrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*lrp));
+ memcpy(lrp, rrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*lrp));
xfs_alloc_log_recs(cur, lbp, INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1,
INT_GET(left->bb_numrecs, ARCH_CONVERT) + INT_GET(right->bb_numrecs, ARCH_CONVERT));
}
left->bb_rightsib = right->bb_rightsib; /* INT_: direct copy */
xfs_alloc_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB);
/*
- * If there is a right sibling now, make it point to the
+ * If there is a right sibling now, make it point to the
* remaining block.
*/
if (INT_GET(left->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) {
xfs_alloc_block_t *rrblock;
- xfs_buf_t *rrbp;
+ xfs_buf_t *rrbp;
- if (error = xfs_btree_read_bufs(mp, cur->bc_tp,
+ if ((error = xfs_btree_read_bufs(mp, cur->bc_tp,
cur->bc_private.a.agno, INT_GET(left->bb_rightsib, ARCH_CONVERT), 0,
- &rrbp, XFS_ALLOC_BTREE_REF))
+ &rrbp, XFS_ALLOC_BTREE_REF)))
return error;
rrblock = XFS_BUF_TO_ALLOC_BLOCK(rrbp);
- if (error = xfs_btree_check_sblock(cur, rrblock, level, rrbp))
+ if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp)))
return error;
INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, lbno);
xfs_alloc_log_block(cur->bc_tp, rrbp, XFS_BB_LEFTSIB);
/*
* Free the deleting block by putting it on the freelist.
*/
- if (error = xfs_alloc_put_freelist(cur->bc_tp, cur->bc_private.a.agbp,
- NULL, rbno))
+ if ((error = xfs_alloc_put_freelist(cur->bc_tp, cur->bc_private.a.agbp,
+ NULL, rbno)))
return error;
+ /*
+ * Since blocks move to the free list without the coordination
+ * used in xfs_bmap_finish, we can't allow block to be available
+ * for reallocation and non-transaction writing (user data)
+ * until we know that the transaction that moved it to the free
+ * list is permanently on disk. We track the blocks by declaring
+ * these blocks as "busy"; the busy list is maintained on a
+ * per-ag basis and each transaction records which entries
+ * should be removed when the iclog commits to disk. If a
+ * busy block is allocated, the iclog is pushed up to the
+ * LSN that freed the block.
+ */
+ xfs_alloc_mark_busy(cur->bc_tp,
+ INT_GET(agf->agf_seqno, ARCH_CONVERT), bno, 1);
+
xfs_trans_agbtree_delta(cur->bc_tp, -1);
/*
* Adjust the current level's cursor so that we're left referring
*/
if (level > 0)
cur->bc_ptrs[level]--;
- /*
+ /*
* Return value means the next level up has something to do.
*/
*stat = 2;
* and we're done.
*/
if (level >= cur->bc_nlevels) {
- XFS_STATS_INC(xs_abt_insrec);
- if (error = xfs_alloc_newroot(cur, &i))
+ XFS_STATS_INC(xfsstats.xs_abt_insrec);
+ if ((error = xfs_alloc_newroot(cur, &i)))
return error;
*bnop = NULLAGBLOCK;
*stat = i;
*stat = 0;
return 0;
}
- XFS_STATS_INC(xs_abt_insrec);
+ XFS_STATS_INC(xfsstats.xs_abt_insrec);
/*
* Get pointers to the btree buffer and block.
*/
bp = cur->bc_bufs[level];
block = XFS_BUF_TO_ALLOC_BLOCK(bp);
#ifdef DEBUG
- if (error = xfs_btree_check_sblock(cur, block, level, bp))
+ if ((error = xfs_btree_check_sblock(cur, block, level, bp)))
return error;
- /*
+ /*
* Check that the new entry is being inserted in the right place.
*/
if (ptr <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) {
/*
* First, try shifting an entry to the right neighbor.
*/
- if (error = xfs_alloc_rshift(cur, level, &i))
+ if ((error = xfs_alloc_rshift(cur, level, &i)))
return error;
if (i) {
/* nothing */
* Next, try shifting an entry to the left neighbor.
*/
else {
- if (error = xfs_alloc_lshift(cur, level, &i))
+ if ((error = xfs_alloc_lshift(cur, level, &i)))
return error;
if (i)
optr = ptr = cur->bc_ptrs[level];
* variables because we could be in a
* different block now.
*/
- if (error = xfs_alloc_split(cur, level, &nbno,
- &nkey, &ncur, &i))
+ if ((error = xfs_alloc_split(cur, level, &nbno,
+ &nkey, &ncur, &i)))
return error;
if (i) {
bp = cur->bc_bufs[level];
block = XFS_BUF_TO_ALLOC_BLOCK(bp);
#ifdef DEBUG
- if (error =
+ if ((error =
xfs_btree_check_sblock(cur,
- block, level, bp))
+ block, level, bp)))
return error;
#endif
ptr = cur->bc_ptrs[level];
pp = XFS_ALLOC_PTR_ADDR(block, 1, cur);
#ifdef DEBUG
for (i = INT_GET(block->bb_numrecs, ARCH_CONVERT); i >= ptr; i--) {
- if (error = xfs_btree_check_sptr(cur, INT_GET(pp[i - 1], ARCH_CONVERT), level))
+ if ((error = xfs_btree_check_sptr(cur, INT_GET(pp[i - 1], ARCH_CONVERT), level)))
return error;
}
#endif
- ovbcopy(&kp[ptr - 1], &kp[ptr],
+ memmove(&kp[ptr], &kp[ptr - 1],
(INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr + 1) * sizeof(*kp)); /* INT_: copy */
- ovbcopy(&pp[ptr - 1], &pp[ptr],
+ memmove(&pp[ptr], &pp[ptr - 1],
(INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr + 1) * sizeof(*pp)); /* INT_: copy */
#ifdef DEBUG
- if (error = xfs_btree_check_sptr(cur, *bnop, level))
+ if ((error = xfs_btree_check_sptr(cur, *bnop, level)))
return error;
#endif
/*
* It's a leaf entry. Make a hole for the new record.
*/
rp = XFS_ALLOC_REC_ADDR(block, 1, cur);
- ovbcopy(&rp[ptr - 1], &rp[ptr],
+ memmove(&rp[ptr], &rp[ptr - 1],
(INT_GET(block->bb_numrecs, ARCH_CONVERT) - ptr + 1) * sizeof(*rp));
/*
* Now stuff the new record in, bump numrecs
STATIC void
xfs_alloc_log_keys(
xfs_btree_cur_t *cur, /* btree cursor */
- xfs_buf_t *bp, /* buffer containing btree block */
+ xfs_buf_t *bp, /* buffer containing btree block */
int kfirst, /* index of first key to log */
int klast) /* index of last key to log */
{
STATIC void
xfs_alloc_log_ptrs(
xfs_btree_cur_t *cur, /* btree cursor */
- xfs_buf_t *bp, /* buffer containing btree block */
+ xfs_buf_t *bp, /* buffer containing btree block */
int pfirst, /* index of first pointer to log */
int plast) /* index of last pointer to log */
{
{
xfs_agblock_t agbno; /* a.g. relative btree block number */
xfs_agnumber_t agno; /* allocation group number */
- xfs_alloc_block_t *block; /* current btree block */
+ xfs_alloc_block_t *block=NULL; /* current btree block */
int diff; /* difference for the current key */
int error; /* error return value */
- int keyno; /* current key number */
+ int keyno=0; /* current key number */
int level; /* level in the btree */
xfs_mount_t *mp; /* file system mount point */
- XFS_STATS_INC(xs_abt_lookup);
+ XFS_STATS_INC(xfsstats.xs_abt_lookup);
/*
* Get the allocation group header, and the root block number.
*/
* pointer down to the next level.
*/
for (level = cur->bc_nlevels - 1, diff = 1; level >= 0; level--) {
- xfs_buf_t *bp; /* buffer pointer for btree block */
- xfs_daddr_t d; /* disk address of btree block */
+ xfs_buf_t *bp; /* buffer pointer for btree block */
+ xfs_daddr_t d; /* disk address of btree block */
/*
* Get the disk address we're looking for.
bp = (xfs_buf_t *)0;
if (!bp) {
/*
- * Need to get a new buffer. Read it, then
+ * Need to get a new buffer. Read it, then
* set it in the cursor, releasing the old one.
*/
- if (error = xfs_btree_read_bufs(mp, cur->bc_tp, agno,
- agbno, 0, &bp, XFS_ALLOC_BTREE_REF))
+ if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, agno,
+ agbno, 0, &bp, XFS_ALLOC_BTREE_REF)))
return error;
xfs_btree_setbuf(cur, level, bp);
/*
* Point to the btree block, now that we have the buffer
*/
block = XFS_BUF_TO_ALLOC_BLOCK(bp);
- if (error = xfs_btree_check_sblock(cur, block, level,
- bp))
+ if ((error = xfs_btree_check_sblock(cur, block, level,
+ bp)))
return error;
} else
block = XFS_BUF_TO_ALLOC_BLOCK(bp);
*/
else {
int high; /* high entry number */
- xfs_alloc_key_t *kkbase;/* base of keys in block */
- xfs_alloc_rec_t *krbase;/* base of records in block */
+ xfs_alloc_key_t *kkbase=NULL;/* base of keys in block */
+ xfs_alloc_rec_t *krbase=NULL;/* base of records in block */
int low; /* low entry number */
/*
xfs_extlen_t blockcount; /* key value */
xfs_agblock_t startblock; /* key value */
- XFS_STATS_INC(xs_abt_compare);
+ XFS_STATS_INC(xfsstats.xs_abt_compare);
/*
* keyno is average of low and high.
*/
keyno = 1;
agbno = INT_GET(*XFS_ALLOC_PTR_ADDR(block, keyno, cur), ARCH_CONVERT);
#ifdef DEBUG
- if (error = xfs_btree_check_sptr(cur, agbno, level))
+ if ((error = xfs_btree_check_sptr(cur, agbno, level)))
return error;
#endif
cur->bc_ptrs[level] = keyno;
int i;
cur->bc_ptrs[0] = keyno;
- if (error = xfs_alloc_increment(cur, 0, &i))
+ if ((error = xfs_alloc_increment(cur, 0, &i)))
return error;
XFS_WANT_CORRUPTED_RETURN(i == 1);
*stat = 1;
int i; /* loop index */
#endif
xfs_alloc_key_t key; /* key value for leaf level upward */
- xfs_buf_t *lbp; /* buffer for left neighbor block */
+ xfs_buf_t *lbp; /* buffer for left neighbor block */
xfs_alloc_block_t *left; /* left neighbor btree block */
int nrec; /* new number of left block entries */
- xfs_buf_t *rbp; /* buffer for right (current) block */
+ xfs_buf_t *rbp; /* buffer for right (current) block */
xfs_alloc_block_t *right; /* right (current) btree block */
- xfs_alloc_key_t *rkp; /* key pointer for right block */
- xfs_alloc_ptr_t *rpp; /* address pointer for right block */
- xfs_alloc_rec_t *rrp; /* record pointer for right block */
+ xfs_alloc_key_t *rkp=NULL; /* key pointer for right block */
+ xfs_alloc_ptr_t *rpp=NULL; /* address pointer for right block */
+ xfs_alloc_rec_t *rrp=NULL; /* record pointer for right block */
/*
* Set up variables for this block as "right".
rbp = cur->bc_bufs[level];
right = XFS_BUF_TO_ALLOC_BLOCK(rbp);
#ifdef DEBUG
- if (error = xfs_btree_check_sblock(cur, right, level, rbp))
+ if ((error = xfs_btree_check_sblock(cur, right, level, rbp)))
return error;
#endif
/*
return 0;
}
/*
- * If the cursor entry is the one that would be moved, don't
+ * If the cursor entry is the one that would be moved, don't
* do it... it's too complicated.
*/
if (cur->bc_ptrs[level] <= 1) {
/*
* Set up the left neighbor as "left".
*/
- if (error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
+ if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
cur->bc_private.a.agno, INT_GET(right->bb_leftsib, ARCH_CONVERT), 0, &lbp,
- XFS_ALLOC_BTREE_REF))
+ XFS_ALLOC_BTREE_REF)))
return error;
left = XFS_BUF_TO_ALLOC_BLOCK(lbp);
- if (error = xfs_btree_check_sblock(cur, left, level, lbp))
+ if ((error = xfs_btree_check_sblock(cur, left, level, lbp)))
return error;
/*
* If it's full, it can't take another entry.
lpp = XFS_ALLOC_PTR_ADDR(left, nrec, cur);
rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur);
#ifdef DEBUG
- if (error = xfs_btree_check_sptr(cur, INT_GET(*rpp, ARCH_CONVERT), level))
+ if ((error = xfs_btree_check_sptr(cur, INT_GET(*rpp, ARCH_CONVERT), level)))
return error;
#endif
*lpp = *rpp; /* INT_: copy */
if (level > 0) {
#ifdef DEBUG
for (i = 0; i < INT_GET(right->bb_numrecs, ARCH_CONVERT); i++) {
- if (error = xfs_btree_check_sptr(cur, INT_GET(rpp[i + 1], ARCH_CONVERT),
- level))
+ if ((error = xfs_btree_check_sptr(cur, INT_GET(rpp[i + 1], ARCH_CONVERT),
+ level)))
return error;
}
#endif
- ovbcopy(rkp + 1, rkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp));
- ovbcopy(rpp + 1, rpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp));
+ memmove(rkp, rkp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp));
+ memmove(rpp, rpp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp));
xfs_alloc_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT));
xfs_alloc_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT));
} else {
- ovbcopy(rrp + 1, rrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp));
+ memmove(rrp, rrp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp));
xfs_alloc_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT));
key.ar_startblock = rrp->ar_startblock; /* INT_: direct copy */
key.ar_blockcount = rrp->ar_blockcount; /* INT_: direct copy */
/*
* Update the parent key values of right.
*/
- if (error = xfs_alloc_updkey(cur, rkp, level + 1))
+ if ((error = xfs_alloc_updkey(cur, rkp, level + 1)))
return error;
/*
* Slide the cursor value left one.
{
int error; /* error return value */
xfs_agblock_t lbno; /* left block number */
- xfs_buf_t *lbp; /* left btree buffer */
+ xfs_buf_t *lbp; /* left btree buffer */
xfs_alloc_block_t *left; /* left btree block */
xfs_mount_t *mp; /* mount structure */
xfs_agblock_t nbno; /* new block number */
- xfs_buf_t *nbp; /* new (root) buffer */
+ xfs_buf_t *nbp; /* new (root) buffer */
xfs_alloc_block_t *new; /* new (root) btree block */
int nptr; /* new value for key index, 1 or 2 */
xfs_agblock_t rbno; /* right block number */
- xfs_buf_t *rbp; /* right btree buffer */
+ xfs_buf_t *rbp; /* right btree buffer */
xfs_alloc_block_t *right; /* right btree block */
mp = cur->bc_mp;
/*
* Get a buffer from the freelist blocks, for the new root.
*/
- if (error = xfs_alloc_get_freelist(cur->bc_tp, cur->bc_private.a.agbp,
- &nbno))
+ if ((error = xfs_alloc_get_freelist(cur->bc_tp, cur->bc_private.a.agbp,
+ &nbno)))
return error;
/*
* None available, we fail.
lbp = cur->bc_bufs[cur->bc_nlevels - 1];
left = XFS_BUF_TO_ALLOC_BLOCK(lbp);
#ifdef DEBUG
- if (error = xfs_btree_check_sblock(cur, left, cur->bc_nlevels - 1, lbp))
+ if ((error = xfs_btree_check_sblock(cur, left, cur->bc_nlevels - 1, lbp)))
return error;
#endif
if (INT_GET(left->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) {
*/
lbno = XFS_DADDR_TO_AGBNO(mp, XFS_BUF_ADDR(lbp));
rbno = INT_GET(left->bb_rightsib, ARCH_CONVERT);
- if (error = xfs_btree_read_bufs(mp, cur->bc_tp,
+ if ((error = xfs_btree_read_bufs(mp, cur->bc_tp,
cur->bc_private.a.agno, rbno, 0, &rbp,
- XFS_ALLOC_BTREE_REF))
+ XFS_ALLOC_BTREE_REF)))
return error;
right = XFS_BUF_TO_ALLOC_BLOCK(rbp);
- if (error = xfs_btree_check_sblock(cur, right,
- cur->bc_nlevels - 1, rbp))
+ if ((error = xfs_btree_check_sblock(cur, right,
+ cur->bc_nlevels - 1, rbp)))
return error;
nptr = 1;
} else {
right = left;
rbno = XFS_DADDR_TO_AGBNO(mp, XFS_BUF_ADDR(rbp));
lbno = INT_GET(right->bb_leftsib, ARCH_CONVERT);
- if (error = xfs_btree_read_bufs(mp, cur->bc_tp,
+ if ((error = xfs_btree_read_bufs(mp, cur->bc_tp,
cur->bc_private.a.agno, lbno, 0, &lbp,
- XFS_ALLOC_BTREE_REF))
+ XFS_ALLOC_BTREE_REF)))
return error;
left = XFS_BUF_TO_ALLOC_BLOCK(lbp);
- if (error = xfs_btree_check_sblock(cur, left,
- cur->bc_nlevels - 1, lbp))
+ if ((error = xfs_btree_check_sblock(cur, left,
+ cur->bc_nlevels - 1, lbp)))
return error;
nptr = 2;
}
INT_SET(new->bb_level, ARCH_CONVERT, (__uint16_t)cur->bc_nlevels);
INT_SET(new->bb_numrecs, ARCH_CONVERT, 2);
INT_SET(new->bb_leftsib, ARCH_CONVERT, NULLAGBLOCK);
- INT_SET(new->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK);
+ INT_SET(new->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK);
xfs_alloc_log_block(cur->bc_tp, nbp, XFS_BB_ALL_BITS);
ASSERT(lbno != NULLAGBLOCK && rbno != NULLAGBLOCK);
/*
int error; /* error return value */
int i; /* loop index */
xfs_alloc_key_t key; /* key value for leaf level upward */
- xfs_buf_t *lbp; /* buffer for left (current) block */
+ xfs_buf_t *lbp; /* buffer for left (current) block */
xfs_alloc_block_t *left; /* left (current) btree block */
- xfs_buf_t *rbp; /* buffer for right neighbor block */
+ xfs_buf_t *rbp; /* buffer for right neighbor block */
xfs_alloc_block_t *right; /* right neighbor btree block */
xfs_alloc_key_t *rkp; /* key pointer for right block */
xfs_btree_cur_t *tcur; /* temporary cursor */
lbp = cur->bc_bufs[level];
left = XFS_BUF_TO_ALLOC_BLOCK(lbp);
#ifdef DEBUG
- if (error = xfs_btree_check_sblock(cur, left, level, lbp))
+ if ((error = xfs_btree_check_sblock(cur, left, level, lbp)))
return error;
#endif
/*
/*
* Set up the right neighbor as "right".
*/
- if (error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
+ if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
cur->bc_private.a.agno, INT_GET(left->bb_rightsib, ARCH_CONVERT), 0, &rbp,
- XFS_ALLOC_BTREE_REF))
+ XFS_ALLOC_BTREE_REF)))
return error;
right = XFS_BUF_TO_ALLOC_BLOCK(rbp);
- if (error = xfs_btree_check_sblock(cur, right, level, rbp))
+ if ((error = xfs_btree_check_sblock(cur, right, level, rbp)))
return error;
/*
* If it's full, it can't take another entry.
rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur);
#ifdef DEBUG
for (i = INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1; i >= 0; i--) {
- if (error = xfs_btree_check_sptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))
+ if ((error = xfs_btree_check_sptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level)))
return error;
}
#endif
- ovbcopy(rkp, rkp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp));
- ovbcopy(rpp, rpp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp));
+ memmove(rkp + 1, rkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp));
+ memmove(rpp + 1, rpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp));
#ifdef DEBUG
- if (error = xfs_btree_check_sptr(cur, INT_GET(*lpp, ARCH_CONVERT), level))
+ if ((error = xfs_btree_check_sptr(cur, INT_GET(*lpp, ARCH_CONVERT), level)))
return error;
#endif
*rkp = *lkp; /* INT_: copy */
lrp = XFS_ALLOC_REC_ADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur);
rrp = XFS_ALLOC_REC_ADDR(right, 1, cur);
- ovbcopy(rrp, rrp + 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp));
+ memmove(rrp + 1, rrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp));
*rrp = *lrp;
xfs_alloc_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1);
key.ar_startblock = rrp->ar_startblock; /* INT_: direct copy */
* Using a temporary cursor, update the parent key values of the
* block on the right.
*/
- if (error = xfs_btree_dup_cursor(cur, &tcur))
+ if ((error = xfs_btree_dup_cursor(cur, &tcur)))
return error;
i = xfs_btree_lastrec(tcur, level);
XFS_WANT_CORRUPTED_GOTO(i == 1, error0);
int error; /* error return value */
int i; /* loop index/record number */
xfs_agblock_t lbno; /* left (current) block number */
- xfs_buf_t *lbp; /* buffer for left block */
+ xfs_buf_t *lbp; /* buffer for left block */
xfs_alloc_block_t *left; /* left (current) btree block */
xfs_agblock_t rbno; /* right (new) block number */
- xfs_buf_t *rbp; /* buffer for right block */
+ xfs_buf_t *rbp; /* buffer for right block */
xfs_alloc_block_t *right; /* right (new) btree block */
/*
* Allocate the new block from the freelist.
* If we can't do it, we're toast. Give up.
*/
- if (error = xfs_alloc_get_freelist(cur->bc_tp, cur->bc_private.a.agbp,
- &rbno))
+ if ((error = xfs_alloc_get_freelist(cur->bc_tp, cur->bc_private.a.agbp,
+ &rbno)))
return error;
if (rbno == NULLAGBLOCK) {
*stat = 0;
lbp = cur->bc_bufs[level];
left = XFS_BUF_TO_ALLOC_BLOCK(lbp);
#ifdef DEBUG
- if (error = xfs_btree_check_sblock(cur, left, level, lbp))
+ if ((error = xfs_btree_check_sblock(cur, left, level, lbp)))
return error;
#endif
/*
rpp = XFS_ALLOC_PTR_ADDR(right, 1, cur);
#ifdef DEBUG
for (i = 0; i < INT_GET(right->bb_numrecs, ARCH_CONVERT); i++) {
- if (error = xfs_btree_check_sptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))
+ if ((error = xfs_btree_check_sptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level)))
return error;
}
#endif
- bcopy(lkp, rkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); /* INT_: copy */
- bcopy(lpp, rpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp));/* INT_: copy */
+ memcpy(rkp, lkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); /* INT_: copy */
+ memcpy(rpp, lpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); /* INT_: copy */
xfs_alloc_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT));
xfs_alloc_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT));
*keyp = *rkp;
lrp = XFS_ALLOC_REC_ADDR(left, i, cur);
rrp = XFS_ALLOC_REC_ADDR(right, 1, cur);
- bcopy(lrp, rrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp));
+ memcpy(rrp, lrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp));
xfs_alloc_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT));
keyp->ar_startblock = rrp->ar_startblock; /* INT_: direct copy */
keyp->ar_blockcount = rrp->ar_blockcount; /* INT_: direct copy */
*/
if (INT_GET(right->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) {
xfs_alloc_block_t *rrblock; /* rr btree block */
- xfs_buf_t *rrbp; /* buffer for rrblock */
+ xfs_buf_t *rrbp; /* buffer for rrblock */
- if (error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
+ if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
cur->bc_private.a.agno, INT_GET(right->bb_rightsib, ARCH_CONVERT), 0,
- &rrbp, XFS_ALLOC_BTREE_REF))
+ &rrbp, XFS_ALLOC_BTREE_REF)))
return error;
rrblock = XFS_BUF_TO_ALLOC_BLOCK(rrbp);
- if (error = xfs_btree_check_sblock(cur, rrblock, level, rrbp))
+ if ((error = xfs_btree_check_sblock(cur, rrblock, level, rrbp)))
return error;
INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, rbno);
xfs_alloc_log_block(cur->bc_tp, rrbp, XFS_BB_LEFTSIB);
* the right block, no matter where this cursor was.
*/
if (level + 1 < cur->bc_nlevels) {
- if (error = xfs_btree_dup_cursor(cur, curp))
+ if ((error = xfs_btree_dup_cursor(cur, curp)))
return error;
(*curp)->bc_ptrs[level + 1]++;
}
*/
for (ptr = 1; ptr == 1 && level < cur->bc_nlevels; level++) {
xfs_alloc_block_t *block; /* btree block */
- xfs_buf_t *bp; /* buffer for block */
+ xfs_buf_t *bp; /* buffer for block */
#ifdef DEBUG
int error; /* error return value */
#endif
bp = cur->bc_bufs[level];
block = XFS_BUF_TO_ALLOC_BLOCK(bp);
#ifdef DEBUG
- if (error = xfs_btree_check_sblock(cur, block, level, bp))
+ if ((error = xfs_btree_check_sblock(cur, block, level, bp)))
return error;
#endif
ptr = cur->bc_ptrs[level];
*/
block = XFS_BUF_TO_ALLOC_BLOCK(cur->bc_bufs[level]);
#ifdef DEBUG
- if (error = xfs_btree_check_sblock(cur, block, level,
- cur->bc_bufs[level]))
+ if ((error = xfs_btree_check_sblock(cur, block, level,
+ cur->bc_bufs[level])))
return error;
#endif
/*
if (--cur->bc_ptrs[lev] > 0)
break;
/*
- * Read-ahead the left block, we're going to read it
+ * Read-ahead the left block, we're going to read it
* in the next loop.
*/
xfs_btree_readahead(cur, lev, XFS_BTCUR_LEFTRA);
*/
for (block = XFS_BUF_TO_ALLOC_BLOCK(cur->bc_bufs[lev]); lev > level; ) {
xfs_agblock_t agbno; /* block number of btree block */
- xfs_buf_t *bp; /* buffer pointer for block */
+ xfs_buf_t *bp; /* buffer pointer for block */
agbno = INT_GET(*XFS_ALLOC_PTR_ADDR(block, cur->bc_ptrs[lev], cur), ARCH_CONVERT);
- if (error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
+ if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
cur->bc_private.a.agno, agbno, 0, &bp,
- XFS_ALLOC_BTREE_REF))
+ XFS_ALLOC_BTREE_REF)))
return error;
lev--;
xfs_btree_setbuf(cur, lev, bp);
block = XFS_BUF_TO_ALLOC_BLOCK(bp);
- if (error = xfs_btree_check_sblock(cur, block, lev, bp))
+ if ((error = xfs_btree_check_sblock(cur, block, lev, bp)))
return error;
cur->bc_ptrs[lev] = INT_GET(block->bb_numrecs, ARCH_CONVERT);
}
* Otherwise we are done.
*/
for (level = 0, i = 2; i == 2; level++) {
- if (error = xfs_alloc_delrec(cur, level, &i))
+ if ((error = xfs_alloc_delrec(cur, level, &i)))
return error;
}
if (i == 0) {
for (level = 1; level < cur->bc_nlevels; level++) {
if (cur->bc_ptrs[level] == 0) {
- if (error = xfs_alloc_decrement(cur, level, &i))
+ if ((error = xfs_alloc_decrement(cur, level, &i)))
return error;
break;
}
return 0;
}
-/*
+/*
* Get the data from the pointed-to record.
*/
int /* error */
ptr = cur->bc_ptrs[0];
block = XFS_BUF_TO_ALLOC_BLOCK(cur->bc_bufs[0]);
#ifdef DEBUG
- if (error = xfs_btree_check_sblock(cur, block, 0, cur->bc_bufs[0]))
+ if ((error = xfs_btree_check_sblock(cur, block, 0, cur->bc_bufs[0])))
return error;
#endif
/*
int *stat) /* success/failure */
{
xfs_alloc_block_t *block; /* btree block */
- xfs_buf_t *bp; /* tree block buffer */
+ xfs_buf_t *bp; /* tree block buffer */
int error; /* error return value */
int lev; /* btree level */
bp = cur->bc_bufs[level];
block = XFS_BUF_TO_ALLOC_BLOCK(bp);
#ifdef DEBUG
- if (error = xfs_btree_check_sblock(cur, block, level, bp))
+ if ((error = xfs_btree_check_sblock(cur, block, level, bp)))
return error;
#endif
/*
bp = cur->bc_bufs[lev];
block = XFS_BUF_TO_ALLOC_BLOCK(bp);
#ifdef DEBUG
- if (error = xfs_btree_check_sblock(cur, block, lev, bp))
+ if ((error = xfs_btree_check_sblock(cur, block, lev, bp)))
return error;
#endif
if (++cur->bc_ptrs[lev] <= INT_GET(block->bb_numrecs, ARCH_CONVERT))
break;
/*
- * Read-ahead the right block, we're going to read it
+ * Read-ahead the right block, we're going to read it
* in the next loop.
*/
xfs_btree_readahead(cur, lev, XFS_BTCUR_RIGHTRA);
xfs_agblock_t agbno; /* block number of btree block */
agbno = INT_GET(*XFS_ALLOC_PTR_ADDR(block, cur->bc_ptrs[lev], cur), ARCH_CONVERT);
- if (error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
+ if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
cur->bc_private.a.agno, agbno, 0, &bp,
- XFS_ALLOC_BTREE_REF))
+ XFS_ALLOC_BTREE_REF)))
return error;
lev--;
xfs_btree_setbuf(cur, lev, bp);
block = XFS_BUF_TO_ALLOC_BLOCK(bp);
- if (error = xfs_btree_check_sblock(cur, block, lev, bp))
+ if ((error = xfs_btree_check_sblock(cur, block, lev, bp)))
return error;
cur->bc_ptrs[lev] = 1;
}
* Insert nrec/nbno into this level of the tree.
* Note if we fail, nbno will be null.
*/
- if (error = xfs_alloc_insrec(pcur, level++, &nbno, &nrec, &ncur,
- &i)) {
+ if ((error = xfs_alloc_insrec(pcur, level++, &nbno, &nrec, &ncur,
+ &i))) {
if (pcur != cur)
xfs_btree_del_cursor(pcur, XFS_BTREE_ERROR);
return error;
*/
block = XFS_BUF_TO_ALLOC_BLOCK(cur->bc_bufs[0]);
#ifdef DEBUG
- if (error = xfs_btree_check_sblock(cur, block, 0, cur->bc_bufs[0]))
+ if ((error = xfs_btree_check_sblock(cur, block, 0, cur->bc_bufs[0])))
return error;
#endif
/*
INT_SET(key.ar_startblock, ARCH_CONVERT, bno);
INT_SET(key.ar_blockcount, ARCH_CONVERT, len);
- if (error = xfs_alloc_updkey(cur, &key, 1))
+ if ((error = xfs_alloc_updkey(cur, &key, 1)))
return error;
}
return 0;