vserver 1.9.3
[linux-2.6.git] / fs / jfs / namei.c
index 8c3a8e7..e089615 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/fs.h>
 #include <linux/ctype.h>
+#include <linux/quotaops.h>
 #include "jfs_incore.h"
 #include "jfs_superblock.h"
 #include "jfs_inode.h"
@@ -123,10 +124,10 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode,
         */
        ino = ip->i_ino;
        if ((rc = dtInsert(tid, dip, &dname, &ino, &btstack))) {
-               jfs_err("jfs_create: dtInsert returned %d", rc);
-               if (rc == -EIO)
+               if (rc == -EIO) {
+                       jfs_err("jfs_create: dtInsert returned -EIO");
                        txAbort(tid, 1);        /* Marks Filesystem dirty */
-               else
+               else
                        txAbort(tid, 0);        /* Filesystem full */
                goto out3;
        }
@@ -250,11 +251,10 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode)
         */
        ino = ip->i_ino;
        if ((rc = dtInsert(tid, dip, &dname, &ino, &btstack))) {
-               jfs_err("jfs_mkdir: dtInsert returned %d", rc);
-
-               if (rc == -EIO)
+               if (rc == -EIO) {
+                       jfs_err("jfs_mkdir: dtInsert returned -EIO");
                        txAbort(tid, 1);        /* Marks Filesystem dirty */
-               else
+               else
                        txAbort(tid, 0);        /* Filesystem full */
                goto out3;
        }
@@ -330,6 +330,9 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry)
 
        jfs_info("jfs_rmdir: dip:0x%p name:%s", dip, dentry->d_name.name);
 
+       /* Init inode for quota operations. */
+       DQUOT_INIT(ip);
+
        /* directory must be empty to be removed */
        if (!dtEmpty(ip)) {
                rc = -ENOTEMPTY;
@@ -455,6 +458,9 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry)
 
        jfs_info("jfs_unlink: dip:0x%p name:%s", dip, dentry->d_name.name);
 
+       /* Init inode for quota operations. */
+       DQUOT_INIT(ip);
+
        if ((rc = get_UCSname(&dname, dentry)))
                goto out;
 
@@ -813,7 +819,10 @@ static int jfs_link(struct dentry *old_dentry,
        iplist[1] = dir;
        rc = txCommit(tid, 2, &iplist[0], 0);
 
-       if (!rc)
+       if (rc) {
+               ip->i_nlink--;
+               iput(ip);
+       } else
                d_instantiate(dentry, ip);
 
       free_dname:
@@ -964,7 +973,7 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
                        mp = get_metapage(ip, xaddr, PSIZE, 1);
 
                        if (mp == NULL) {
-                               dbFree(ip, extent, xlen);
+                               xtTruncate(tid, ip, 0, COMMIT_PWMAP);
                                rc = -EIO;
                                txAbort(tid, 0);
                                goto out3;
@@ -975,7 +984,6 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
                        name += copy_size;
                        xaddr += JFS_SBI(sb)->nbperpage;
                }
-               ip->i_blocks = LBLK2PBLK(sb, xlen);
        }
 
        /*
@@ -988,7 +996,7 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
        }
        if (rc) {
                if (xlen)
-                       dbFree(ip, extent, xlen);
+                       xtTruncate(tid, ip, 0, COMMIT_PWMAP);
                txAbort(tid, 0);
                /* discard new inode */
                goto out3;
@@ -1104,8 +1112,11 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                        rc = -EMLINK;
                        goto out3;
                }
-       } else if (new_ip)
+       } else if (new_ip) {
                IWRITE_LOCK(new_ip);
+               /* Init inode for quota operations. */
+               DQUOT_INIT(new_ip);
+       }
 
        /*
         * The real work starts here
@@ -1174,8 +1185,8 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                ino = old_ip->i_ino;
                rc = dtInsert(tid, new_dir, &new_dname, &ino, &btstack);
                if (rc) {
-                       jfs_err("jfs_rename: dtInsert failed w/rc = %d",
-                               rc);
+                       if (rc == -EIO)
+                               jfs_err("jfs_rename: dtInsert returned -EIO");
                        goto out4;
                }
                if (S_ISDIR(old_ip->i_mode))