]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/xfs/xfs_ialloc_btree.c
[XFS] Use the same btree_cur union member for alloc and inobt trees.
[linux-2.6-omap-h63xx.git] / fs / xfs / xfs_ialloc_btree.c
index 616eeeb6953eb27e796102c7c0aa9b23092268a1..83502f3edef0d99477e6fb539418950ec9019c9b 100644 (file)
@@ -181,7 +181,7 @@ xfs_inobt_delrec(
                 * then we can get rid of this level.
                 */
                if (numrecs == 1 && level > 0) {
-                       agbp = cur->bc_private.i.agbp;
+                       agbp = cur->bc_private.a.agbp;
                        agi = XFS_BUF_TO_AGI(agbp);
                        /*
                         * pp is still set to the first pointer in the block.
@@ -189,12 +189,12 @@ xfs_inobt_delrec(
                         */
                        bno = be32_to_cpu(agi->agi_root);
                        agi->agi_root = *pp;
-                       be32_add(&agi->agi_level, -1);
+                       be32_add_cpu(&agi->agi_level, -1);
                        /*
                         * Free the block.
                         */
                        if ((error = xfs_free_extent(cur->bc_tp,
-                               XFS_AGB_TO_FSB(mp, cur->bc_private.i.agno, bno), 1)))
+                               XFS_AGB_TO_FSB(mp, cur->bc_private.a.agno, bno), 1)))
                                return error;
                        xfs_trans_binval(cur->bc_tp, bp);
                        xfs_ialloc_log_agi(cur->bc_tp, agbp,
@@ -379,7 +379,7 @@ xfs_inobt_delrec(
                rrecs = be16_to_cpu(right->bb_numrecs);
                rbp = bp;
                if ((error = xfs_btree_read_bufs(mp, cur->bc_tp,
-                               cur->bc_private.i.agno, lbno, 0, &lbp,
+                               cur->bc_private.a.agno, lbno, 0, &lbp,
                                XFS_INO_BTREE_REF)))
                        return error;
                left = XFS_BUF_TO_INOBT_BLOCK(lbp);
@@ -401,7 +401,7 @@ xfs_inobt_delrec(
                lrecs = be16_to_cpu(left->bb_numrecs);
                lbp = bp;
                if ((error = xfs_btree_read_bufs(mp, cur->bc_tp,
-                               cur->bc_private.i.agno, rbno, 0, &rbp,
+                               cur->bc_private.a.agno, rbno, 0, &rbp,
                                XFS_INO_BTREE_REF)))
                        return error;
                right = XFS_BUF_TO_INOBT_BLOCK(rbp);
@@ -484,7 +484,7 @@ xfs_inobt_delrec(
                xfs_buf_t               *rrbp;
 
                if ((error = xfs_btree_read_bufs(mp, cur->bc_tp,
-                               cur->bc_private.i.agno, be32_to_cpu(left->bb_rightsib), 0,
+                               cur->bc_private.a.agno, be32_to_cpu(left->bb_rightsib), 0,
                                &rrbp, XFS_INO_BTREE_REF)))
                        return error;
                rrblock = XFS_BUF_TO_INOBT_BLOCK(rrbp);
@@ -497,7 +497,7 @@ xfs_inobt_delrec(
         * Free the deleting block.
         */
        if ((error = xfs_free_extent(cur->bc_tp, XFS_AGB_TO_FSB(mp,
-                                    cur->bc_private.i.agno, rbno), 1)))
+                                    cur->bc_private.a.agno, rbno), 1)))
                return error;
        xfs_trans_binval(cur->bc_tp, rbp);
        /*
@@ -568,7 +568,7 @@ xfs_inobt_insrec(
        /*
         * Make a key out of the record data to be inserted, and save it.
         */
-       key.ir_startino = recp->ir_startino; /* INT_: direct copy */
+       key.ir_startino = recp->ir_startino;
        optr = ptr = cur->bc_ptrs[level];
        /*
         * If we're off the left edge, return failure.
@@ -600,7 +600,7 @@ xfs_inobt_insrec(
        }
 #endif
        nbno = NULLAGBLOCK;
-       ncur = (xfs_btree_cur_t *)0;
+       ncur = NULL;
        /*
         * If the block is full, we can't insert the new entry until we
         * make the block un-full.
@@ -641,7 +641,7 @@ xfs_inobt_insrec(
                                                return error;
 #endif
                                        ptr = cur->bc_ptrs[level];
-                                       nrec.ir_startino = nkey.ir_startino; /* INT_: direct copy */
+                                       nrec.ir_startino = nkey.ir_startino;
                                } else {
                                        /*
                                         * Otherwise the insert fails.
@@ -681,7 +681,7 @@ xfs_inobt_insrec(
                if ((error = xfs_btree_check_sptr(cur, *bnop, level)))
                        return error;
 #endif
-               kp[ptr - 1] = key; /* INT_: struct copy */
+               kp[ptr - 1] = key;
                pp[ptr - 1] = cpu_to_be32(*bnop);
                numrecs++;
                block->bb_numrecs = cpu_to_be16(numrecs);
@@ -698,7 +698,7 @@ xfs_inobt_insrec(
                 * Now stuff the new record in, bump numrecs
                 * and log the new data.
                 */
-               rp[ptr - 1] = *recp; /* INT_: struct copy */
+               rp[ptr - 1] = *recp;
                numrecs++;
                block->bb_numrecs = cpu_to_be16(numrecs);
                xfs_inobt_log_recs(cur, bp, ptr, numrecs);
@@ -731,7 +731,7 @@ xfs_inobt_insrec(
         */
        *bnop = nbno;
        if (nbno != NULLAGBLOCK) {
-               *recp = nrec; /* INT_: struct copy */
+               *recp = nrec;
                *curp = ncur;
        }
        *stat = 1;
@@ -854,7 +854,7 @@ xfs_inobt_lookup(
        {
                xfs_agi_t       *agi;   /* a.g. inode header */
 
-               agi = XFS_BUF_TO_AGI(cur->bc_private.i.agbp);
+               agi = XFS_BUF_TO_AGI(cur->bc_private.a.agbp);
                agno = be32_to_cpu(agi->agi_seqno);
                agbno = be32_to_cpu(agi->agi_root);
        }
@@ -878,7 +878,7 @@ xfs_inobt_lookup(
                 */
                bp = cur->bc_bufs[level];
                if (bp && XFS_BUF_ADDR(bp) != d)
-                       bp = (xfs_buf_t *)0;
+                       bp = NULL;
                if (!bp) {
                        /*
                         * Need to get a new buffer.  Read it, then
@@ -950,12 +950,12 @@ xfs_inobt_lookup(
                                        xfs_inobt_key_t *kkp;
 
                                        kkp = kkbase + keyno - 1;
-                                       startino = INT_GET(kkp->ir_startino, ARCH_CONVERT);
+                                       startino = be32_to_cpu(kkp->ir_startino);
                                } else {
                                        xfs_inobt_rec_t *krp;
 
                                        krp = krbase + keyno - 1;
-                                       startino = INT_GET(krp->ir_startino, ARCH_CONVERT);
+                                       startino = be32_to_cpu(krp->ir_startino);
                                }
                                /*
                                 * Compute difference to get next direction.
@@ -1089,7 +1089,7 @@ xfs_inobt_lshift(
         * Set up the left neighbor as "left".
         */
        if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
-                       cur->bc_private.i.agno, be32_to_cpu(right->bb_leftsib),
+                       cur->bc_private.a.agno, be32_to_cpu(right->bb_leftsib),
                        0, &lbp, XFS_INO_BTREE_REF)))
                return error;
        left = XFS_BUF_TO_INOBT_BLOCK(lbp);
@@ -1117,7 +1117,7 @@ xfs_inobt_lshift(
                if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*rpp), level)))
                        return error;
 #endif
