linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / fs / jfs / namei.c
index e089615..a32f2f5 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/fs.h>
 #include <linux/ctype.h>
 #include <linux/quotaops.h>
+#include <linux/vserver/xid.h>
 #include "jfs_incore.h"
 #include "jfs_superblock.h"
 #include "jfs_inode.h"
 #include "jfs_acl.h"
 #include "jfs_debug.h"
 
-extern struct inode_operations jfs_file_inode_operations;
-extern struct inode_operations jfs_symlink_inode_operations;
-extern struct file_operations jfs_file_operations;
-extern struct address_space_operations jfs_aops;
-
-extern int jfs_fsync(struct file *, struct dentry *, int);
-extern void jfs_truncate_nolock(struct inode *, loff_t);
-extern int jfs_init_acl(struct inode *, struct inode *);
-
 /*
  * forward references
  */
-struct inode_operations jfs_dir_inode_operations;
-struct file_operations jfs_dir_operations;
 struct dentry_operations jfs_ci_dentry_operations;
 
 static s64 commitZeroLink(tid_t, struct inode *);
 
+/*
+ * NAME:       free_ea_wmap(inode)
+ *
+ * FUNCTION:   free uncommitted extended attributes from working map 
+ *
+ */
+static inline void free_ea_wmap(struct inode *inode)
+{
+       dxd_t *ea = &JFS_IP(inode)->ea;
+
+       if (ea->flag & DXD_EXTENT) {
+               /* free EA pages from cache */
+               invalidate_dxd_metapages(inode, *ea);
+               dbFree(inode, addressDXD(ea), lengthDXD(ea));
+       }
+       ea->flag = 0;
+}
+
 /*
  * NAME:       jfs_create(dip, dentry, mode)
  *
@@ -100,8 +108,19 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode,
        down(&JFS_IP(dip)->commit_sem);
        down(&JFS_IP(ip)->commit_sem);
 
+       rc = jfs_init_acl(tid, ip, dip);
+       if (rc)
+               goto out3;
+
+       rc = jfs_init_security(tid, ip, dip);
+       if (rc) {
+               txAbort(tid, 0);
+               goto out3;
+       }
+
        if ((rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))) {
                jfs_err("jfs_create: dtSearch returned %d", rc);
+               txAbort(tid, 0);
                goto out3;
        }
 
@@ -150,6 +169,7 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode,
        up(&JFS_IP(dip)->commit_sem);
        up(&JFS_IP(ip)->commit_sem);
        if (rc) {
+               free_ea_wmap(ip);
                ip->i_nlink = 0;
                iput(ip);
        } else
@@ -158,11 +178,6 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode,
       out2:
        free_UCSname(&dname);
 
-#ifdef CONFIG_JFS_POSIX_ACL
-       if (rc == 0)
-               jfs_init_acl(ip, dip);
-#endif
-
       out1:
 
        jfs_info("jfs_create: rc:%d", rc);
@@ -227,8 +242,19 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode)
        down(&JFS_IP(dip)->commit_sem);
        down(&JFS_IP(ip)->commit_sem);
 
+       rc = jfs_init_acl(tid, ip, dip);
+       if (rc)
+               goto out3;
+
+       rc = jfs_init_security(tid, ip, dip);
+       if (rc) {
+               txAbort(tid, 0);
+               goto out3;
+       }
+
        if ((rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))) {
                jfs_err("jfs_mkdir: dtSearch returned %d", rc);
+               txAbort(tid, 0);
                goto out3;
        }
 
@@ -262,8 +288,6 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode)
        ip->i_nlink = 2;        /* for '.' */
        ip->i_op = &jfs_dir_inode_operations;
        ip->i_fop = &jfs_dir_operations;
-       ip->i_mapping->a_ops = &jfs_aops;
-       mapping_set_gfp_mask(ip->i_mapping, GFP_NOFS);
 
        insert_inode_hash(ip);
        mark_inode_dirty(ip);
@@ -280,6 +304,7 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode)
        up(&JFS_IP(dip)->commit_sem);
        up(&JFS_IP(ip)->commit_sem);
        if (rc) {
+               free_ea_wmap(ip);
                ip->i_nlink = 0;
                iput(ip);
        } else
@@ -288,10 +313,6 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode)
       out2:
        free_UCSname(&dname);
 
-#ifdef CONFIG_JFS_POSIX_ACL
-       if (rc == 0)
-               jfs_init_acl(ip, dip);
-#endif
 
       out1:
 
@@ -657,7 +678,7 @@ static s64 commitZeroLink(tid_t tid, struct inode *ip)
 
 
 /*
- * NAME:       freeZeroLink()
+ * NAME:       jfs_free_zero_link()
  *
  * FUNCTION:    for non-directory, called by iClose(),
  *             free resources of a file from cache and WORKING map 
@@ -665,15 +686,12 @@ static s64 commitZeroLink(tid_t tid, struct inode *ip)
  *             while associated with a pager object,
  *
  * PARAMETER:  ip      - pointer to inode of file.
- *
- * RETURN:     0 -ok
  */
