ath5k: fix NULL pointer in antenna configuration
[safe/jmp/linux-2.6] / fs / xfs / xfs_trans_buf.c
index 4229136..fb58636 100644 (file)
 #include "xfs_trans.h"
 #include "xfs_sb.h"
 #include "xfs_ag.h"
-#include "xfs_dir.h"
 #include "xfs_dir2.h"
 #include "xfs_dmapi.h"
 #include "xfs_mount.h"
 #include "xfs_bmap_btree.h"
 #include "xfs_alloc_btree.h"
 #include "xfs_ialloc_btree.h"
-#include "xfs_dir_sf.h"
 #include "xfs_dir2_sf.h"
 #include "xfs_attr_sf.h"
 #include "xfs_dinode.h"
@@ -40,6 +38,7 @@
 #include "xfs_trans_priv.h"
 #include "xfs_error.h"
 #include "xfs_rw.h"
+#include "xfs_trace.h"
 
 
 STATIC xfs_buf_t *xfs_trans_buf_item_match(xfs_trans_t *, xfs_buftarg_t *,
@@ -47,6 +46,65 @@ STATIC xfs_buf_t *xfs_trans_buf_item_match(xfs_trans_t *, xfs_buftarg_t *,
 STATIC xfs_buf_t *xfs_trans_buf_item_match_all(xfs_trans_t *, xfs_buftarg_t *,
                xfs_daddr_t, int);
 
+/*
+ * Add the locked buffer to the transaction.
+ *
+ * The buffer must be locked, and it cannot be associated with any
+ * transaction.
+ *
+ * If the buffer does not yet have a buf log item associated with it,
+ * then allocate one for it.  Then add the buf item to the transaction.
+ */
+STATIC void
+_xfs_trans_bjoin(
+       struct xfs_trans        *tp,
+       struct xfs_buf          *bp,
+       int                     reset_recur)
+{
+       struct xfs_buf_log_item *bip;
+
+       ASSERT(XFS_BUF_ISBUSY(bp));
+       ASSERT(XFS_BUF_FSPRIVATE2(bp, void *) == NULL);
+
+       /*
+        * The xfs_buf_log_item pointer is stored in b_fsprivate.  If
+        * it doesn't have one yet, then allocate one and initialize it.
+        * The checks to see if one is there are in xfs_buf_item_init().
+        */
+       xfs_buf_item_init(bp, tp->t_mountp);
+       bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *);
+       ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
+       ASSERT(!(bip->bli_format.blf_flags & XFS_BLI_CANCEL));
+       ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED));
+       if (reset_recur)
+               bip->bli_recur = 0;
+
+       /*
+        * Take a reference for this transaction on the buf item.
+        */
+       atomic_inc(&bip->bli_refcount);
+
+       /*
+        * Get a log_item_desc to point at the new item.
+        */
+       (void) xfs_trans_add_item(tp, (xfs_log_item_t *)bip);
+
+       /*
+        * Initialize b_fsprivate2 so we can find it with incore_match()
+        * in xfs_trans_get_buf() and friends above.
+        */
+       XFS_BUF_SET_FSPRIVATE2(bp, tp);
+
+}
+
+void
+xfs_trans_bjoin(
+       struct xfs_trans        *tp,
+       struct xfs_buf          *bp)
+{
+       _xfs_trans_bjoin(tp, bp, 0);
+       trace_xfs_trans_bjoin(bp->b_fspriv);
+}
 
 /*
  * Get and lock the buffer for the caller if it is not already
@@ -76,16 +134,14 @@ xfs_trans_get_buf(xfs_trans_t      *tp,
        xfs_buf_log_item_t      *bip;
 
        if (flags == 0)
-               flags = XFS_BUF_LOCK | XFS_BUF_MAPPED;
+               flags = XBF_LOCK | XBF_MAPPED;
 
        /*
         * Default to a normal get_buf() call if the tp is NULL.
         */
