ALSA: usb-audio: add UAC2 sepecific Feature Unit controls
[safe/jmp/linux-2.6] / fs / xfs / xfs_trans_item.c
index 66a09f0..f11d37d 100644 (file)
 #include "xfs_inum.h"
 #include "xfs_trans.h"
 #include "xfs_trans_priv.h"
+/* XXX: from here down needed until struct xfs_trans has its own ailp */
+#include "xfs_bit.h"
+#include "xfs_buf_item.h"
+#include "xfs_sb.h"
+#include "xfs_ag.h"
+#include "xfs_dir2.h"
+#include "xfs_dmapi.h"
+#include "xfs_mount.h"
 
 STATIC int     xfs_trans_unlock_chunk(xfs_log_item_chunk_t *,
                                        int, int, xfs_lsn_t);
@@ -53,11 +61,11 @@ xfs_trans_add_item(xfs_trans_t *tp, xfs_log_item_t *lip)
                 * Initialize the chunk, and then
                 * claim the first slot in the newly allocated chunk.
                 */
-               XFS_LIC_INIT(licp);
-               XFS_LIC_CLAIM(licp, 0);
+               xfs_lic_init(licp);
+               xfs_lic_claim(licp, 0);
                licp->lic_unused = 1;
-               XFS_LIC_INIT_SLOT(licp, 0);
-               lidp = XFS_LIC_SLOT(licp, 0);
+               xfs_lic_init_slot(licp, 0);
+               lidp = xfs_lic_slot(licp, 0);
 
                /*
                 * Link in the new chunk and update the free count.
@@ -79,6 +87,7 @@ xfs_trans_add_item(xfs_trans_t *tp, xfs_log_item_t *lip)
                lidp->lid_size = 0;
                lip->li_desc = lidp;
                lip->li_mountp = tp->t_mountp;
+               lip->li_ailp = tp->t_mountp->m_ail;
                return lidp;
        }
 
@@ -88,14 +97,14 @@ xfs_trans_add_item(xfs_trans_t *tp, xfs_log_item_t *lip)
         */
        licp = &tp->t_items;
        while (licp != NULL) {
-               if (XFS_LIC_VACANCY(licp)) {
+               if (xfs_lic_vacancy(licp)) {
                        if (licp->lic_unused <= XFS_LIC_MAX_SLOT) {
                                i = licp->lic_unused;
-                               ASSERT(XFS_LIC_ISFREE(licp, i));
+                               ASSERT(xfs_lic_isfree(licp, i));
                                break;
                        }
                        for (i = 0; i <= XFS_LIC_MAX_SLOT; i++) {
-                               if (XFS_LIC_ISFREE(licp, i))
+                               if (xfs_lic_isfree(licp, i))
                                        break;
                        }
                        ASSERT(i <= XFS_LIC_MAX_SLOT);
@@ -108,18 +117,19 @@ xfs_trans_add_item(xfs_trans_t *tp, xfs_log_item_t *lip)
         * If we find a free descriptor, claim it,
         * initialize it, and return it.
         */
-       XFS_LIC_CLAIM(licp, i);
+       xfs_lic_claim(licp, i);
        if (licp->lic_unused <= i) {
                licp->lic_unused = i + 1;
-               XFS_LIC_INIT_SLOT(licp, i);
+               xfs_lic_init_slot(licp, i);
        }
-       lidp = XFS_LIC_SLOT(licp, i);
+       lidp = xfs_lic_slot(licp, i);
        tp->t_items_free--;
        lidp->lid_item = lip;
        lidp->lid_flags = 0;
        lidp->lid_size = 0;
        lip->li_desc = lidp;
        lip->li_mountp = tp->t_mountp;
+       lip->li_ailp = tp->t_mountp->m_ail;
        return lidp;
 }
 
@@ -136,9 +146,9 @@ xfs_trans_free_item(xfs_trans_t     *tp, xfs_log_item_desc_t *lidp)
        xfs_log_item_chunk_t    *licp;
        xfs_log_item_chunk_t    **licpp;
 
-       slot = XFS_LIC_DESC_TO_SLOT(lidp);
-       licp = XFS_LIC_DESC_TO_CHUNK(lidp);
-       XFS_LIC_RELSE(licp, slot);
+       slot = xfs_lic_desc_to_slot(lidp);
+       licp = xfs_lic_desc_to_chunk(lidp);
+       xfs_lic_relse(licp, slot);
        lidp->lid_item->li_desc = NULL;
        tp->t_items_free++;
 
@@ -154,14 +164,14 @@ xfs_trans_free_item(xfs_trans_t   *tp, xfs_log_item_desc_t *lidp)
         * Also decrement the transaction structure's count of free items
         * by the number in a chunk since we are freeing an empty chunk.
         */
-       if (XFS_LIC_ARE_ALL_FREE(licp) && (licp != &(tp->t_items))) {
+       if (xfs_lic_are_all_free(licp) && (licp != &(tp->t_items))) {
                licpp = &(tp->t_items.lic_next);
                while (*licpp != licp) {
                        ASSERT(*licpp != NULL);
                        licpp = &((*licpp)->lic_next);
                }
                *licpp = licp->lic_next;
-               kmem_free(licp, sizeof(xfs_log_item_chunk_t));
+               kmem_free(licp);
                tp->t_items_free -= XFS_LIC_NUM_SLOTS;
        }
 }
@@ -207,20 +217,20 @@ xfs_trans_first_item(xfs_trans_t *tp)
        /*
         * If it's not in the first chunk, skip to the second.
         */
-       if (XFS_LIC_ARE_ALL_FREE(licp)) {
+       if (xfs_lic_are_all_free(licp)) {
                licp = licp->lic_next;
        }
 
        /*
         * Return the first non-free descriptor in the chunk.
         */
-       ASSERT(!XFS_LIC_ARE_ALL_FREE(licp));
+       ASSERT(!xfs_lic_are_all_free(licp));
        for (i = 0; i < licp->lic_unused; i++) {
-               if (XFS_LIC_ISFREE(licp, i)) {
+               if (xfs_lic_isfree(licp, i)) {
                        continue;
                }
 
-               return XFS_LIC_SLOT(licp, i);
+               return xfs_lic_slot(licp, i);
        }
        cmn_err(CE_WARN, "xfs_trans_first_item() -- no first item");
        return NULL;
@@ -242,18 +252,18 @@ xfs_trans_next_item(xfs_trans_t *tp, xfs_log_item_desc_t *lidp)
        xfs_log_item_chunk_t    *licp;
        int                     i;
 
-       licp = XFS_LIC_DESC_TO_CHUNK(lidp);
+       licp = xfs_lic_desc_to_chunk(lidp);
 
        /*
         * First search the rest of the chunk. The for loop keeps us
         * from referencing things beyond the end of the chunk.
         */
-       for (i = (int)XFS_LIC_DESC_TO_SLOT(lidp) + 1; i < licp->lic_unused; i++) {
-               if (XFS_LIC_ISFREE(licp, i)) {
+       for (i = (int)xfs_lic_desc_to_slot(lidp) + 1; i < licp->lic_unused; i++) {
+               if (xfs_lic_isfree(licp, i)) {
                        continue;
                }
 
-               return XFS_LIC_SLOT(licp, i);
+               return xfs_lic_slot(licp, i);
        }
 
        /*
@@ -266,13 +276,13 @@ xfs_trans_next_item(xfs_trans_t *tp, xfs_log_item_desc_t *lidp)
        }
 
        licp = licp->lic_next;
-       ASSERT(!XFS_LIC_ARE_ALL_FREE(licp));
+       ASSERT(!xfs_lic_are_all_free(licp));
        for (i = 0; i < licp->lic_unused; i++) {
-               if (XFS_LIC_ISFREE(licp, i)) {
+               if (xfs_lic_isfree(licp, i)) {
                        continue;
                }
 
-               return XFS_LIC_SLOT(licp, i);
+               return xfs_lic_slot(licp, i);
        }
        ASSERT(0);
        /* NOTREACHED */
@@ -289,6 +299,7 @@ xfs_trans_next_item(xfs_trans_t *tp, xfs_log_item_desc_t *lidp)
 void
 xfs_trans_free_items(
        xfs_trans_t     *tp,
+       xfs_lsn_t       commit_lsn,
        int             flags)
 {
        xfs_log_item_chunk_t    *licp;
@@ -300,9 +311,9 @@ xfs_trans_free_items(
        /*
         * Special case the embedded chunk so we don't free it below.
         */
-       if (!XFS_LIC_ARE_ALL_FREE(licp)) {
-               (void) xfs_trans_unlock_chunk(licp, 1, abort, NULLCOMMITLSN);
-               XFS_LIC_ALL_FREE(licp);
+       if (!xfs_lic_are_all_free(licp)) {
+               (void) xfs_trans_unlock_chunk(licp, 1, abort, commit_lsn);
+               xfs_lic_all_free(licp);
                licp->lic_unused = 0;
        }
        licp = licp->lic_next;
@@ -311,10 +322,10 @@ xfs_trans_free_items(
         * Unlock each item in each chunk and free the chunks.
         */
        while (licp != NULL) {
-               ASSERT(!XFS_LIC_ARE_ALL_FREE(licp));
-               (void) xfs_trans_unlock_chunk(licp, 1, abort, NULLCOMMITLSN);
+               ASSERT(!xfs_lic_are_all_free(licp));
+               (void) xfs_trans_unlock_chunk(licp, 1, abort, commit_lsn);
                next_licp = licp->lic_next;
-               kmem_free(licp, sizeof(xfs_log_item_chunk_t));
+               kmem_free(licp);
                licp = next_licp;
        }
 
@@ -347,7 +358,7 @@ xfs_trans_unlock_items(xfs_trans_t *tp, xfs_lsn_t commit_lsn)
        /*
         * Special case the embedded chunk so we don't free.
         */
-       if (!XFS_LIC_ARE_ALL_FREE(licp)) {
+       if (!xfs_lic_are_all_free(licp)) {
                freed = xfs_trans_unlock_chunk(licp, 0, 0, commit_lsn);
        }
        licpp = &(tp->t_items.lic_next);
@@ -358,12 +369,12 @@ xfs_trans_unlock_items(xfs_trans_t *tp, xfs_lsn_t commit_lsn)
         * and free empty chunks.
         */
        while (licp != NULL) {
-               ASSERT(!XFS_LIC_ARE_ALL_FREE(licp));
+               ASSERT(!xfs_lic_are_all_free(licp));
                freed += xfs_trans_unlock_chunk(licp, 0, 0, commit_lsn);
                next_licp = licp->lic_next;
-               if (XFS_LIC_ARE_ALL_FREE(licp)) {
+               if (xfs_lic_are_all_free(licp)) {
                        *licpp = next_licp;
-                       kmem_free(licp, sizeof(xfs_log_item_chunk_t));
+                       kmem_free(licp);
                        freed -= XFS_LIC_NUM_SLOTS;
                } else {
                        licpp = &(licp->lic_next);
@@ -402,7 +413,7 @@ xfs_trans_unlock_chunk(
        freed = 0;
        lidp = licp->lic_descs;
        for (i = 0; i < licp->lic_unused; i++, lidp++) {
-               if (XFS_LIC_ISFREE(licp, i)) {
+               if (xfs_lic_isfree(licp, i)) {
                        continue;
                }
                lip = lidp->lid_item;
@@ -421,119 +432,10 @@ xfs_trans_unlock_chunk(
                 */
                if (!(freeing_chunk) &&
                    (!(lidp->lid_flags & XFS_LID_DIRTY) || abort)) {
-                       XFS_LIC_RELSE(licp, i);
+                       xfs_lic_relse(licp, i);
                        freed++;
                }
        }
 
        return freed;
 }
-
-
-/*
- * This is called to add the given busy item to the transaction's
- * list of busy items.  It must find a free busy item descriptor
- * or allocate a new one and add the item to that descriptor.
- * The function returns a pointer to busy descriptor used to point
- * to the new busy entry.  The log busy entry will now point to its new
- * descriptor with its ???? field.
- */
-xfs_log_busy_slot_t *
-xfs_trans_add_busy(xfs_trans_t *tp, xfs_agnumber_t ag, xfs_extlen_t idx)
-{
-       xfs_log_busy_chunk_t    *lbcp;
-       xfs_log_busy_slot_t     *lbsp;
-       int                     i=0;
-
-       /*
-        * If there are no free descriptors, allocate a new chunk
-        * of them and put it at the front of the chunk list.
-        */
-       if (tp->t_busy_free == 0) {
-               lbcp = (xfs_log_busy_chunk_t*)
-                      kmem_alloc(sizeof(xfs_log_busy_chunk_t), KM_SLEEP);
-               ASSERT(lbcp != NULL);
-               /*
-                * Initialize the chunk, and then
-                * claim the first slot in the newly allocated chunk.
-                */
-               XFS_LBC_INIT(lbcp);
-               XFS_LBC_CLAIM(lbcp, 0);
-               lbcp->lbc_unused = 1;
-               lbsp = XFS_LBC_SLOT(lbcp, 0);
-
-               /*
-                * Link in the new chunk and update the free count.
-                */
-               lbcp->lbc_next = tp->t_busy.lbc_next;
-               tp->t_busy.lbc_next = lbcp;
-               tp->t_busy_free = XFS_LIC_NUM_SLOTS - 1;
-
-               /*
-                * Initialize the descriptor and the generic portion
-                * of the log item.
-                *
-                * Point the new slot at this item and return it.
-                * Also point the log item at its currently active
-                * descriptor and set the item's mount pointer.
-                */
-               lbsp->lbc_ag = ag;
-               lbsp->lbc_idx = idx;
-               return lbsp;
-       }
-
-       /*
-        * Find the free descriptor. It is somewhere in the chunklist
-        * of descriptors.
-        */
-       lbcp = &tp->t_busy;
-       while (lbcp != NULL) {
-               if (XFS_LBC_VACANCY(lbcp)) {
-                       if (lbcp->lbc_unused <= XFS_LBC_MAX_SLOT) {
-                               i = lbcp->lbc_unused;
-                               break;
-                       } else {
-                               /* out-of-order vacancy */
-                               cmn_err(CE_DEBUG, "OOO vacancy lbcp 0x%p\n", lbcp);
-                               ASSERT(0);
-                       }
-               }
-               lbcp = lbcp->lbc_next;
-       }
-       ASSERT(lbcp != NULL);
-       /*
-        * If we find a free descriptor, claim it,
-        * initialize it, and return it.
-        */
-       XFS_LBC_CLAIM(lbcp, i);
-       if (lbcp->lbc_unused <= i) {
-               lbcp->lbc_unused = i + 1;
-       }
-       lbsp = XFS_LBC_SLOT(lbcp, i);
-       tp->t_busy_free--;
-       lbsp->lbc_ag = ag;
-       lbsp->lbc_idx = idx;
-       return lbsp;
-}
-
-
-/*
- * xfs_trans_free_busy
- * Free all of the busy lists from a transaction
- */
-void
-xfs_trans_free_busy(xfs_trans_t *tp)
-{
-       xfs_log_busy_chunk_t    *lbcp;
-       xfs_log_busy_chunk_t    *lbcq;
-
-       lbcp = tp->t_busy.lbc_next;
-       while (lbcp != NULL) {
-               lbcq = lbcp->lbc_next;
-               kmem_free(lbcp, sizeof(xfs_log_busy_chunk_t));
-               lbcp = lbcq;
-       }
-
-       XFS_LBC_INIT(&tp->t_busy);
-       tp->t_busy.lbc_unused = 0;
-}