-               *lpp = *rpp; /* INT_: no-change copy */
+               *lpp = *rpp;
                xfs_inobt_log_ptrs(cur, lbp, nrec, nrec);
        }
        /*
@@ -1132,7 +1132,7 @@ xfs_inobt_lshift(
        /*
         * Bump and log left's numrecs, decrement and log right's numrecs.
         */
-       be16_add(&left->bb_numrecs, 1);
+       be16_add_cpu(&left->bb_numrecs, 1);
        xfs_inobt_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS);
 #ifdef DEBUG
        if (level > 0)
@@ -1140,7 +1140,7 @@ xfs_inobt_lshift(
        else
                xfs_btree_check_rec(cur->bc_btnum, lrp - 1, lrp);
 #endif
-       be16_add(&right->bb_numrecs, -1);
+       be16_add_cpu(&right->bb_numrecs, -1);
        xfs_inobt_log_block(cur->bc_tp, rbp, XFS_BB_NUMRECS);
        /*
         * Slide the contents of right down one entry.
@@ -1160,7 +1160,7 @@ xfs_inobt_lshift(
        } else {
                memmove(rrp, rrp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
                xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
-               key.ir_startino = rrp->ir_startino; /* INT_: direct copy */
+               key.ir_startino = rrp->ir_startino;
                rkp = &key;
        }
        /*
@@ -1207,10 +1207,10 @@ xfs_inobt_newroot(
        /*
         * Get a block & a buffer.
         */
-       agi = XFS_BUF_TO_AGI(cur->bc_private.i.agbp);
+       agi = XFS_BUF_TO_AGI(cur->bc_private.a.agbp);
        args.tp = cur->bc_tp;
        args.mp = cur->bc_mp;