-int freeZeroLink(struct inode *ip)
+void jfs_free_zero_link(struct inode *ip)
 {
-       int rc = 0;
        int type;
 
-       jfs_info("freeZeroLink: ip = 0x%p", ip);
+       jfs_info("jfs_free_zero_link: ip = 0x%p", ip);
 
        /* return if not reg or symbolic link or if size is
         * already ok.
@@ -686,10 +704,10 @@ int freeZeroLink(struct inode *ip)
        case S_IFLNK:
                /* if its contained in inode nothing to do */
                if (ip->i_size < IDATASIZE)
-                       return 0;
+                       return;
                break;
        default:
-               return 0;
+               return;
        }
 
        /*
@@ -739,9 +757,7 @@ int freeZeroLink(struct inode *ip)
         * free xtree/data blocks from working block map;
         */
        if (ip->i_size)
-               rc = xtTruncate(0, ip, 0, COMMIT_WMAP);
-
-       return rc;
+               xtTruncate(0, ip, 0, COMMIT_WMAP);
 }
 
 /*
@@ -812,6 +828,7 @@ static int jfs_link(struct dentry *old_dentry,
        /* update object inode */
        ip->i_nlink++;          /* for new link */
        ip->i_ctime = CURRENT_TIME;
+       dir->i_ctime = dir->i_mtime = CURRENT_TIME;
        mark_inode_dirty(dir);
        atomic_inc(&ip->i_count);
 
@@ -903,6 +920,10 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
        down(&JFS_IP(dip)->commit_sem);
        down(&JFS_IP(ip)->commit_sem);
 
+       rc = jfs_init_security(tid, ip, dip);
+       if (rc)
+               goto out3;
+
        tblk = tid_to_tblock(tid);
        tblk->xflag |= COMMIT_CREATE;
        tblk->ino = ip->i_ino;
@@ -1005,6 +1026,8 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
        insert_inode_hash(ip);
        mark_inode_dirty(ip);
 
+       dip->i_ctime = dip->i_mtime = CURRENT_TIME;
+       mark_inode_dirty(dip);
        /*
         * commit update of parent directory and link object
         */
@@ -1018,6 +1041,7 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
        up(&JFS_IP(dip)->commit_sem);
        up(&JFS_IP(ip)->commit_sem);
        if (rc) {
+               free_ea_wmap(ip);
                ip->i_nlink = 0;
                iput(ip);
        } else
@@ -1026,11 +1050,6 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
       out2:
        free_UCSname(&dname);
 
-#ifdef CONFIG_JFS_POSIX_ACL
-       if (rc == 0)
-               jfs_init_acl(ip, dip);
-#endif
-
       out1:
        jfs_info("jfs_symlink: rc:%d", rc);
        return rc;
@@ -1233,7 +1252,7 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        old_ip->i_ctime = CURRENT_TIME;
        mark_inode_dirty(old_ip);
 
-       new_dir->i_ctime = new_dir->i_mtime = CURRENT_TIME;
+       new_dir->i_ctime = new_dir->i_mtime = current_fs_time(new_dir->i_sb);
        mark_inode_dirty(new_dir);
 
        /* Build list of inodes modified by this transaction */
@@ -1346,8 +1365,20 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry,
        down(&JFS_IP(dir)->commit_sem);
        down(&JFS_IP(ip)->commit_sem);
 
-       if ((rc = dtSearch(dir, &dname, &ino, &btstack, JFS_CREATE)))
+       rc = jfs_init_acl(tid, ip, dir);
+       if (rc)
+               goto out3;
+
+       rc = jfs_init_security(tid, ip, dir);
+       if (rc) {
+               txAbort(tid, 0);
                goto out3;
+       }
+
+       if ((rc = dtSearch(dir, &dname, &ino, &btstack, JFS_CREATE))) {
+               txAbort(tid, 0);
+               goto out3;
+       }
 
        tblk = tid_to_tblock(tid);
        tblk->xflag |= COMMIT_CREATE;
@@ -1355,8 +1386,10 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry,
        tblk->u.ixpxd = JFS_IP(ip)->ixpxd;
 
        ino = ip->i_ino;
-       if ((rc = dtInsert(tid, dir, &dname, &ino, &btstack)))
+       if ((rc = dtInsert(tid, dir, &dname, &ino, &btstack))) {
+               txAbort(tid, 0);
                goto out3;
+       }
 
        ip->i_op = &jfs_file_inode_operations;
        jfs_ip->dev = new_encode_dev(rdev);
@@ -1378,6 +1411,7 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry,
        up(&JFS_IP(ip)->commit_sem);
        up(&JFS_IP(dir)->commit_sem);
        if (rc) {
+               free_ea_wmap(ip);
                ip->i_nlink = 0;
                iput(ip);
        } else
@@ -1386,11 +1420,6 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry,
       out1:
        free_UCSname(&dname);
 
-#ifdef CONFIG_JFS_POSIX_ACL
-       if (rc == 0)
-               jfs_init_acl(ip, dir);
-#endif
-
       out:
        jfs_info("jfs_mknod: returning %d", rc);
        return rc;
@@ -1408,6 +1437,8 @@ static struct dentry *jfs_lookup(struct inode *dip, struct dentry *dentry, struc
 
        jfs_info("jfs_lookup: name = %s", name);
 
+       if (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2)
+               dentry->d_op = &jfs_ci_dentry_operations;
 
        if ((name[0] == '.') && (len == 1))
                inum = dip->i_ino;
@@ -1435,9 +1466,7 @@ static struct dentry *jfs_lookup(struct inode *dip, struct dentry *dentry, struc
                return ERR_PTR(-EACCES);
        }
 
-       if (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2)
-               dentry->d_op = &jfs_ci_dentry_operations;
-
+       vx_propagate_xid(nd, ip);
        dentry = d_splice_alias(ip, dentry);
 
        if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))