]> err.no Git - linux-2.6/blobdiff - fs/xfs/linux-2.6/xfs_iops.c
Merge master.kernel.org:/home/rmk/linux-2.6-arm
[linux-2.6] / fs / xfs / linux-2.6 / xfs_iops.c
index 52b02bd5c283d34f9e06c47c5565c681aa3fd675..af487437bd7e7e6c0de33b94389a567e0ce93b7f 100644 (file)
@@ -106,7 +106,7 @@ xfs_ichgtime(
        xfs_inode_t     *ip,
        int             flags)
 {
-       struct inode    *inode = LINVFS_GET_IP(XFS_ITOV(ip));
+       struct inode    *inode = vn_to_inode(XFS_ITOV(ip));
        timespec_t      tv;
 
        nanotime(&tv);
@@ -198,11 +198,11 @@ xfs_ichgtime_fast(
  * Pull the link count and size up from the xfs inode to the linux inode
  */
 STATIC void
-__linvfs_validate_fields(
+xfs_validate_fields(
        struct inode    *ip,
        struct vattr    *vattr)
 {
-       vnode_t         *vp = LINVFS_GET_VP(ip);
+       vnode_t         *vp = vn_from_inode(ip);
        int             error;
 
        vattr->va_mask = XFS_AT_NLINK|XFS_AT_SIZE|XFS_AT_NBLOCKS;
@@ -224,11 +224,11 @@ __linvfs_validate_fields(
  * inode, of course, such that log replay can't cause these to be lost).
  */
 STATIC int
-__linvfs_init_security(
+xfs_init_security(
        struct vnode    *vp,
        struct inode    *dir)
 {
-       struct inode    *ip = LINVFS_GET_IP(vp);
+       struct inode    *ip = vn_to_inode(vp);
        size_t          length;
        void            *value;
        char            *name;
@@ -257,13 +257,13 @@ __linvfs_init_security(
  * XXX(hch):  nfsd is broken, better fix it instead.
  */
 STATIC inline int
-__linvfs_has_fs_struct(struct task_struct *task)
+xfs_has_fs_struct(struct task_struct *task)
 {
        return (task->fs != init_task.fs);
 }
 
 STATIC inline void
-__linvfs_cleanup_inode(
+xfs_cleanup_inode(
        vnode_t         *dvp,
        vnode_t         *vp,
        struct dentry   *dentry,
@@ -274,10 +274,10 @@ __linvfs_cleanup_inode(
 
        /* Oh, the horror.
         * If we can't add the ACL or we fail in
-        * linvfs_init_security we must back out.
+        * xfs_init_security we must back out.
         * ENOSPC can hit here, among other things.
         */
-       teardown.d_inode = LINVFS_GET_IP(vp);
+       teardown.d_inode = vn_to_inode(vp);
        teardown.d_name = dentry->d_name;
 
        if (S_ISDIR(mode))
@@ -288,15 +288,15 @@ __linvfs_cleanup_inode(
 }
 
 STATIC int
-linvfs_mknod(
+xfs_vn_mknod(
        struct inode    *dir,
        struct dentry   *dentry,
        int             mode,
        dev_t           rdev)
 {
        struct inode    *ip;
-       vattr_t         *vattr;
-       vnode_t         *vp = NULL, *dvp = LINVFS_GET_VP(dir);
+       vattr_t         vattr = { 0 };
+       vnode_t         *vp = NULL, *dvp = vn_from_inode(dir);
        xfs_acl_t       *default_acl = NULL;
        attrexists_t    test_default_acl = _ACL_DEFAULT_EXISTS;
        int             error;
@@ -308,13 +308,8 @@ linvfs_mknod(
        if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff))
                return -EINVAL;
 
-       vattr = kmalloc(sizeof(*vattr), GFP_KERNEL);
-       if (unlikely(!vattr))
-               return -ENOMEM;
-
        if (unlikely(test_default_acl && test_default_acl(dvp))) {
                if (!_ACL_ALLOC(default_acl)) {
-                       kfree(vattr);
                        return -ENOMEM;
                }
                if (!_ACL_GET_DEFAULT(dvp, default_acl)) {
@@ -323,23 +318,22 @@ linvfs_mknod(
                }
        }
 
-       if (IS_POSIXACL(dir) && !default_acl && __linvfs_has_fs_struct(current))
+       if (IS_POSIXACL(dir) && !default_acl && xfs_has_fs_struct(current))
                mode &= ~current->fs->umask;
 
-       memset(vattr, 0, sizeof(*vattr));
-       vattr->va_mask = XFS_AT_TYPE|XFS_AT_MODE;
-       vattr->va_mode = mode;
+       vattr.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
+       vattr.va_mode = mode;
 
        switch (mode & S_IFMT) {
        case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK:
-               vattr->va_rdev = sysv_encode_dev(rdev);
-               vattr->va_mask |= XFS_AT_RDEV;
+               vattr.va_rdev = sysv_encode_dev(rdev);
+               vattr.va_mask |= XFS_AT_RDEV;
                /*FALLTHROUGH*/
        case S_IFREG:
-               VOP_CREATE(dvp, dentry, vattr, &vp, NULL, error);
+               VOP_CREATE(dvp, dentry, &vattr, &vp, NULL, error);
                break;
        case S_IFDIR:
-               VOP_MKDIR(dvp, dentry, vattr, &vp, NULL, error);
+               VOP_MKDIR(dvp, dentry, &vattr, &vp, NULL, error);
                break;
        default:
                error = EINVAL;
@@ -347,63 +341,62 @@ linvfs_mknod(
        }
 
        if (unlikely(!error)) {
-               error = __linvfs_init_security(vp, dir);
+               error = xfs_init_security(vp, dir);
                if (error)
-                       __linvfs_cleanup_inode(dvp, vp, dentry, mode);
+                       xfs_cleanup_inode(dvp, vp, dentry, mode);
        }
 
        if (unlikely(default_acl)) {
                if (!error) {
-                       error = _ACL_INHERIT(vp, vattr, default_acl);
+                       error = _ACL_INHERIT(vp, &vattr, default_acl);
                        if (!error)
                                VMODIFY(vp);
                        else
-                               __linvfs_cleanup_inode(dvp, vp, dentry, mode);
+                               xfs_cleanup_inode(dvp, vp, dentry, mode);
                }
                _ACL_FREE(default_acl);
        }
 
        if (likely(!error)) {
                ASSERT(vp);
-               ip = LINVFS_GET_IP(vp);
+               ip = vn_to_inode(vp);
 
                if (S_ISCHR(mode) || S_ISBLK(mode))
                        ip->i_rdev = rdev;
                else if (S_ISDIR(mode))
-                       __linvfs_validate_fields(ip, vattr);
+                       xfs_validate_fields(ip, &vattr);
                d_instantiate(dentry, ip);
-               __linvfs_validate_fields(dir, vattr);
+               xfs_validate_fields(dir, &vattr);
        }
-       kfree(vattr);
        return -error;
 }
 
 STATIC int
-linvfs_create(
+xfs_vn_create(
        struct inode    *dir,
        struct dentry   *dentry,
        int             mode,
        struct nameidata *nd)
 {
-       return linvfs_mknod(dir, dentry, mode, 0);
+       return xfs_vn_mknod(dir, dentry, mode, 0);
 }
 
 STATIC int
-linvfs_mkdir(
+xfs_vn_mkdir(
        struct inode    *dir,
        struct dentry   *dentry,
        int             mode)
 {
-       return linvfs_mknod(dir, dentry, mode|S_IFDIR, 0);
+       return xfs_vn_mknod(dir, dentry, mode|S_IFDIR, 0);
 }
 
 STATIC struct dentry *
-linvfs_lookup(
+xfs_vn_lookup(
        struct inode    *dir,
        struct dentry   *dentry,
        struct nameidata *nd)
 {
-       struct vnode    *vp = LINVFS_GET_VP(dir), *cvp;
+       struct vnode    *vp = vn_from_inode(dir), *cvp;
        int             error;
 
        if (dentry->d_name.len >= MAXNAMELEN)
@@ -417,11 +410,11 @@ linvfs_lookup(
                return NULL;
        }
 
-       return d_splice_alias(LINVFS_GET_IP(cvp), dentry);
+       return d_splice_alias(vn_to_inode(cvp), dentry);
 }
 
 STATIC int
-linvfs_link(
+xfs_vn_link(
        struct dentry   *old_dentry,
        struct inode    *dir,
        struct dentry   *dentry)
@@ -429,121 +422,102 @@ linvfs_link(
        struct inode    *ip;    /* inode of guy being linked to */
        vnode_t         *tdvp;  /* target directory for new name/link */
        vnode_t         *vp;    /* vp of name being linked */
-       vattr_t         *vattr;
+       vattr_t         vattr;
        int             error;
 
        ip = old_dentry->d_inode;       /* inode being linked to */
        if (S_ISDIR(ip->i_mode))
                return -EPERM;
 
-       vattr = kmalloc(sizeof(*vattr), GFP_KERNEL);
-       if (unlikely(!vattr))
-               return -ENOMEM;
-
-       tdvp = LINVFS_GET_VP(dir);
-       vp = LINVFS_GET_VP(ip);
+       tdvp = vn_from_inode(dir);
+       vp = vn_from_inode(ip);
 
        VOP_LINK(tdvp, vp, dentry, NULL, error);
        if (likely(!error)) {
                VMODIFY(tdvp);
                VN_HOLD(vp);
-               __linvfs_validate_fields(ip, vattr);
+               xfs_validate_fields(ip, &vattr);
                d_instantiate(dentry, ip);
        }
-       kfree(vattr);
        return -error;
 }
 
 STATIC int
-linvfs_unlink(
+xfs_vn_unlink(
        struct inode    *dir,
        struct dentry   *dentry)
 {
        struct inode    *inode;
        vnode_t         *dvp;   /* directory containing name to remove */
-       vattr_t         *vattr;
+       vattr_t         vattr;
        int             error;
 
-       vattr = kmalloc(sizeof(*vattr), GFP_KERNEL);
-       if (unlikely(!vattr))
-               return -ENOMEM;
-
        inode = dentry->d_inode;
-       dvp = LINVFS_GET_VP(dir);
+       dvp = vn_from_inode(dir);
 
        VOP_REMOVE(dvp, dentry, NULL, error);
        if (likely(!error)) {
-               __linvfs_validate_fields(dir, vattr);   /* size needs update */
-               __linvfs_validate_fields(inode, vattr);
+               xfs_validate_fields(dir, &vattr);       /* size needs update */
+               xfs_validate_fields(inode, &vattr);
        }
-       kfree(vattr);
        return -error;
 }
 
 STATIC int
-linvfs_symlink(
+xfs_vn_symlink(
        struct inode    *dir,
        struct dentry   *dentry,
        const char      *symname)
 {
        struct inode    *ip;
-       vattr_t         *vattr;
+       vattr_t         vattr = { 0 };
        vnode_t         *dvp;   /* directory containing name of symlink */
        vnode_t         *cvp;   /* used to lookup symlink to put in dentry */
        int             error;
 
-       dvp = LINVFS_GET_VP(dir);
+       dvp = vn_from_inode(dir);
        cvp = NULL;
 
-       vattr = kmalloc(sizeof(*vattr), GFP_KERNEL);
-       if (unlikely(!vattr))
-               return -ENOMEM;
-
-       memset(vattr, 0, sizeof(*vattr));
-       vattr->va_mode = S_IFLNK |
+       vattr.va_mode = S_IFLNK |
                (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO);
-       vattr->va_mask = XFS_AT_TYPE|XFS_AT_MODE;
+       vattr.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
 
        error = 0;
-       VOP_SYMLINK(dvp, dentry, vattr, (char *)symname, &cvp, NULL, error);
+       VOP_SYMLINK(dvp, dentry, &vattr, (char *)symname, &cvp, NULL, error);
        if (likely(!error && cvp)) {
-               error = __linvfs_init_security(cvp, dir);
+               error = xfs_init_security(cvp, dir);
                if (likely(!error)) {
-                       ip = LINVFS_GET_IP(cvp);
+                       ip = vn_to_inode(cvp);
                        d_instantiate(dentry, ip);
-                       __linvfs_validate_fields(dir, vattr);
-                       __linvfs_validate_fields(ip, vattr);
+                       xfs_validate_fields(dir, &vattr);
+                       xfs_validate_fields(ip, &vattr);
+               } else {
+                       xfs_cleanup_inode(dvp, cvp, dentry, 0);
                }
        }
-       kfree(vattr);
        return -error;
 }
 
 STATIC int
-linvfs_rmdir(
+xfs_vn_rmdir(
        struct inode    *dir,
        struct dentry   *dentry)
 {
        struct inode    *inode = dentry->d_inode;
-       vnode_t         *dvp = LINVFS_GET_VP(dir);
-       vattr_t         *vattr;
+       vnode_t         *dvp = vn_from_inode(dir);
+       vattr_t         vattr;
        int             error;
 
-       vattr = kmalloc(sizeof(*vattr), GFP_KERNEL);
-       if (unlikely(!vattr))
-               return -ENOMEM;
-
        VOP_RMDIR(dvp, dentry, NULL, error);
        if (likely(!error)) {
-               __linvfs_validate_fields(inode, vattr);
-               __linvfs_validate_fields(dir, vattr);
+               xfs_validate_fields(inode, &vattr);
+               xfs_validate_fields(dir, &vattr);
        }
-       kfree(vattr);
        return -error;
 }
 
 STATIC int
-linvfs_rename(
+xfs_vn_rename(
        struct inode    *odir,
        struct dentry   *odentry,
        struct inode    *ndir,
@@ -552,25 +526,20 @@ linvfs_rename(
        struct inode    *new_inode = ndentry->d_inode;
        vnode_t         *fvp;   /* from directory */
        vnode_t         *tvp;   /* target directory */
-       vattr_t         *vattr;
+       vattr_t         vattr;
        int             error;
 
-       vattr = kmalloc(sizeof(*vattr), GFP_KERNEL);
-       if (unlikely(!vattr))
-               return -ENOMEM;
-
-       fvp = LINVFS_GET_VP(odir);
-       tvp = LINVFS_GET_VP(ndir);
+       fvp = vn_from_inode(odir);
+       tvp = vn_from_inode(ndir);
 
        VOP_RENAME(fvp, odentry, tvp, ndentry, NULL, error);
        if (likely(!error)) {
                if (new_inode)
-                       __linvfs_validate_fields(new_inode, vattr);
-               __linvfs_validate_fields(odir, vattr);
+                       xfs_validate_fields(new_inode, &vattr);
+               xfs_validate_fields(odir, &vattr);
                if (ndir != odir)
-                       __linvfs_validate_fields(ndir, vattr);
+                       xfs_validate_fields(ndir, &vattr);
        }
-       kfree(vattr);
        return -error;
 }
 
@@ -580,7 +549,7 @@ linvfs_rename(
  * uio is kmalloced for this reason...
  */
 STATIC void *
-linvfs_follow_link(
+xfs_vn_follow_link(
        struct dentry           *dentry,
        struct nameidata        *nd)
 {
@@ -606,7 +575,7 @@ linvfs_follow_link(
                return NULL;
        }
 
-       vp = LINVFS_GET_VP(dentry->d_inode);
+       vp = vn_from_inode(dentry->d_inode);
 
        iov.iov_base = link;
        iov.iov_len = MAXPATHLEN;
@@ -631,7 +600,7 @@ linvfs_follow_link(
 }
 
 STATIC void
-linvfs_put_link(
+xfs_vn_put_link(
        struct dentry   *dentry,
        struct nameidata *nd,
        void            *p)
@@ -644,12 +613,12 @@ linvfs_put_link(
 
 #ifdef CONFIG_XFS_POSIX_ACL
 STATIC int
-linvfs_permission(
+xfs_vn_permission(
        struct inode    *inode,
        int             mode,
        struct nameidata *nd)
 {
-       vnode_t         *vp = LINVFS_GET_VP(inode);
+       vnode_t         *vp = vn_from_inode(inode);
        int             error;
 
        mode <<= 6;             /* convert from linux to vnode access bits */
@@ -657,17 +626,17 @@ linvfs_permission(
        return -error;
 }
 #else
-#define linvfs_permission NULL
+#define xfs_vn_permission NULL
 #endif
 
 STATIC int
-linvfs_getattr(
+xfs_vn_getattr(
        struct vfsmount *mnt,
        struct dentry   *dentry,
        struct kstat    *stat)
 {
        struct inode    *inode = dentry->d_inode;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
+       vnode_t         *vp = vn_from_inode(inode);
        int             error = 0;
 
        if (unlikely(vp->v_flag & VMODIFIED))
@@ -678,13 +647,13 @@ linvfs_getattr(
 }
 
 STATIC int
-linvfs_setattr(
+xfs_vn_setattr(
        struct dentry   *dentry,
        struct iattr    *attr)
 {
        struct inode    *inode = dentry->d_inode;
        unsigned int    ia_valid = attr->ia_valid;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
+       vnode_t         *vp = vn_from_inode(inode);
        vattr_t         vattr = { 0 };
        int             flags = 0;
        int             error;
@@ -736,21 +705,21 @@ linvfs_setattr(
 }
 
 STATIC void
-linvfs_truncate(
+xfs_vn_truncate(
        struct inode    *inode)
 {
        block_truncate_page(inode->i_mapping, inode->i_size, xfs_get_block);
 }
 
 STATIC int
-linvfs_setxattr(
+xfs_vn_setxattr(
        struct dentry   *dentry,
        const char      *name,
        const void      *data,
        size_t          size,
        int             flags)
 {
-       vnode_t         *vp = LINVFS_GET_VP(dentry->d_inode);
+       vnode_t         *vp = vn_from_inode(dentry->d_inode);
        char            *attr = (char *)name;
        attrnames_t     *namesp;
        int             xflags = 0;
@@ -774,13 +743,13 @@ linvfs_setxattr(
 }
 
 STATIC ssize_t
-linvfs_getxattr(
+xfs_vn_getxattr(
        struct dentry   *dentry,
        const char      *name,
        void            *data,
        size_t          size)
 {
-       vnode_t         *vp = LINVFS_GET_VP(dentry->d_inode);
+       vnode_t         *vp = vn_from_inode(dentry->d_inode);
        char            *attr = (char *)name;
        attrnames_t     *namesp;
        int             xflags = 0;
@@ -804,12 +773,12 @@ linvfs_getxattr(
 }
 
 STATIC ssize_t
-linvfs_listxattr(
+xfs_vn_listxattr(
        struct dentry           *dentry,
        char                    *data,
        size_t                  size)
 {
-       vnode_t                 *vp = LINVFS_GET_VP(dentry->d_inode);
+       vnode_t                 *vp = vn_from_inode(dentry->d_inode);
        int                     error, xflags = ATTR_KERNAMELS;
        ssize_t                 result;
 
@@ -824,11 +793,11 @@ linvfs_listxattr(
 }
 
 STATIC int
-linvfs_removexattr(
+xfs_vn_removexattr(
        struct dentry   *dentry,
        const char      *name)
 {
-       vnode_t         *vp = LINVFS_GET_VP(dentry->d_inode);
+       vnode_t         *vp = vn_from_inode(dentry->d_inode);
        char            *attr = (char *)name;
        attrnames_t     *namesp;
        int             xflags = 0;
@@ -846,45 +815,45 @@ linvfs_removexattr(
 }
 
 
-struct inode_operations linvfs_file_inode_operations = {
-       .permission             = linvfs_permission,
-       .truncate               = linvfs_truncate,
-       .getattr                = linvfs_getattr,
-       .setattr                = linvfs_setattr,
-       .setxattr               = linvfs_setxattr,
-       .getxattr               = linvfs_getxattr,
-       .listxattr              = linvfs_listxattr,
-       .removexattr            = linvfs_removexattr,
+struct inode_operations xfs_inode_operations = {
+       .permission             = xfs_vn_permission,
+       .truncate               = xfs_vn_truncate,
+       .getattr                = xfs_vn_getattr,
+       .setattr                = xfs_vn_setattr,
+       .setxattr               = xfs_vn_setxattr,
+       .getxattr               = xfs_vn_getxattr,
+       .listxattr              = xfs_vn_listxattr,
+       .removexattr            = xfs_vn_removexattr,
 };
 
-struct inode_operations linvfs_dir_inode_operations = {
-       .create                 = linvfs_create,
-       .lookup                 = linvfs_lookup,
-       .link                   = linvfs_link,
-       .unlink                 = linvfs_unlink,
-       .symlink                = linvfs_symlink,
-       .mkdir                  = linvfs_mkdir,
-       .rmdir                  = linvfs_rmdir,
-       .mknod                  = linvfs_mknod,
-       .rename                 = linvfs_rename,
-       .permission             = linvfs_permission,
-       .getattr                = linvfs_getattr,
-       .setattr                = linvfs_setattr,
-       .setxattr               = linvfs_setxattr,
-       .getxattr               = linvfs_getxattr,
-       .listxattr              = linvfs_listxattr,
-       .removexattr            = linvfs_removexattr,
+struct inode_operations xfs_dir_inode_operations = {
+       .create                 = xfs_vn_create,
+       .lookup                 = xfs_vn_lookup,
+       .link                   = xfs_vn_link,
+       .unlink                 = xfs_vn_unlink,
+       .symlink                = xfs_vn_symlink,
+       .mkdir                  = xfs_vn_mkdir,
+       .rmdir                  = xfs_vn_rmdir,
+       .mknod                  = xfs_vn_mknod,
+       .rename                 = xfs_vn_rename,
+       .permission             = xfs_vn_permission,
+       .getattr                = xfs_vn_getattr,
+       .setattr                = xfs_vn_setattr,
+       .setxattr               = xfs_vn_setxattr,
+       .getxattr               = xfs_vn_getxattr,
+       .listxattr              = xfs_vn_listxattr,
+       .removexattr            = xfs_vn_removexattr,
 };
 
-struct inode_operations linvfs_symlink_inode_operations = {
+struct inode_operations xfs_symlink_inode_operations = {
        .readlink               = generic_readlink,
-       .follow_link            = linvfs_follow_link,
-       .put_link               = linvfs_put_link,
-       .permission             = linvfs_permission,
-       .getattr                = linvfs_getattr,
-       .setattr                = linvfs_setattr,
-       .setxattr               = linvfs_setxattr,
-       .getxattr               = linvfs_getxattr,
-       .listxattr              = linvfs_listxattr,
-       .removexattr            = linvfs_removexattr,
+       .follow_link            = xfs_vn_follow_link,
+       .put_link               = xfs_vn_put_link,
+       .permission             = xfs_vn_permission,
+       .getattr                = xfs_vn_getattr,
+       .setattr                = xfs_vn_setattr,
+       .setxattr               = xfs_vn_setxattr,
+       .getxattr               = xfs_vn_getxattr,
+       .listxattr              = xfs_vn_listxattr,
+       .removexattr            = xfs_vn_removexattr,
 };