]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/xfs/xfs_trans_ail.c
drivers: fix dma_get_required_mask
[linux-2.6-omap-h63xx.git] / fs / xfs / xfs_trans_ail.c
index 7ed7425478def6bafe5e4d9e5451fe000e1a92ef..76d470d8a1e63b8ece4dc74ffb69881f057eeb13 100644 (file)
@@ -34,9 +34,9 @@ STATIC xfs_log_item_t * xfs_ail_min(xfs_ail_entry_t *);
 STATIC xfs_log_item_t * xfs_ail_next(xfs_ail_entry_t *, xfs_log_item_t *);
 
 #ifdef DEBUG
-STATIC void xfs_ail_check(xfs_ail_entry_t *);
+STATIC void xfs_ail_check(xfs_ail_entry_t *, xfs_log_item_t *);
 #else
-#define        xfs_ail_check(a)
+#define        xfs_ail_check(a,l)
 #endif /* DEBUG */
 
 
@@ -261,16 +261,19 @@ xfsaild_push(
                xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE);
        }
 
-       /*
-        * We reached the target so wait a bit longer for I/O to complete and
-        * remove pushed items from the AIL before we start the next scan from
-        * the start of the AIL.
-        */
-       if ((XFS_LSN_CMP(lsn, target) >= 0)) {
+       if (!count) {
+               /* We're past our target or empty, so idle */
+               tout = 1000;
+       } else if (XFS_LSN_CMP(lsn, target) >= 0) {
+               /*
+                * We reached the target so wait a bit longer for I/O to
+                * complete and remove pushed items from the AIL before we
+                * start the next scan from the start of the AIL.
+                */
                tout += 20;
                last_pushed_lsn = 0;
        } else if ((restarts > XFS_TRANS_PUSH_AIL_RESTARTS) ||
-                  (count && ((stuck * 100) / count > 90))) {
+                  ((stuck * 100) / count > 90)) {
                /*
                 * Either there is a lot of contention on the AIL or we
                 * are stuck due to operations in progress. "Stuck" in this
@@ -563,7 +566,7 @@ xfs_ail_insert(
        next_lip->li_ail.ail_forw = lip;
        lip->li_ail.ail_forw->li_ail.ail_back = lip;
 
-       xfs_ail_check(base);
+       xfs_ail_check(base, lip);
        return;
 }
 
@@ -577,12 +580,12 @@ xfs_ail_delete(
        xfs_log_item_t  *lip)
 /* ARGSUSED */
 {
+       xfs_ail_check(base, lip);
        lip->li_ail.ail_forw->li_ail.ail_back = lip->li_ail.ail_back;
        lip->li_ail.ail_back->li_ail.ail_forw = lip->li_ail.ail_forw;
        lip->li_ail.ail_forw = NULL;
        lip->li_ail.ail_back = NULL;
 
-       xfs_ail_check(base);
        return lip;
 }
 
@@ -626,13 +629,13 @@ xfs_ail_next(
  */
 STATIC void
 xfs_ail_check(
-       xfs_ail_entry_t *base)
+       xfs_ail_entry_t *base,
+       xfs_log_item_t  *lip)
 {
-       xfs_log_item_t  *lip;
        xfs_log_item_t  *prev_lip;
 
-       lip = base->ail_forw;
-       if (lip == (xfs_log_item_t*)base) {
+       prev_lip = base->ail_forw;
+       if (prev_lip == (xfs_log_item_t*)base) {
                /*
                 * Make sure the pointers are correct when the list
                 * is empty.
@@ -641,10 +644,28 @@ xfs_ail_check(
                return;
        }
 
+       /*
+        * Check the next and previous entries are valid.
+        */
+       ASSERT((lip->li_flags & XFS_LI_IN_AIL) != 0);
+       prev_lip = lip->li_ail.ail_back;
+       if (prev_lip != (xfs_log_item_t*)base) {
+               ASSERT(prev_lip->li_ail.ail_forw == lip);
+               ASSERT(XFS_LSN_CMP(prev_lip->li_lsn, lip->li_lsn) <= 0);
+       }
+       prev_lip = lip->li_ail.ail_forw;
+       if (prev_lip != (xfs_log_item_t*)base) {
+               ASSERT(prev_lip->li_ail.ail_back == lip);
+               ASSERT(XFS_LSN_CMP(prev_lip->li_lsn, lip->li_lsn) >= 0);
+       }
+
+
+#ifdef XFS_TRANS_DEBUG
        /*
         * Walk the list checking forward and backward pointers,
         * lsn ordering, and that every entry has the XFS_LI_IN_AIL
-        * flag set.
+        * flag set. This is really expensive, so only do it when
+        * specifically debugging the transaction subsystem.
         */
        prev_lip = (xfs_log_item_t*)base;
        while (lip != (xfs_log_item_t*)base) {
@@ -659,5 +680,6 @@ xfs_ail_check(
        }
        ASSERT(lip == (xfs_log_item_t*)base);
        ASSERT(base->ail_back == prev_lip);
+#endif /* XFS_TRANS_DEBUG */
 }
 #endif /* DEBUG */