-       args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.i.agno,
+       args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.a.agno,
                be32_to_cpu(agi->agi_root));
        args.mod = args.minleft = args.alignment = args.total = args.wasdel =
                args.isfl = args.userdata = args.minalignslop = 0;
@@ -1232,8 +1232,8 @@ xfs_inobt_newroot(
         * Set the root data in the a.g. inode structure.
         */
        agi->agi_root = cpu_to_be32(args.agbno);
-       be32_add(&agi->agi_level, 1);
-       xfs_ialloc_log_agi(args.tp, cur->bc_private.i.agbp,
+       be32_add_cpu(&agi->agi_level, 1);
+       xfs_ialloc_log_agi(args.tp, cur->bc_private.a.agbp,
                XFS_AGI_ROOT | XFS_AGI_LEVEL);
        /*
         * At the previous root level there are now two blocks: the old
@@ -1297,13 +1297,13 @@ xfs_inobt_newroot(
         */
        kp = XFS_INOBT_KEY_ADDR(new, 1, cur);
        if (be16_to_cpu(left->bb_level) > 0) {
-               kp[0] = *XFS_INOBT_KEY_ADDR(left, 1, cur); /* INT_: struct copy */
-               kp[1] = *XFS_INOBT_KEY_ADDR(right, 1, cur); /* INT_: struct copy */
+               kp[0] = *XFS_INOBT_KEY_ADDR(left, 1, cur);
+               kp[1] = *XFS_INOBT_KEY_ADDR(right, 1, cur);
        } else {
                rp = XFS_INOBT_REC_ADDR(left, 1, cur);
-               INT_COPY(kp[0].ir_startino, rp->ir_startino, ARCH_CONVERT);
+               kp[0].ir_startino = rp->ir_startino;
                rp = XFS_INOBT_REC_ADDR(right, 1, cur);
-               INT_COPY(kp[1].ir_startino, rp->ir_startino, ARCH_CONVERT);
+               kp[1].ir_startino = rp->ir_startino;
        }
        xfs_inobt_log_keys(cur, nbp, 1, 2);
        /*
@@ -1376,7 +1376,7 @@ xfs_inobt_rshift(
         * Set up the right neighbor as "right".
         */
        if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
-                       cur->bc_private.i.agno, be32_to_cpu(left->bb_rightsib),
+                       cur->bc_private.a.agno, be32_to_cpu(left->bb_rightsib),
                        0, &rbp, XFS_INO_BTREE_REF)))
                return error;
        right = XFS_BUF_TO_INOBT_BLOCK(rbp);
@@ -1410,8 +1410,8 @@ xfs_inobt_rshift(
                if ((error = xfs_btree_check_sptr(cur, be32_to_cpu(*lpp), level)))
                        return error;
 #endif
-               *rkp = *lkp; /* INT_: no change copy */
-               *rpp = *lpp; /* INT_: no change copy */
+               *rkp = *lkp;
+               *rpp = *lpp;
                xfs_inobt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
                xfs_inobt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
        } else {
@@ -1420,15 +1420,15 @@ xfs_inobt_rshift(
                memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
                *rrp = *lrp;
                xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
-               key.ir_startino = rrp->ir_startino; /* INT_: direct copy */
+               key.ir_startino = rrp->ir_startino;
                rkp = &key;
        }
        /*
         * Decrement and log left's numrecs, bump and log right's numrecs.
         */
-       be16_add(&left->bb_numrecs, -1);
+       be16_add_cpu(&left->bb_numrecs, -1);
        xfs_inobt_log_block(cur->bc_tp, lbp, XFS_BB_NUMRECS);
-       be16_add(&right->bb_numrecs, 1);
+       be16_add_cpu(&right->bb_numrecs, 1);
 #ifdef DEBUG
        if (level > 0)
                xfs_btree_check_key(cur->bc_btnum, rkp, rkp + 1);
@@ -1492,7 +1492,7 @@ xfs_inobt_split(
         * Allocate the new block.
         * If we can't do it, we're toast.  Give up.
         */
-       args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.i.agno, lbno);
+       args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.a.agno, lbno);
        args.mod = args.minleft = args.alignment = args.total = args.wasdel =
                args.isfl = args.userdata = args.minalignslop = 0;
        args.minlen = args.maxlen = args.prod = 1;