-       if (tp == NULL) {
-               bp = xfs_buf_get_flags(target_dev, blkno, len,
-                                                       flags | BUF_BUSY);
-               return(bp);
-       }
+       if (tp == NULL)
+               return xfs_buf_get(target_dev, blkno, len,
+                                  flags | XBF_DONT_BLOCK);
 
        /*
         * If we find the buffer in the cache with this transaction
@@ -100,79 +156,43 @@ xfs_trans_get_buf(xfs_trans_t     *tp,
        }
        if (bp != NULL) {
                ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);
-               if (XFS_FORCED_SHUTDOWN(tp->t_mountp)) {
-                       xfs_buftrace("TRANS GET RECUR SHUT", bp);
+               if (XFS_FORCED_SHUTDOWN(tp->t_mountp))
                        XFS_BUF_SUPER_STALE(bp);
-               }
+
                /*
                 * If the buffer is stale then it was binval'ed
                 * since last read.  This doesn't matter since the
                 * caller isn't allowed to use the data anyway.
                 */
-               else if (XFS_BUF_ISSTALE(bp)) {
-                       xfs_buftrace("TRANS GET RECUR STALE", bp);
+               else if (XFS_BUF_ISSTALE(bp))
                        ASSERT(!XFS_BUF_ISDELAYWRITE(bp));
-               }
+
                ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp);
                bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *);
                ASSERT(bip != NULL);
                ASSERT(atomic_read(&bip->bli_refcount) > 0);
                bip->bli_recur++;
-               xfs_buftrace("TRANS GET RECUR", bp);
-               xfs_buf_item_trace("GET RECUR", bip);
+               trace_xfs_trans_get_buf_recur(bip);
                return (bp);
        }
 
        /*
-        * We always specify the BUF_BUSY flag within a transaction so
-        * that get_buf does not try to push out a delayed write buffer
+        * We always specify the XBF_DONT_BLOCK flag within a transaction
+        * so that get_buf does not try to push out a delayed write buffer
         * which might cause another transaction to take place (if the
         * buffer was delayed alloc).  Such recursive transactions can
         * easily deadlock with our current transaction as well as cause
         * us to run out of stack space.
         */
-       bp = xfs_buf_get_flags(target_dev, blkno, len, flags | BUF_BUSY);
+       bp = xfs_buf_get(target_dev, blkno, len, flags | XBF_DONT_BLOCK);
        if (bp == NULL) {
                return NULL;
        }
 
        ASSERT(!XFS_BUF_GETERROR(bp));
 
-       /*
-        * The xfs_buf_log_item pointer is stored in b_fsprivate.  If
-        * it doesn't have one yet, then allocate one and initialize it.
-        * The checks to see if one is there are in xfs_buf_item_init().
-        */
-       xfs_buf_item_init(bp, tp->t_mountp);
-
-       /*
-        * Set the recursion count for the buffer within this transaction
-        * to 0.
-        */
-       bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t*);
-       ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
-       ASSERT(!(bip->bli_format.blf_flags & XFS_BLI_CANCEL));
-       ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED));
-       bip->bli_recur = 0;
-
-       /*
-        * Take a reference for this transaction on the buf item.
-        */
-       atomic_inc(&bip->bli_refcount);
-
-       /*
-        * Get a log_item_desc to point at the new item.
-        */
-       (void) xfs_trans_add_item(tp, (xfs_log_item_t*)bip);
-
-       /*
-        * Initialize b_fsprivate2 so we can find it with incore_match()
-        * above.
-        */
-       XFS_BUF_SET_FSPRIVATE2(bp, tp);
-
-       xfs_buftrace("TRANS GET", bp);
-       xfs_buf_item_trace("GET", bip);
+       _xfs_trans_bjoin(tp, bp, 1);
+       trace_xfs_trans_get_buf(bp->b_fspriv);
        return (bp);
 }
 
