vserver 1.9.3
[linux-2.6.git] / fs / jfs / jfs_imap.c
index 848fbc8..084ec26 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *   Copyright (C) International Business Machines Corp., 2000-2003
+ *   Copyright (C) International Business Machines Corp., 2000-2004
  *
  *   This program is free software;  you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -44,6 +44,7 @@
 #include <linux/fs.h>
 #include <linux/buffer_head.h>
 #include <linux/pagemap.h>
+#include <linux/quotaops.h>
 #include <linux/vserver/xid.h>
 
 #include "jfs_incore.h"
@@ -505,6 +506,9 @@ struct inode *diReadSpecial(struct super_block *sb, ino_t inum, int secondary)
        ip->i_mapping->a_ops = &jfs_aops;
        mapping_set_gfp_mask(ip->i_mapping, GFP_NOFS);
 
+       /* Allocations to metadata inodes should not affect quotas */
+       ip->i_flags |= S_NOQUOTA;
+
        if ((inum == FILESYSTEM_I) && (JFS_IP(ip)->ipimap == sbi->ipaimap)) {
                sbi->gengen = le32_to_cpu(dp->di_gengen);
                sbi->inostamp = le32_to_cpu(dp->di_inostamp);
@@ -1281,6 +1285,7 @@ int diFree(struct inode *ip)
         * to be freed by the transaction;  
         */
        tid = txBegin(ipimap->i_sb, COMMIT_FORCE);
+       down(&JFS_IP(ipimap)->commit_sem);
 
        /* acquire tlock of the iag page of the freed ixad 
         * to force the page NOHOMEOK (even though no data is
@@ -1313,6 +1318,7 @@ int diFree(struct inode *ip)
        rc = txCommit(tid, 1, &iplist[0], COMMIT_FORCE);
 
        txEnd(tid);
+       up(&JFS_IP(ipimap)->commit_sem);
 
        /* unlock the AG inode map information */
        AG_UNLOCK(imap, agno);
@@ -2062,7 +2068,7 @@ static int diAllocBit(struct inomap * imap, struct iag * iagp, int ino)
 {
        int extno, bitno, agno, sword, rc;
        struct metapage *amp = NULL, *bmp = NULL;
-       struct iag *aiagp = 0, *biagp = 0;
+       struct iag *aiagp = NULL, *biagp = NULL;
        u32 mask;
 
        /* check if this is the last free inode within the iag.
@@ -2208,7 +2214,7 @@ static int diAllocBit(struct inomap * imap, struct iag * iagp, int ino)
 static int diNewExt(struct inomap * imap, struct iag * iagp, int extno)
 {
        int agno, iagno, fwd, back, freei = 0, sword, rc;
-       struct iag *aiagp = 0, *biagp = 0, *ciagp = 0;
+       struct iag *aiagp = NULL, *biagp = NULL, *ciagp = NULL;
        struct metapage *amp, *bmp, *cmp, *dmp;
        struct inode *ipimap;
        s64 blkno, hint;
@@ -2600,33 +2606,19 @@ diNewIAG(struct inomap * imap, int *iagnop, int agno, struct metapage ** mpp)
                        iagp->inosmap[i] = ONES;
 
                flush_metapage(mp);
-#ifdef _STILL_TO_PORT
-               /* synchronously write the iag page */
-               if (bmWrite(bp)) {
-                       /* Free the blocks allocated for the iag since it was
-                        * not successfully added to the inode map
-                        */
-                       dbFree(ipimap, xaddr, (s64) xlen);
-
-                       /* release the inode map lock */
-                       IWRITE_UNLOCK(ipimap);
-
-                       rc = -EIO;
-                       goto out;
-               }
-
-               /* Now the iag is on disk */
 
                /*
                 * start tyransaction of update of the inode map
                 * addressing structure pointing to the new iag page;
                 */
-#endif                         /*  _STILL_TO_PORT */
                tid = txBegin(sb, COMMIT_FORCE);
+               down(&JFS_IP(ipimap)->commit_sem);
 
                /* update the inode map addressing structure to point to it */
                if ((rc =
                     xtInsert(tid, ipimap, 0, blkno, xlen, &xaddr, 0))) {
+                       txEnd(tid);
+                       up(&JFS_IP(ipimap)->commit_sem);
                        /* Free the blocks allocated for the iag since it was
                         * not successfully added to the inode map
                         */
@@ -2640,7 +2632,7 @@ diNewIAG(struct inomap * imap, int *iagnop, int agno, struct metapage ** mpp)
 
                /* update the inode map's inode to reflect the extension */
                ipimap->i_size += PSIZE;
-               ipimap->i_blocks += LBLK2PBLK(sb, xlen);
+               inode_add_bytes(ipimap, PSIZE);
 
                /*
                 * txCommit(COMMIT_FORCE) will synchronously write address 
@@ -2651,6 +2643,7 @@ diNewIAG(struct inomap * imap, int *iagnop, int agno, struct metapage ** mpp)
                rc = txCommit(tid, 1, &iplist[0], COMMIT_FORCE);
 
                txEnd(tid);
+               up(&JFS_IP(ipimap)->commit_sem);
 
                duplicateIXtree(sb, blkno, xlen, &xaddr);
 
@@ -2911,7 +2904,7 @@ int diExtendFS(struct inode *ipimap, struct inode *ipbmap)
 {
        int rc, rcx = 0;
        struct inomap *imap = JFS_IP(ipimap)->i_imap;
-       struct iag *iagp = 0, *hiagp = 0;
+       struct iag *iagp = NULL, *hiagp = NULL;
        struct bmap *mp = JFS_SBI(ipbmap->i_sb)->bmap;
        struct metapage *bp, *hbp;
        int i, n, head;
@@ -3080,7 +3073,7 @@ static void duplicateIXtree(struct super_block *sb, s64 blkno,
        }
        /* update the inode map's inode to reflect the extension */
        ip->i_size += PSIZE;
-       ip->i_blocks += LBLK2PBLK(sb, xlen);
+       inode_add_bytes(ip, PSIZE);
        txCommit(tid, 1, &ip, COMMIT_FORCE);
       cleanup:
        txEnd(tid);
@@ -3110,10 +3103,10 @@ static int copy_from_dinode(struct dinode * dip, struct inode *ip)
 
        uid = le32_to_cpu(dip->di_uid);
        gid = le32_to_cpu(dip->di_gid);
-       ip->i_uid = INOXID_UID(uid, gid);
-       ip->i_gid = INOXID_GID(uid, gid);
-       ip->i_xid = INOXID_XID(uid, gid, 0);
-       
+       ip->i_uid = INOXID_UID(XID_TAG(ip), uid, gid);
+       ip->i_gid = INOXID_GID(XID_TAG(ip), uid, gid);
+       ip->i_xid = INOXID_XID(XID_TAG(ip), uid, gid, 0);
+
        ip->i_size = le64_to_cpu(dip->di_size);
        ip->i_atime.tv_sec = le32_to_cpu(dip->di_atime.tv_sec);
        ip->i_atime.tv_nsec = le32_to_cpu(dip->di_atime.tv_nsec);
@@ -3175,8 +3168,8 @@ static void copy_to_dinode(struct dinode * dip, struct inode *ip)
        dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
        dip->di_nlink = cpu_to_le32(ip->i_nlink);
 
-       uid = XIDINO_UID(ip->i_uid, ip->i_xid);
-       gid = XIDINO_GID(ip->i_gid, ip->i_xid);
+       uid = XIDINO_UID(XID_TAG(ip), ip->i_uid, ip->i_xid);
+       gid = XIDINO_GID(XID_TAG(ip), ip->i_gid, ip->i_xid);
        dip->di_uid = cpu_to_le32(uid);
        dip->di_gid = cpu_to_le32(gid);
        /*