ALSA: usb-audio: add support for Akai MPD16
[safe/jmp/linux-2.6] / fs / jfs / jfs_imap.c
index 3870ba8..f8332dc 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/buffer_head.h>
 #include <linux/pagemap.h>
 #include <linux/quotaops.h>
+#include <linux/slab.h>
 
 #include "jfs_incore.h"
 #include "jfs_inode.h"
 #include "jfs_debug.h"
 
 /*
- * __mark_inode_dirty expects inodes to be hashed.  Since we don't want
- * special inodes in the fileset inode space, we hash them to a dummy head
- */
-static HLIST_HEAD(aggregate_hash);
-
-/*
  * imap locks
  */
 /* iag free list lock */
@@ -381,7 +376,7 @@ int diRead(struct inode *ip)
 
        /* read the page of disk inode */
        mp = read_metapage(ipimap, pageno << sbi->l2nbperpage, PSIZE, 1);
-       if (mp == 0) {
+       if (!mp) {
                jfs_err("diRead: read_metapage failed");
                return -EIO;
        }
@@ -496,7 +491,13 @@ struct inode *diReadSpecial(struct super_block *sb, ino_t inum, int secondary)
        /* release the page */
        release_metapage(mp);
 
-       hlist_add_head(&ip->i_hash, &aggregate_hash);
+       /*
+        * __mark_inode_dirty expects inodes to be hashed.  Since we don't
+        * want special inodes in the fileset inode space, we make them
+        * appear hashed, but do not put on any lists.  hlist_del()
+        * will work fine and require no locking.
+        */
+       ip->i_hash.pprev = &ip->i_hash.next;
 
        return (ip);
 }
@@ -654,7 +655,7 @@ int diWrite(tid_t tid, struct inode *ip)
        /* read the page of disk inode */
       retry:
        mp = read_metapage(ipimap, pageno << sbi->l2nbperpage, PSIZE, 1);
-       if (mp == 0)
+       if (!mp)
                return -EIO;
 
        /* get the pointer to the disk inode */
@@ -1019,8 +1020,7 @@ int diFree(struct inode *ip)
                /* update the free inode counts at the iag, ag and
                 * map level.
                 */
-               iagp->nfreeinos =
-                   cpu_to_le32(le32_to_cpu(iagp->nfreeinos) + 1);
+               le32_add_cpu(&iagp->nfreeinos, 1);
                imap->im_agctl[agno].numfree += 1;
                atomic_inc(&imap->im_numfree);
 
@@ -1219,9 +1219,8 @@ int diFree(struct inode *ip)
        /* update the number of free inodes and number of free extents
         * for the iag.
         */
-       iagp->nfreeinos = cpu_to_le32(le32_to_cpu(iagp->nfreeinos) -
-                                     (INOSPEREXT - 1));
-       iagp->nfreeexts = cpu_to_le32(le32_to_cpu(iagp->nfreeexts) + 1);
+       le32_add_cpu(&iagp->nfreeinos, -(INOSPEREXT - 1));
+       le32_add_cpu(&iagp->nfreeexts, 1);
 
        /* update the number of free inodes and backed inodes
         * at the ag and inode map level.
@@ -1522,7 +1521,7 @@ int diAlloc(struct inode *pip, bool dir, struct inode *ip)
                                        jfs_error(ip->i_sb,
                                                  "diAlloc: can't find free bit "
                                                  "in wmap");
-                                       return EIO;
+                                       return -EIO;
                                }
 
                                /* determine the inode number within the
@@ -2124,7 +2123,7 @@ static int diAllocBit(struct inomap * imap, struct iag * iagp, int ino)
        /* update the free inode count at the iag, ag, inode
         * map levels.
         */
-       iagp->nfreeinos = cpu_to_le32(le32_to_cpu(iagp->nfreeinos) - 1);
+       le32_add_cpu(&iagp->nfreeinos, -1);
        imap->im_agctl[agno].numfree -= 1;
        atomic_dec(&imap->im_numfree);
 
@@ -2378,9 +2377,8 @@ static int diNewExt(struct inomap * imap, struct iag * iagp, int extno)
        /* update the free inode and free extent counts for the
         * iag.
         */
-       iagp->nfreeinos = cpu_to_le32(le32_to_cpu(iagp->nfreeinos) +
-                                     (INOSPEREXT - 1));
-       iagp->nfreeexts = cpu_to_le32(le32_to_cpu(iagp->nfreeexts) - 1);
+       le32_add_cpu(&iagp->nfreeinos, (INOSPEREXT - 1));
+       le32_add_cpu(&iagp->nfreeexts, -1);
 
        /* update the free and backed inode counts for the ag.
         */
@@ -2574,6 +2572,7 @@ diNewIAG(struct inomap * imap, int *iagnop, int agno, struct metapage ** mpp)
 
                        txAbort(tid, 0);
                        txEnd(tid);
+                       mutex_unlock(&JFS_IP(ipimap)->commit_mutex);
 
                        /* release the inode map lock */
                        IWRITE_UNLOCK(ipimap);