]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - libxfs/xfs_alloc_btree.c
Merge whitespace changes over
[thirdparty/xfsprogs-dev.git] / libxfs / xfs_alloc_btree.c
index c6d0e0fdd725d7a18c6008e63a72946a6cba955d..1fc539cc56e41d142fbd5b525a851770f81ddc73 100644 (file)
@@ -1,32 +1,32 @@
 /*
- * 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/
  */
 
@@ -58,9 +58,9 @@ xfs_alloc_delrec(
        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 */
@@ -69,7 +69,7 @@ xfs_alloc_delrec(
        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 */
 
@@ -87,7 +87,7 @@ xfs_alloc_delrec(
        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
        /*
@@ -97,7 +97,7 @@ xfs_alloc_delrec(
                *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.
@@ -108,14 +108,14 @@ xfs_alloc_delrec(
                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);
@@ -128,7 +128,7 @@ xfs_alloc_delrec(
        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);
                }
@@ -201,9 +201,26 @@ xfs_alloc_delrec(
                        /*
                         * 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);
@@ -247,7 +264,7 @@ xfs_alloc_delrec(
         * 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
@@ -260,7 +277,7 @@ xfs_alloc_delrec(
                 */
                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);
@@ -271,7 +288,7 @@ xfs_alloc_delrec(
                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
                /*
@@ -285,7 +302,7 @@ xfs_alloc_delrec(
                 */
                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) >=
@@ -302,14 +319,14 @@ xfs_alloc_delrec(
                }
                /*
                 * 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);
                }
@@ -325,7 +342,7 @@ xfs_alloc_delrec(
                 */
                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);
@@ -335,7 +352,7 @@ xfs_alloc_delrec(
                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
                /*
@@ -349,7 +366,7 @@ xfs_alloc_delrec(
                 */
                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) >=
@@ -388,12 +405,12 @@ xfs_alloc_delrec(
                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;
        }
        /*
@@ -409,12 +426,12 @@ xfs_alloc_delrec(
                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;
        }
        /*
@@ -441,12 +458,12 @@ xfs_alloc_delrec(
                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,
@@ -457,7 +474,7 @@ xfs_alloc_delrec(
                 */
                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));
        }
@@ -486,19 +503,19 @@ xfs_alloc_delrec(
        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);