@@ -212,49 +232,16 @@ xfs_trans_getsb(xfs_trans_t       *tp,
                ASSERT(bip != NULL);
                ASSERT(atomic_read(&bip->bli_refcount) > 0);
                bip->bli_recur++;
-               xfs_buf_item_trace("GETSB RECUR", bip);
+               trace_xfs_trans_getsb_recur(bip);
                return (bp);
        }
 
        bp = xfs_getsb(mp, flags);
-       if (bp == NULL) {
+       if (bp == NULL)
                return NULL;
-       }
-
-       /*
-        * The xfs_buf_log_item pointer is stored in b_fsprivate.  If
-        * it doesn't have one yet, then allocate one and initialize it.
-        * The checks to see if one is there are in xfs_buf_item_init().
-        */
-       xfs_buf_item_init(bp, mp);
-
-       /*
-        * Set the recursion count for the buffer within this transaction
-        * to 0.
-        */
-       bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t*);
-       ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
-       ASSERT(!(bip->bli_format.blf_flags & XFS_BLI_CANCEL));
-       ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED));
-       bip->bli_recur = 0;
 
-       /*
-        * Take a reference for this transaction on the buf item.
-        */
-       atomic_inc(&bip->bli_refcount);
-
-       /*
-        * Get a log_item_desc to point at the new item.
-        */
-       (void) xfs_trans_add_item(tp, (xfs_log_item_t*)bip);
-
-       /*
-        * Initialize b_fsprivate2 so we can find it with incore_match()
-        * above.
-        */
-       XFS_BUF_SET_FSPRIVATE2(bp, tp);
-
-       xfs_buf_item_trace("GETSB", bip);
+       _xfs_trans_bjoin(tp, bp, 1);
+       trace_xfs_trans_getsb(bp->b_fspriv);
        return (bp);
 }
 