@@ -1529,7 +1529,7 @@ xfs_inobt_split(
         */
        if ((be16_to_cpu(left->bb_numrecs) & 1) &&
            cur->bc_ptrs[level] <= be16_to_cpu(right->bb_numrecs) + 1)
-               be16_add(&right->bb_numrecs, 1);
+               be16_add_cpu(&right->bb_numrecs, 1);
        i = be16_to_cpu(left->bb_numrecs) - be16_to_cpu(right->bb_numrecs) + 1;
        /*
         * For non-leaf blocks, copy keys and addresses over to the new block.
@@ -1559,13 +1559,13 @@ xfs_inobt_split(
                rrp = XFS_INOBT_REC_ADDR(right, 1, cur);
                memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
                xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
-               keyp->ir_startino = rrp->ir_startino; /* INT_: direct copy */
+               keyp->ir_startino = rrp->ir_startino;
        }
        /*
         * Find the left block number by looking in the buffer.
         * Adjust numrecs, sibling pointers.
         */
-       be16_add(&left->bb_numrecs, -(be16_to_cpu(right->bb_numrecs)));
+       be16_add_cpu(&left->bb_numrecs, -(be16_to_cpu(right->bb_numrecs)));
        right->bb_rightsib = left->bb_rightsib;
        left->bb_rightsib = cpu_to_be32(args.agbno);
        right->bb_leftsib = cpu_to_be32(lbno);
@@ -1725,7 +1725,7 @@ xfs_inobt_decrement(
 
                agbno = be32_to_cpu(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur));
                if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
-                               cur->bc_private.i.agno, agbno, 0, &bp,
+                               cur->bc_private.a.agno, agbno, 0, &bp,
                                XFS_INO_BTREE_REF)))
                        return error;
                lev--;
@@ -1813,9 +1813,9 @@ xfs_inobt_get_rec(
         * Point to the record and extract its data.
         */
        rec = XFS_INOBT_REC_ADDR(block, ptr, cur);
-       *ino = INT_GET(rec->ir_startino, ARCH_CONVERT);
-       *fcnt = INT_GET(rec->ir_freecount, ARCH_CONVERT);
-       *free = INT_GET(rec->ir_free, ARCH_CONVERT);
+       *ino = be32_to_cpu(rec->ir_startino);
+       *fcnt = be32_to_cpu(rec->ir_freecount);
+       *free = be64_to_cpu(rec->ir_free);
        *stat = 1;
        return 0;
 }
@@ -1897,7 +1897,7 @@ xfs_inobt_increment(
 
                agbno = be32_to_cpu(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur));
                if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
-                               cur->bc_private.i.agno, agbno, 0, &bp,
+                               cur->bc_private.a.agno, agbno, 0, &bp,
                                XFS_INO_BTREE_REF)))
                        return error;
                lev--;
@@ -1930,10 +1930,10 @@ xfs_inobt_insert(
 
        level = 0;
        nbno = NULLAGBLOCK;
-       INT_SET(nrec.ir_startino, ARCH_CONVERT, cur->bc_rec.i.ir_startino);
-       INT_SET(nrec.ir_freecount, ARCH_CONVERT, cur->bc_rec.i.ir_freecount);
-       INT_SET(nrec.ir_free, ARCH_CONVERT, cur->bc_rec.i.ir_free);
-       ncur = (xfs_btree_cur_t *)0;
+       nrec.ir_startino = cpu_to_be32(cur->bc_rec.i.ir_startino);
+       nrec.ir_freecount = cpu_to_be32(cur->bc_rec.i.ir_freecount);
+       nrec.ir_free = cpu_to_be64(cur->bc_rec.i.ir_free);
+       ncur = NULL;
        pcur = cur;
        /*
         * Loop going up the tree, starting at the leaf level.
@@ -1965,7 +1965,7 @@ xfs_inobt_insert(
                 */
                if (ncur) {
                        pcur = ncur;
-                       ncur = (xfs_btree_cur_t *)0;
+                       ncur = NULL;
                }
        } while (nbno != NULLAGBLOCK);
        *stat = i;
@@ -2060,9 +2060,9 @@ xfs_inobt_update(
        /*
         * Fill in the new contents and log them.
         */
-       INT_SET(rp->ir_startino, ARCH_CONVERT, ino);
-       INT_SET(rp->ir_freecount, ARCH_CONVERT, fcnt);
-       INT_SET(rp->ir_free, ARCH_CONVERT, free);
+       rp->ir_startino = cpu_to_be32(ino);
+       rp->ir_freecount = cpu_to_be32(fcnt);
+       rp->ir_free = cpu_to_be64(free);
        xfs_inobt_log_recs(cur, bp, ptr, ptr);
        /*
         * Updating first record in leaf. Pass new key value up to our parent.
@@ -2070,7 +2070,7 @@ xfs_inobt_update(
        if (ptr == 1) {
                xfs_inobt_key_t key;    /* key containing [ino] */
 
-               INT_SET(key.ir_startino, ARCH_CONVERT, ino);
+               key.ir_startino = cpu_to_be32(ino);
                if ((error = xfs_inobt_updkey(cur, &key, 1)))
                        return error;
        }