fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / fs / xfs / linux-2.6 / xfs_iops.c
index d2ac9c6..19525d4 100644 (file)
@@ -23,7 +23,6 @@
 #include "xfs_trans.h"
 #include "xfs_sb.h"
 #include "xfs_ag.h"
-#include "xfs_dir.h"
 #include "xfs_dir2.h"
 #include "xfs_alloc.h"
 #include "xfs_dmapi.h"
@@ -32,7 +31,6 @@
 #include "xfs_bmap_btree.h"
 #include "xfs_alloc_btree.h"
 #include "xfs_ialloc_btree.h"
-#include "xfs_dir_sf.h"
 #include "xfs_dir2_sf.h"
 #include "xfs_attr_sf.h"
 #include "xfs_dinode.h"
 #include <linux/xattr.h>
 #include <linux/namei.h>
 #include <linux/security.h>
-#include <linux/vserver/xid.h>
+#include <linux/vs_tag.h>
 
 /*
  * Get a XFS inode from a given vnode.
  */
 xfs_inode_t *
 xfs_vtoi(
-       struct vnode    *vp)
+       bhv_vnode_t     *vp)
 {
        bhv_desc_t      *bdp;
 
@@ -81,7 +79,7 @@ void
 xfs_synchronize_atime(
        xfs_inode_t     *ip)
 {
-       vnode_t         *vp;
+       bhv_vnode_t     *vp;
 
        vp = XFS_ITOV_NULL(ip);
        if (vp) {
@@ -107,7 +105,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);
@@ -199,22 +197,18 @@ xfs_ichgtime_fast(
  * Pull the link count and size up from the xfs inode to the linux inode
  */
 STATIC void
-validate_fields(
-       struct inode    *ip)
+xfs_validate_fields(
+       struct inode    *ip,
+       bhv_vattr_t     *vattr)
 {
-       vnode_t         *vp = LINVFS_GET_VP(ip);
-       vattr_t         va;
-       int             error;
-
-       va.va_mask = XFS_AT_NLINK|XFS_AT_SIZE|XFS_AT_NBLOCKS;
-       VOP_GETATTR(vp, &va, ATTR_LAZY, NULL, error);
-       if (likely(!error)) {
-               ip->i_nlink = va.va_nlink;
-               ip->i_blocks = va.va_nblocks;
-
-               /* we're under i_mutex so i_size can't change under us */
-               if (i_size_read(ip) != va.va_size)
-                       i_size_write(ip, va.va_size);
+       vattr->va_mask = XFS_AT_NLINK|XFS_AT_SIZE|XFS_AT_NBLOCKS;
+       if (!bhv_vop_getattr(vn_from_inode(ip), vattr, ATTR_LAZY, NULL)) {
+               ip->i_nlink = vattr->va_nlink;
+               ip->i_blocks = vattr->va_nblocks;
+
+               /* we're under i_sem so i_size can't change under us */
+               if (i_size_read(ip) != vattr->va_size)
+                       i_size_write(ip, vattr->va_size);
        }
 }
 
@@ -225,11 +219,11 @@ validate_fields(
  * inode, of course, such that log replay can't cause these to be lost).
  */
 STATIC int
-linvfs_init_security(
-       struct vnode    *vp,
+xfs_init_security(
+       bhv_vnode_t     *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;
@@ -242,7 +236,7 @@ linvfs_init_security(
                return -error;
        }
 
-       VOP_ATTR_SET(vp, name, value, length, ATTR_SECURE, NULL, error);
+       error = bhv_vop_attr_set(vp, name, value, length, ATTR_SECURE, NULL);
        if (!error)
                VMODIFY(vp);
 
@@ -258,46 +252,45 @@ linvfs_init_security(
  * XXX(hch):  nfsd is broken, better fix it instead.
  */
 STATIC inline int
-has_fs_struct(struct task_struct *task)
+xfs_has_fs_struct(struct task_struct *task)
 {
        return (task->fs != init_task.fs);
 }
 
 STATIC inline void
-cleanup_inode(
-       vnode_t         *dvp,
-       vnode_t         *vp,
-       struct dentry   *dentry,        
+xfs_cleanup_inode(
+       bhv_vnode_t     *dvp,
+       bhv_vnode_t     *vp,
+       struct dentry   *dentry,
        int             mode)
 {
        struct dentry   teardown = {};
-       int             err2;
 
        /* Oh, the horror.
-        * If we can't add the ACL or we fail in 
-        * linvfs_init_security we must back out.
+        * If we can't add the ACL or we fail in
+        * 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))
-               VOP_RMDIR(dvp, &teardown, NULL, err2);
+               bhv_vop_rmdir(dvp, &teardown, NULL);
        else
-               VOP_REMOVE(dvp, &teardown, NULL, err2);
+               bhv_vop_remove(dvp, &teardown, NULL);
        VN_RELE(vp);
 }
 
 STATIC int
-linvfs_mknod(
+xfs_vn_mknod(
        struct inode    *dir,
        struct dentry   *dentry,
        int             mode,
        dev_t           rdev)
 {
        struct inode    *ip;
-       vattr_t         va;
-       vnode_t         *vp = NULL, *dvp = LINVFS_GET_VP(dir);
+       bhv_vattr_t     vattr = { 0 };
+       bhv_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;
@@ -306,242 +299,241 @@ linvfs_mknod(
         * Irix uses Missed'em'V split, but doesn't want to see
         * the upper 5 bits of (14bit) major.
         */
-       if (!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff)
+       if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff))
                return -EINVAL;
 
-       if (test_default_acl && test_default_acl(dvp)) {
-               if (!_ACL_ALLOC(default_acl))
+       if (unlikely(test_default_acl && test_default_acl(dvp))) {
+               if (!_ACL_ALLOC(default_acl)) {
                        return -ENOMEM;
+               }
                if (!_ACL_GET_DEFAULT(dvp, default_acl)) {
                        _ACL_FREE(default_acl);
                        default_acl = NULL;
                }
        }
 
-       if (IS_POSIXACL(dir) && !default_acl && has_fs_struct(current))
+       if (IS_POSIXACL(dir) && !default_acl && xfs_has_fs_struct(current))
                mode &= ~current->fs->umask;
 
-       memset(&va, 0, sizeof(va));
-       va.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
-       va.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:
-               va.va_rdev = sysv_encode_dev(rdev);
-               va.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, &va, &vp, NULL, error);
+               error = bhv_vop_create(dvp, dentry, &vattr, &vp, NULL);
                break;
        case S_IFDIR:
-               VOP_MKDIR(dvp, dentry, &va, &vp, NULL, error);
+               error = bhv_vop_mkdir(dvp, dentry, &vattr, &vp, NULL);
                break;
        default:
                error = EINVAL;
                break;
        }
 
-       if (!error)
-       {
-               error = linvfs_init_security(vp, dir);
+       if (unlikely(!error)) {
+               error = xfs_init_security(vp, dir);
                if (error)
-                       cleanup_inode(dvp, vp, dentry, mode);
+                       xfs_cleanup_inode(dvp, vp, dentry, mode);
        }
 
-       if (default_acl) {
+       if (unlikely(default_acl)) {
                if (!error) {
-                       error = _ACL_INHERIT(vp, &va, default_acl);
-                       if (!error) 
+                       error = _ACL_INHERIT(vp, &vattr, default_acl);
+                       if (!error)
                                VMODIFY(vp);
                        else
-                               cleanup_inode(dvp, vp, dentry, mode);
+                               xfs_cleanup_inode(dvp, vp, dentry, mode);
                }
                _ACL_FREE(default_acl);
        }
 
-       if (!error) {
+       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))
-                       validate_fields(ip);
+                       xfs_validate_fields(ip, &vattr);
                d_instantiate(dentry, ip);
-               validate_fields(dir);
+               xfs_validate_fields(dir, &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;
+       bhv_vnode_t     *vp = vn_from_inode(dir), *cvp;
        int             error;
 
        if (dentry->d_name.len >= MAXNAMELEN)
                return ERR_PTR(-ENAMETOOLONG);
 
-       VOP_LOOKUP(vp, dentry, &cvp, 0, NULL, NULL, error);
-       if (error) {
+       error = bhv_vop_lookup(vp, dentry, &cvp, 0, NULL, NULL);
+       if (unlikely(error)) {
                if (unlikely(error != ENOENT))
                        return ERR_PTR(-error);
                d_add(dentry, NULL);
                return NULL;
        }
-       vx_propagate_xid(nd, LINVFS_GET_IP(cvp));
+       dx_propagate_tag(nd, vn_to_inode(cvp));
 
-       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)
 {
        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 */
+       bhv_vnode_t     *tdvp;  /* target directory for new name/link */
+       bhv_vnode_t     *vp;    /* vp of name being linked */
+       bhv_vattr_t     vattr;
        int             error;
 
        ip = old_dentry->d_inode;       /* inode being linked to */
-       if (S_ISDIR(ip->i_mode))
-               return -EPERM;
-
-       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 (!error) {
+       VN_HOLD(vp);
+       error = bhv_vop_link(tdvp, vp, dentry, NULL);
+       if (unlikely(error)) {
+               VN_RELE(vp);
+       } else {
                VMODIFY(tdvp);
-               VN_HOLD(vp);
-               validate_fields(ip);
+               xfs_validate_fields(ip, &vattr);
                d_instantiate(dentry, ip);
        }
        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 */
+       bhv_vnode_t     *dvp;   /* directory containing name to remove */
+       bhv_vattr_t     vattr;
        int             error;
 
        inode = dentry->d_inode;
-       dvp = LINVFS_GET_VP(dir);
+       dvp = vn_from_inode(dir);
 
-       VOP_REMOVE(dvp, dentry, NULL, error);
-       if (!error) {
-               validate_fields(dir);   /* For size only */
-               validate_fields(inode);
+       error = bhv_vop_remove(dvp, dentry, NULL);
+       if (likely(!error)) {
+               xfs_validate_fields(dir, &vattr);       /* size needs update */
+               xfs_validate_fields(inode, &vattr);
        }
-
        return -error;
 }
 
 STATIC int
-linvfs_symlink(
+xfs_vn_symlink(
        struct inode    *dir,
        struct dentry   *dentry,
        const char      *symname)
 {
        struct inode    *ip;
-       vattr_t         va;
-       vnode_t         *dvp;   /* directory containing name of symlink */
-       vnode_t         *cvp;   /* used to lookup symlink to put in dentry */
+       bhv_vattr_t     va = { 0 };
+       bhv_vnode_t     *dvp;   /* directory containing name of symlink */
+       bhv_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;
 
-       memset(&va, 0, sizeof(va));
        va.va_mode = S_IFLNK |
                (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO);
        va.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
 
-       error = 0;
-       VOP_SYMLINK(dvp, dentry, &va, (char *)symname, &cvp, NULL, error);
+       error = bhv_vop_symlink(dvp, dentry, &va, (char *)symname, &cvp, NULL);
        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);
-                       validate_fields(dir);
-                       validate_fields(ip);
+                       xfs_validate_fields(dir, &va);
+                       xfs_validate_fields(ip, &va);
+               } else {
+                       xfs_cleanup_inode(dvp, cvp, dentry, 0);
                }
        }
        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);
+       bhv_vnode_t     *dvp = vn_from_inode(dir);
+       bhv_vattr_t     vattr;
        int             error;
 
-       VOP_RMDIR(dvp, dentry, NULL, error);
-       if (!error) {
-               validate_fields(inode);
-               validate_fields(dir);
+       error = bhv_vop_rmdir(dvp, dentry, NULL);
+       if (likely(!error)) {
+               xfs_validate_fields(inode, &vattr);
+               xfs_validate_fields(dir, &vattr);
        }
        return -error;
 }
 
 STATIC int
-linvfs_rename(
+xfs_vn_rename(
        struct inode    *odir,
        struct dentry   *odentry,
        struct inode    *ndir,
        struct dentry   *ndentry)
 {
        struct inode    *new_inode = ndentry->d_inode;
-       vnode_t         *fvp;   /* from directory */
-       vnode_t         *tvp;   /* target directory */
+       bhv_vnode_t     *fvp;   /* from directory */
+       bhv_vnode_t     *tvp;   /* target directory */
+       bhv_vattr_t     vattr;
        int             error;
 
-       fvp = LINVFS_GET_VP(odir);
-       tvp = LINVFS_GET_VP(ndir);
-
-       VOP_RENAME(fvp, odentry, tvp, ndentry, NULL, error);
-       if (error)
-               return -error;
+       fvp = vn_from_inode(odir);
+       tvp = vn_from_inode(ndir);
 
-       if (new_inode)
-               validate_fields(new_inode);
-
-       validate_fields(odir);
-       if (ndir != odir)
-               validate_fields(ndir);
-       return 0;
+       error = bhv_vop_rename(fvp, odentry, tvp, ndentry, NULL);
+       if (likely(!error)) {
+               if (new_inode)
+                       xfs_validate_fields(new_inode, &vattr);
+               xfs_validate_fields(odir, &vattr);
+               if (ndir != odir)
+                       xfs_validate_fields(ndir, &vattr);
+       }
+       return -error;
 }
 
 /*
@@ -550,11 +542,11 @@ linvfs_rename(
  * uio is kmalloced for this reason...
  */
 STATIC void *
-linvfs_follow_link(
+xfs_vn_follow_link(
        struct dentry           *dentry,
        struct nameidata        *nd)
 {
-       vnode_t                 *vp;
+       bhv_vnode_t             *vp;
        uio_t                   *uio;
        iovec_t                 iov;
        int                     error;
@@ -563,20 +555,20 @@ linvfs_follow_link(
        ASSERT(dentry);
        ASSERT(nd);
 
-       link = (char *)kmalloc(MAXPATHLEN+1, GFP_KERNEL);
+       link = kmalloc(MAXPATHLEN+1, GFP_KERNEL);
        if (!link) {
                nd_set_link(nd, ERR_PTR(-ENOMEM));
                return NULL;
        }
 
-       uio = (uio_t *)kmalloc(sizeof(uio_t), GFP_KERNEL);
+       uio = kmalloc(sizeof(uio_t), GFP_KERNEL);
        if (!uio) {
                kfree(link);
                nd_set_link(nd, ERR_PTR(-ENOMEM));
                return NULL;
        }
 
-       vp = LINVFS_GET_VP(dentry->d_inode);
+       vp = vn_from_inode(dentry->d_inode);
 
        iov.iov_base = link;
        iov.iov_len = MAXPATHLEN;
@@ -587,8 +579,8 @@ linvfs_follow_link(
        uio->uio_resid = MAXPATHLEN;
        uio->uio_iovcnt = 1;
 
-       VOP_READLINK(vp, uio, 0, NULL, error);
-       if (error) {
+       error = bhv_vop_readlink(vp, uio, 0, NULL);
+       if (unlikely(error)) {
                kfree(link);
                link = ERR_PTR(-error);
        } else {
@@ -601,7 +593,7 @@ linvfs_follow_link(
 }
 
 STATIC void
-linvfs_put_link(
+xfs_vn_put_link(
        struct dentry   *dentry,
        struct nameidata *nd,
        void            *p)
@@ -614,83 +606,58 @@ 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);
-       int             error;
-
-       mode <<= 6;             /* convert from linux to vnode access bits */
-       VOP_ACCESS(vp, mode, NULL, error);
-       return -error;
+       return -bhv_vop_access(vn_from_inode(inode), mode << 6, NULL);
 }
 #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);
-       int             error = 0;
-
-       if (unlikely(vp->v_flag & VMODIFIED))
-               error = vn_revalidate(vp);
-       if (!error)
-               generic_fillattr(inode, stat);
-       return 0;
-}
-
-STATIC int
-linvfs_sync_flags(struct inode *inode)
-{
-       unsigned int oldflags, newflags;
-       vattr_t         vattr;
-       int             flags = 0;
+       bhv_vnode_t     *vp = vn_from_inode(inode);
+       bhv_vattr_t     vattr = { .va_mask = XFS_AT_STAT };
        int             error;
-       vnode_t         *vp = LINVFS_GET_VP(inode);
-
-       memset(&vattr, 0, sizeof(vattr_t));
 
-       vattr.va_mask = XFS_AT_XFLAGS;
-       VOP_GETATTR(vp, &vattr, 0, NULL, error);
-       if (error)
-               return error;
-       oldflags = vattr.va_xflags;
-       newflags = oldflags & ~(XFS_XFLAG_IMMUTABLE |
-               XFS_XFLAG_IUNLINK | XFS_XFLAG_BARRIER);
-
-       if (IS_IMMUTABLE(inode))
-               newflags |= XFS_XFLAG_IMMUTABLE;
-       if (IS_IUNLINK(inode))
-               newflags |= XFS_XFLAG_IUNLINK;
-       if (IS_BARRIER(inode))
-               newflags |= XFS_XFLAG_BARRIER;
-
-       if (oldflags ^ newflags) {
-               vattr.va_xflags = newflags;
-               vattr.va_mask |= XFS_AT_XFLAGS;
-               VOP_SETATTR(vp, &vattr, flags, NULL, error);
+       error = bhv_vop_getattr(vp, &vattr, ATTR_LAZY, NULL);
+       if (likely(!error)) {
+               stat->size = i_size_read(inode);
+               stat->dev = inode->i_sb->s_dev;
+               stat->rdev = (vattr.va_rdev == 0) ? 0 :
+                               MKDEV(sysv_major(vattr.va_rdev) & 0x1ff,
+                                     sysv_minor(vattr.va_rdev));
+               stat->mode = vattr.va_mode;
+               stat->nlink = vattr.va_nlink;
+               stat->uid = vattr.va_uid;
+               stat->gid = vattr.va_gid;
+               stat->ino = vattr.va_nodeid;
+               stat->atime = vattr.va_atime;
+               stat->mtime = vattr.va_mtime;
+               stat->ctime = vattr.va_ctime;
+               stat->blocks = vattr.va_nblocks;
+               stat->blksize = vattr.va_blocksize;
        }
-       vn_revalidate(vp);
-       return error;
+       return -error;
 }
 
 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);
-       vattr_t         vattr;
+       bhv_vnode_t     *vp = vn_from_inode(inode);
+       bhv_vattr_t     vattr = { 0 };
        int             flags = 0;
        int             error;
 
@@ -698,7 +665,6 @@ linvfs_setattr(
        if (error)
                return error;
 
-       memset(&vattr, 0, sizeof(vattr_t));
        if (ia_valid & ATTR_UID) {
                vattr.va_mask |= XFS_AT_UID;
                vattr.va_uid = attr->ia_uid;
@@ -707,9 +673,9 @@ linvfs_setattr(
                vattr.va_mask |= XFS_AT_GID;
                vattr.va_gid = attr->ia_gid;
        }
-       if ((ia_valid & ATTR_XID) && IS_TAGXID(inode)) {
-               vattr.va_mask |= XFS_AT_XID;
-               vattr.va_xid = attr->ia_xid;
+       if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode)) {
+               vattr.va_mask |= XFS_AT_TAG;
+               vattr.va_tag = attr->ia_tag;
        }
        if (ia_valid & ATTR_SIZE) {
                vattr.va_mask |= XFS_AT_SIZE;
@@ -742,29 +708,64 @@ linvfs_setattr(
                flags |= ATTR_NONBLOCK;
 #endif
 
-       VOP_SETATTR(vp, &vattr, flags, NULL, error);
-       if (error)
-               return -error;
-       vn_revalidate(vp);
-       return error;
+       error = bhv_vop_setattr(vp, &vattr, flags, NULL);
+       if (likely(!error))
+               __vn_revalidate(vp, &vattr);
+       return -error;
 }
 
 STATIC void
-linvfs_truncate(
+xfs_vn_truncate(
        struct inode    *inode)
 {
-       block_truncate_page(inode->i_mapping, inode->i_size, linvfs_get_block);
+       block_truncate_page(inode->i_mapping, inode->i_size, xfs_get_blocks);
+}
+
+STATIC int
+xfs_vn_sync_flags(struct inode *inode)
+{
+       unsigned int oldflags, newflags;
+       int             flags = 0;
+       int             error;
+       bhv_vattr_t     vattr;
+       bhv_vnode_t     *vp = vn_from_inode(inode);
+
+       memset(&vattr, 0, sizeof vattr);
+
+       vattr.va_mask = XFS_AT_XFLAGS;
+       error = bhv_vop_getattr(vp, &vattr, 0, NULL);
+
+       if (error)
+               return error;
+       oldflags = vattr.va_xflags;
+       newflags = oldflags & ~(XFS_XFLAG_IMMUTABLE |
+               XFS_XFLAG_IUNLINK | XFS_XFLAG_BARRIER);
+
+       if (IS_IMMUTABLE(inode))
+               newflags |= XFS_XFLAG_IMMUTABLE;
+       if (IS_IUNLINK(inode))
+               newflags |= XFS_XFLAG_IUNLINK;
+       if (IS_BARRIER(inode))
+               newflags |= XFS_XFLAG_BARRIER;
+
+       if (oldflags ^ newflags) {
+               vattr.va_xflags = newflags;
+               vattr.va_mask |= XFS_AT_XFLAGS;
+               error = bhv_vop_setattr(vp, &vattr, flags, NULL);
+       }
+       vn_revalidate(vp);
+       return error;
 }
 
 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);
+       bhv_vnode_t     *vp = vn_from_inode(dentry->d_inode);
        char            *attr = (char *)name;
        attrnames_t     *namesp;
        int             xflags = 0;
@@ -788,13 +789,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);
+       bhv_vnode_t     *vp = vn_from_inode(dentry->d_inode);
        char            *attr = (char *)name;
        attrnames_t     *namesp;
        int             xflags = 0;
@@ -818,12 +819,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);
+       bhv_vnode_t             *vp = vn_from_inode(dentry->d_inode);
        int                     error, xflags = ATTR_KERNAMELS;
        ssize_t                 result;
 
@@ -838,11 +839,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);
+       bhv_vnode_t     *vp = vn_from_inode(dentry->d_inode);
        char            *attr = (char *)name;
        attrnames_t     *namesp;
        int             xflags = 0;
@@ -860,48 +861,48 @@ 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,
-       .sync_flags             = linvfs_sync_flags,
+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,
+       .sync_flags             = xfs_vn_sync_flags,
 };
 
-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,
-       .sync_flags             = linvfs_sync_flags,
+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,
+       .sync_flags             = xfs_vn_sync_flags,
 };
 
-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,
-       .sync_flags             = linvfs_sync_flags,
+       .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,
+       .sync_flags             = xfs_vn_sync_flags,
 };