@@ -298,17 +285,18 @@ xfs_trans_read_buf(
        int                     error;
 
        if (flags == 0)
-               flags = XFS_BUF_LOCK | XFS_BUF_MAPPED;
+               flags = XBF_LOCK | XBF_MAPPED;
 
        /*
         * Default to a normal get_buf() call if the tp is NULL.
         */
        if (tp == NULL) {
-               bp = xfs_buf_read_flags(target, blkno, len, flags | BUF_BUSY);
+               bp = xfs_buf_read(target, blkno, len, flags | XBF_DONT_BLOCK);
                if (!bp)
-                       return XFS_ERROR(ENOMEM);
+                       return (flags & XBF_TRYLOCK) ?
+                                       EAGAIN : XFS_ERROR(ENOMEM);
 
-               if ((bp != NULL) && (XFS_BUF_GETERROR(bp) != 0)) {
+               if (XFS_BUF_GETERROR(bp) != 0) {
                        xfs_ioerror_alert("xfs_trans_read_buf", mp,
                                          bp, blkno);
                        error = XFS_BUF_GETERROR(bp);
@@ -316,11 +304,11 @@ xfs_trans_read_buf(
                        return error;
                }
 #ifdef DEBUG
-               if (xfs_do_error && (bp != NULL)) {
+               if (xfs_do_error) {
                        if (xfs_error_target == target) {
                                if (((xfs_req_num++) % xfs_error_mod) == 0) {
                                        xfs_buf_relse(bp);
-                                       printk("Returning error!\n");
+                                       cmn_err(CE_DEBUG, "Returning error!\n");
                                        return XFS_ERROR(EIO);
                                }
                        }
@@ -351,21 +339,19 @@ xfs_trans_read_buf(
                ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL);
                ASSERT((XFS_BUF_ISERROR(bp)) == 0);
                if (!(XFS_BUF_ISDONE(bp))) {
-                       xfs_buftrace("READ_BUF_INCORE !DONE", bp);
+                       trace_xfs_trans_read_buf_io(bp, _RET_IP_);
                        ASSERT(!XFS_BUF_ISASYNC(bp));
                        XFS_BUF_READ(bp);
                        xfsbdstrat(tp->t_mountp, bp);
-                       xfs_iowait(bp);
-                       if (XFS_BUF_GETERROR(bp) != 0) {
+                       error = xfs_iowait(bp);
+                       if (error) {
                                xfs_ioerror_alert("xfs_trans_read_buf", mp,
                                                  bp, blkno);
-                               error = XFS_BUF_GETERROR(bp);
                                xfs_buf_relse(bp);
                                /*
-                                * We can gracefully recover from most
-                                * read errors. Ones we can't are those
-                                * that happen after the transaction's
-                                * already dirty.
+                                * We can gracefully recover from most read
+                                * errors. Ones we can't are those that happen
+                                * after the transaction's already dirty.
                                 */
                                if (tp->t_flags & XFS_TRANS_DIRTY)
                                        xfs_force_shutdown(tp->t_mountp,
@@ -378,7 +364,7 @@ xfs_trans_read_buf(
                 * brelse it either. Just get out.
                 */
                if (XFS_FORCED_SHUTDOWN(mp)) {
-                       xfs_buftrace("READ_BUF_INCORE XFSSHUTDN", bp);
+                       trace_xfs_trans_read_buf_shut(bp, _RET_IP_);
                        *bpp = NULL;
                        return XFS_ERROR(EIO);
                }
@@ -388,27 +374,26 @@ xfs_trans_read_buf(
                bip->bli_recur++;
 
                ASSERT(atomic_read(&bip->bli_refcount) > 0);
-               xfs_buf_item_trace("READ RECUR", bip);
+               trace_xfs_trans_read_buf_recur(bip);
                *bpp = bp;
                return 0;
        }
 
        /*
-        * We always specify the BUF_BUSY flag within a transaction so
-        * that get_buf does not try to push out a delayed write buffer
+        * We always specify the XBF_DONT_BLOCK flag within a transaction
+        * so that get_buf does not try to push out a delayed write buffer
         * which might cause another transaction to take place (if the
         * buffer was delayed alloc).  Such recursive transactions can
         * easily deadlock with our current transaction as well as cause
         * us to run out of stack space.
         */
-       bp = xfs_buf_read_flags(target, blkno, len, flags | BUF_BUSY);
+       bp = xfs_buf_read(target, blkno, len, flags | XBF_DONT_BLOCK);
        if (bp == NULL) {
                *bpp = NULL;
                return 0;
        }
        if (XFS_BUF_GETERROR(bp) != 0) {
            XFS_BUF_SUPER_STALE(bp);
-               xfs_buftrace("READ ERROR", bp);
                error = XFS_BUF_GETERROR(bp);
 
                xfs_ioerror_alert("xfs_trans_read_buf", mp,
@@ -425,7 +410,7 @@ xfs_trans_read_buf(
                                xfs_force_shutdown(tp->t_mountp,
                                                   SHUTDOWN_META_IO_ERROR);
                                xfs_buf_relse(bp);
-                               printk("Returning error in trans!\n");
+                               cmn_err(CE_DEBUG, "Returning trans error!\n");
                                return XFS_ERROR(EIO);
                        }
                }
@@ -434,41 +419,9 @@ xfs_trans_read_buf(
        if (XFS_FORCED_SHUTDOWN(mp))
                goto shutdown_abort;
 
-       /*
-        * The xfs_buf_log_item pointer is stored in b_fsprivate.  If
-        * it doesn't have one yet, then allocate one and initialize it.
-        * The checks to see if one is there are in xfs_buf_item_init().
-        */
-       xfs_buf_item_init(bp, tp->t_mountp);
-
-       /*
-        * Set the recursion count for the buffer within this transaction
-        * to 0.
-        */
-       bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t*);
-       ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
-       ASSERT(!(bip->bli_format.blf_flags & XFS_BLI_CANCEL));
-       ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED));
-       bip->bli_recur = 0;
-
-       /*
-        * Take a reference for this transaction on the buf item.
-        */
-       atomic_inc(&bip->bli_refcount);
-
-       /*
-        * Get a log_item_desc to point at the new item.
-        */
-       (void) xfs_trans_add_item(tp, (xfs_log_item_t*)bip);
+       _xfs_trans_bjoin(tp, bp, 1);
+       trace_xfs_trans_read_buf(bp->b_fspriv);
 
-       /*
-        * Initialize b_fsprivate2 so we can find it with incore_match()
-        * above.
-        */
-       XFS_BUF_SET_FSPRIVATE2(bp, tp);
-
-       xfs_buftrace("TRANS READ", bp);
-       xfs_buf_item_trace("READ", bip);
        *bpp = bp;
        return 0;
 
@@ -483,10 +436,10 @@ shutdown_abort:
        if (XFS_BUF_ISSTALE(bp) && XFS_BUF_ISDELAYWRITE(bp))
                cmn_err(CE_NOTE, "about to pop assert, bp == 0x%p", bp);
 #endif
-       ASSERT((XFS_BUF_BFLAGS(bp) & (XFS_B_STALE|XFS_B_DELWRI)) !=
-                                               (XFS_B_STALE|XFS_B_DELWRI));
+       ASSERT((XFS_BUF_BFLAGS(bp) & (XBF_STALE|XBF_DELWRI)) !=
+                                    (XBF_STALE|XBF_DELWRI));
 
-       xfs_buftrace("READ_BUF XFSSHUTDN", bp);
+       trace_xfs_trans_read_buf_shut(bp, _RET_IP_);
        xfs_buf_relse(bp);
        *bpp = NULL;
        return XFS_ERROR(EIO);
@@ -530,9 +483,8 @@ xfs_trans_brelse(xfs_trans_t        *tp,
                        lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
                        if (lip->li_type == XFS_LI_BUF) {
                                bip = XFS_BUF_FSPRIVATE(bp,xfs_buf_log_item_t*);
-                               xfs_trans_unlocked_item(
-                                               bip->bli_item.li_mountp,
-                                               lip);
+                               xfs_trans_unlocked_item(bip->bli_item.li_ailp,
+                                                       lip);
                        }
                }
                xfs_buf_relse(bp);
@@ -553,13 +505,14 @@ xfs_trans_brelse(xfs_trans_t      *tp,
        lidp = xfs_trans_find_item(tp, (xfs_log_item_t*)bip);
        ASSERT(lidp != NULL);
 
+       trace_xfs_trans_brelse(bip);
+
        /*
         * If the release is just for a recursive lock,
         * then decrement the count and return.
         */
        if (bip->bli_recur > 0) {
                bip->bli_recur--;
-               xfs_buf_item_trace("RELSE RECUR", bip);
                return;
        }
 
@@ -567,10 +520,8 @@ xfs_trans_brelse(xfs_trans_t       *tp,
         * If the buffer is dirty within this transaction, we can't
         * release it until we commit.
         */
-       if (lidp->lid_flags & XFS_LID_DIRTY) {
-               xfs_buf_item_trace("RELSE DIRTY", bip);
+       if (lidp->lid_flags & XFS_LID_DIRTY)
                return;
-       }
 
        /*
         * If the buffer has been invalidated, then we can't release
@@ -578,13 +529,10 @@ xfs_trans_brelse(xfs_trans_t      *tp,
         * as part of this transaction.  This prevents us from pulling
         * the item from the AIL before we should.
         */
-       if (bip->bli_flags & XFS_BLI_STALE) {
-               xfs_buf_item_trace("RELSE STALE", bip);
+       if (bip->bli_flags & XFS_BLI_STALE)
                return;
-       }
 
        ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED));
-       xfs_buf_item_trace("RELSE", bip);
 
        /*
         * Free up the log item descriptor tracking the released item.
@@ -629,7 +577,7 @@ xfs_trans_brelse(xfs_trans_t        *tp,
         * tell the AIL that the buffer is being unlocked.
         */
        if (bip != NULL) {
-               xfs_trans_unlocked_item(bip->bli_item.li_mountp,
+               xfs_trans_unlocked_item(bip->bli_item.li_ailp,
                                        (xfs_log_item_t*)bip);
        }
 
@@ -638,53 +586,6 @@ xfs_trans_brelse(xfs_trans_t       *tp,
 }
 
 /*
- * Add the locked buffer to the transaction.
- * The buffer must be locked, and it cannot be associated with any
- * transaction.
- *
- * If the buffer does not yet have a buf log item associated with it,
- * then allocate one for it.  Then add the buf item to the transaction.
- */
-void
-xfs_trans_bjoin(xfs_trans_t    *tp,
-               xfs_buf_t       *bp)
-{
-       xfs_buf_log_item_t      *bip;
-
-       ASSERT(XFS_BUF_ISBUSY(bp));
-       ASSERT(XFS_BUF_FSPRIVATE2(bp, void *) == NULL);
-
-       /*
-        * The xfs_buf_log_item pointer is stored in b_fsprivate.  If
-        * it doesn't have one yet, then allocate one and initialize it.
-        * The checks to see if one is there are in xfs_buf_item_init().
-        */
-       xfs_buf_item_init(bp, tp->t_mountp);
-       bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *);
-       ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
-       ASSERT(!(bip->bli_format.blf_flags & XFS_BLI_CANCEL));
-       ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED));
-
-       /*
-        * Take a reference for this transaction on the buf item.
-        */
-       atomic_inc(&bip->bli_refcount);
-
-       /*
-        * Get a log_item_desc to point at the new item.
-        */
-       (void) xfs_trans_add_item(tp, (xfs_log_item_t *)bip);
-
-       /*
-        * Initialize b_fsprivate2 so we can find it with incore_match()
-        * in xfs_trans_get_buf() and friends above.
-        */
-       XFS_BUF_SET_FSPRIVATE2(bp, tp);
-
-       xfs_buf_item_trace("BJOIN", bip);
-}
-
-/*
  * Mark the buffer as not needing to be unlocked when the buf item's
  * IOP_UNLOCK() routine is called.  The buffer must already be locked
  * and associated with the given transaction.
@@ -705,7 +606,7 @@ xfs_trans_bhold(xfs_trans_t *tp,
        ASSERT(!(bip->bli_format.blf_flags & XFS_BLI_CANCEL));
        ASSERT(atomic_read(&bip->bli_refcount) > 0);
        bip->bli_flags |= XFS_BLI_HOLD;
-       xfs_buf_item_trace("BHOLD", bip);
+       trace_xfs_trans_bhold(bip);
 }
 
 /*
@@ -728,7 +629,8 @@ xfs_trans_bhold_release(xfs_trans_t *tp,
        ASSERT(atomic_read(&bip->bli_refcount) > 0);
        ASSERT(bip->bli_flags & XFS_BLI_HOLD);
        bip->bli_flags &= ~XFS_BLI_HOLD;
-       xfs_buf_item_trace("BHOLD RELEASE", bip);
+
+       trace_xfs_trans_bhold_release(bip);
 }
 
 /*
@@ -774,6 +676,8 @@ xfs_trans_log_buf(xfs_trans_t       *tp,
        XFS_BUF_SET_IODONE_FUNC(bp, xfs_buf_iodone_callbacks);
        bip->bli_item.li_cb = (void(*)(xfs_buf_t*,xfs_log_item_t*))xfs_buf_iodone;
 
+       trace_xfs_trans_log_buf(bip);
+
        /*
         * If we invalidated the buffer within this transaction, then
         * cancel the invalidation now that we're dirtying the buffer
@@ -781,7 +685,6 @@ xfs_trans_log_buf(xfs_trans_t       *tp,
         * because we have a reference to the buffer this entire time.
         */
        if (bip->bli_flags & XFS_BLI_STALE) {
-               xfs_buf_item_trace("BLOG UNSTALE", bip);
                bip->bli_flags &= ~XFS_BLI_STALE;
                ASSERT(XFS_BUF_ISSTALE(bp));
                XFS_BUF_UNSTALE(bp);
@@ -796,7 +699,6 @@ xfs_trans_log_buf(xfs_trans_t       *tp,
        lidp->lid_flags &= ~XFS_LID_BUF_STALE;
        bip->bli_flags |= XFS_BLI_LOGGED;
        xfs_buf_item_log(bip, first, last);
-       xfs_buf_item_trace("BLOG", bip);
 }
 
 
@@ -835,6 +737,8 @@ xfs_trans_binval(
        ASSERT(lidp != NULL);
        ASSERT(atomic_read(&bip->bli_refcount) > 0);
 
+       trace_xfs_trans_binval(bip);
+
        if (bip->bli_flags & XFS_BLI_STALE) {
                /*
                 * If the buffer is already invalidated, then
@@ -847,8 +751,6 @@ xfs_trans_binval(
                ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL);
                ASSERT(lidp->lid_flags & XFS_LID_DIRTY);
                ASSERT(tp->t_flags & XFS_TRANS_DIRTY);
-               xfs_buftrace("XFS_BINVAL RECUR", bp);
-               xfs_buf_item_trace("BINVAL RECUR", bip);
                return;
        }
 
@@ -882,8 +784,6 @@ xfs_trans_binval(
              (bip->bli_format.blf_map_size * sizeof(uint)));
        lidp->lid_flags |= XFS_LID_DIRTY|XFS_LID_BUF_STALE;
        tp->t_flags |= XFS_TRANS_DIRTY;
-       xfs_buftrace("XFS_BINVAL", bp);
-       xfs_buf_item_trace("BINVAL", bip);
 }
 
 /*
@@ -1024,16 +924,16 @@ xfs_trans_buf_item_match(
        bp = NULL;
        len = BBTOB(len);
        licp = &tp->t_items;
-       if (!XFS_LIC_ARE_ALL_FREE(licp)) {
+       if (!xfs_lic_are_all_free(licp)) {
                for (i = 0; i < licp->lic_unused; i++) {
                        /*
                         * Skip unoccupied slots.
                         */
-                       if (XFS_LIC_ISFREE(licp, i)) {
+                       if (xfs_lic_isfree(licp, i)) {
                                continue;
                        }
 
-                       lidp = XFS_LIC_SLOT(licp, i);
+                       lidp = xfs_lic_slot(licp, i);
                        blip = (xfs_buf_log_item_t *)lidp->lid_item;
                        if (blip->bli_item.li_type != XFS_LI_BUF) {
                                continue;
@@ -1077,7 +977,7 @@ xfs_trans_buf_item_match_all(
        bp = NULL;
        len = BBTOB(len);
        for (licp = &tp->t_items; licp != NULL; licp = licp->lic_next) {
-               if (XFS_LIC_ARE_ALL_FREE(licp)) {
+               if (xfs_lic_are_all_free(licp)) {
                        ASSERT(licp == &tp->t_items);
                        ASSERT(licp->lic_next == NULL);
                        return NULL;
@@ -1086,11 +986,11 @@ xfs_trans_buf_item_match_all(
                        /*
                         * Skip unoccupied slots.
                         */
-                       if (XFS_LIC_ISFREE(licp, i)) {
+                       if (xfs_lic_isfree(licp, i)) {
                                continue;
                        }
 
-                       lidp = XFS_LIC_SLOT(licp, i);
+                       lidp = xfs_lic_slot(licp, i);
                        blip = (xfs_buf_log_item_t *)lidp->lid_item;
                        if (blip->bli_item.li_type != XFS_LI_BUF) {
                                continue;