@@ -506,9 +523,24 @@ xfs_alloc_delrec(
        /*
         * 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
@@ -517,7 +549,7 @@ xfs_alloc_delrec(
         */
        if (level > 0)
                cur->bc_ptrs[level]--;
-       /* 
+       /*
         * Return value means the next level up has something to do.
         */
        *stat = 2;
@@ -563,8 +595,8 @@ xfs_alloc_insrec(
         * 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;
@@ -583,16 +615,16 @@ xfs_alloc_insrec(
                *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)) {
@@ -615,7 +647,7 @@ xfs_alloc_insrec(
                /*
                 * 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 */
@@ -624,7 +656,7 @@ xfs_alloc_insrec(
                 * 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];
@@ -635,16 +667,16 @@ xfs_alloc_insrec(
                                 * 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];
@@ -674,16 +706,16 @@ xfs_alloc_insrec(
                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
                /*
@@ -704,7 +736,7 @@ xfs_alloc_insrec(
                 * 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
@@ -792,7 +824,7 @@ xfs_alloc_log_block(
 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 */
 {
@@ -814,7 +846,7 @@ xfs_alloc_log_keys(
 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 */
 {
@@ -876,14 +908,14 @@ xfs_alloc_lookup(
 {
        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.
         */
@@ -903,8 +935,8 @@ xfs_alloc_lookup(
         * 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.
@@ -919,19 +951,19 @@ xfs_alloc_lookup(
                        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);
@@ -946,8 +978,8 @@ xfs_alloc_lookup(
                 */
                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 */
 
                        /*
@@ -978,7 +1010,7 @@ xfs_alloc_lookup(
                                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.
                                 */
@@ -1039,7 +1071,7 @@ xfs_alloc_lookup(
                                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;
@@ -1061,7 +1093,7 @@ xfs_alloc_lookup(
                        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;
@@ -1096,14 +1128,14 @@ xfs_alloc_lshift(
        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".
@@ -1111,7 +1143,7 @@ xfs_alloc_lshift(
        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
        /*
@@ -1122,7 +1154,7 @@ xfs_alloc_lshift(
                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) {
@@ -1132,12 +1164,12 @@ xfs_alloc_lshift(
        /*
         * 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.
@@ -1161,7 +1193,7 @@ xfs_alloc_lshift(
                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 */
@@ -1193,17 +1225,17 @@ xfs_alloc_lshift(
        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 */
@@ -1212,7 +1244,7 @@ xfs_alloc_lshift(
        /*
         * 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.
@@ -1232,15 +1264,15 @@ xfs_alloc_newroot(
 {
        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;
@@ -1249,8 +1281,8 @@ xfs_alloc_newroot(
        /*
         * 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.
@@ -1287,7 +1319,7 @@ xfs_alloc_newroot(
        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) {
@@ -1296,13 +1328,13 @@ xfs_alloc_newroot(
                 */
                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 {
@@ -1313,13 +1345,13 @@ xfs_alloc_newroot(
                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;
        }
@@ -1330,7 +1362,7 @@ xfs_alloc_newroot(
        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);
        /*
@@ -1389,9 +1421,9 @@ xfs_alloc_rshift(
        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 */
@@ -1402,7 +1434,7 @@ xfs_alloc_rshift(
        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
        /*
@@ -1423,12 +1455,12 @@ xfs_alloc_rshift(
        /*
         * 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.
@@ -1452,14 +1484,14 @@ xfs_alloc_rshift(
                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 */
@@ -1473,7 +1505,7 @@ xfs_alloc_rshift(
 
                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 */
@@ -1492,7 +1524,7 @@ xfs_alloc_rshift(
         * 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);
@@ -1523,18 +1555,18 @@ xfs_alloc_split(
        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;
@@ -1553,7 +1585,7 @@ xfs_alloc_split(
        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
        /*
@@ -1585,12 +1617,12 @@ xfs_alloc_split(
                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;
@@ -1604,7 +1636,7 @@ xfs_alloc_split(
 
                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 */
@@ -1626,14 +1658,14 @@ xfs_alloc_split(
         */
        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);
@@ -1652,7 +1684,7 @@ xfs_alloc_split(
         * 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]++;
        }
@@ -1680,7 +1712,7 @@ xfs_alloc_updkey(
         */
        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
@@ -1689,7 +1721,7 @@ xfs_alloc_updkey(
                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];
@@ -1736,8 +1768,8 @@ xfs_alloc_decrement(
         */
        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
        /*
@@ -1755,7 +1787,7 @@ xfs_alloc_decrement(
                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);
@@ -1770,17 +1802,17 @@ xfs_alloc_decrement(
         */
        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);
        }
@@ -1808,13 +1840,13 @@ xfs_alloc_delete(
         * 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;
                        }
@@ -1824,7 +1856,7 @@ xfs_alloc_delete(
        return 0;
 }
 
-/* 
+/*
  * Get the data from the pointed-to record.
  */
 int                                    /* error */
@@ -1843,7 +1875,7 @@ xfs_alloc_get_rec(
        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
        /*
@@ -1878,7 +1910,7 @@ xfs_alloc_increment(
        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 */
 
@@ -1893,7 +1925,7 @@ xfs_alloc_increment(
        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
        /*
@@ -1919,13 +1951,13 @@ xfs_alloc_increment(
                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);
@@ -1943,14 +1975,14 @@ xfs_alloc_increment(
                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;
        }
@@ -1991,8 +2023,8 @@ xfs_alloc_insert(
                 * 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;
@@ -2085,7 +2117,7 @@ xfs_alloc_update(
         */
        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
        /*
@@ -2129,7 +2161,7 @@ xfs_alloc_update(
 
                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;