ravb: Remove extra TAB
[linux-2.6-microblaze.git] / fs / xfs / xfs_extent_busy.c
index a407568..ad22a00 100644 (file)
 #include "xfs_log_format.h"
 #include "xfs_shared.h"
 #include "xfs_trans_resv.h"
-#include "xfs_sb.h"
 #include "xfs_mount.h"
 #include "xfs_alloc.h"
 #include "xfs_extent_busy.h"
 #include "xfs_trace.h"
 #include "xfs_trans.h"
 #include "xfs_log.h"
+#include "xfs_ag.h"
 
 void
 xfs_extent_busy_insert(
        struct xfs_trans        *tp,
-       xfs_agnumber_t          agno,
+       struct xfs_perag        *pag,
        xfs_agblock_t           bno,
        xfs_extlen_t            len,
        unsigned int            flags)
 {
        struct xfs_extent_busy  *new;
        struct xfs_extent_busy  *busyp;
-       struct xfs_perag        *pag;
        struct rb_node          **rbp;
        struct rb_node          *parent = NULL;
 
        new = kmem_zalloc(sizeof(struct xfs_extent_busy), 0);
-       new->agno = agno;
+       new->agno = pag->pag_agno;
        new->bno = bno;
        new->length = len;
        INIT_LIST_HEAD(&new->list);
        new->flags = flags;
 
        /* trace before insert to be able to see failed inserts */
-       trace_xfs_extent_busy(tp->t_mountp, agno, bno, len);
+       trace_xfs_extent_busy(tp->t_mountp, pag->pag_agno, bno, len);
 
-       pag = xfs_perag_get(tp->t_mountp, new->agno);
        spin_lock(&pag->pagb_lock);
        rbp = &pag->pagb_tree.rb_node;
        while (*rbp) {
@@ -66,7 +64,6 @@ xfs_extent_busy_insert(
 
        list_add(&new->list, &tp->t_busy);
        spin_unlock(&pag->pagb_lock);
-       xfs_perag_put(pag);
 }
 
 /*
@@ -81,21 +78,17 @@ xfs_extent_busy_insert(
 int
 xfs_extent_busy_search(
        struct xfs_mount        *mp,
-       xfs_agnumber_t          agno,
+       struct xfs_perag        *pag,
        xfs_agblock_t           bno,
        xfs_extlen_t            len)
 {
-       struct xfs_perag        *pag;
        struct rb_node          *rbp;
        struct xfs_extent_busy  *busyp;
        int                     match = 0;
 
-       pag = xfs_perag_get(mp, agno);
+       /* find closest start bno overlap */
        spin_lock(&pag->pagb_lock);
-
        rbp = pag->pagb_tree.rb_node;
-
-       /* find closest start bno overlap */
        while (rbp) {
                busyp = rb_entry(rbp, struct xfs_extent_busy, rb_node);
                if (bno < busyp->bno) {
@@ -115,7 +108,6 @@ xfs_extent_busy_search(
                }
        }
        spin_unlock(&pag->pagb_lock);
-       xfs_perag_put(pag);
        return match;
 }
 
@@ -281,17 +273,14 @@ out_force_log:
 void
 xfs_extent_busy_reuse(
        struct xfs_mount        *mp,
-       xfs_agnumber_t          agno,
+       struct xfs_perag        *pag,
        xfs_agblock_t           fbno,
        xfs_extlen_t            flen,
        bool                    userdata)
 {
-       struct xfs_perag        *pag;
        struct rb_node          *rbp;
 
        ASSERT(flen > 0);
-
-       pag = xfs_perag_get(mp, agno);
        spin_lock(&pag->pagb_lock);
 restart:
        rbp = pag->pagb_tree.rb_node;
@@ -314,7 +303,6 @@ restart:
                        goto restart;
        }
        spin_unlock(&pag->pagb_lock);
-       xfs_perag_put(pag);
 }
 
 /*
@@ -605,12 +593,11 @@ void
 xfs_extent_busy_wait_all(
        struct xfs_mount        *mp)
 {
+       struct xfs_perag        *pag;
        DEFINE_WAIT             (wait);
        xfs_agnumber_t          agno;
 
-       for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) {
-               struct xfs_perag *pag = xfs_perag_get(mp, agno);
-
+       for_each_perag(mp, agno, pag) {
                do {
                        prepare_to_wait(&pag->pagb_wait, &wait, TASK_KILLABLE);
                        if  (RB_EMPTY_ROOT(&pag->pagb_tree))
@@ -618,8 +605,6 @@ xfs_extent_busy_wait_all(
                        schedule();
                } while (1);
                finish_wait(&pag->pagb_wait, &wait);
-
-               xfs_perag_put(pag);
        }
 }