]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/xfs/linux-2.6/xfs_export.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
[linux-2.6-omap-h63xx.git] / fs / xfs / linux-2.6 / xfs_export.c
index ca4f66c4de16aaa743f5dcb7cc0e44ae02715ef1..7f7abec25e141302458af4e72a0bf3ecce87fbab 100644 (file)
@@ -22,6 +22,7 @@
 #include "xfs_trans.h"
 #include "xfs_sb.h"
 #include "xfs_ag.h"
+#include "xfs_dir2.h"
 #include "xfs_dmapi.h"
 #include "xfs_mount.h"
 #include "xfs_export.h"
@@ -30,8 +31,6 @@
 #include "xfs_inode.h"
 #include "xfs_vfsops.h"
 
-static struct dentry dotdot = { .d_name.name = "..", .d_name.len = 2, };
-
 /*
  * Note that we only accept fileids which are long enough rather than allow
  * the parent generation number to default to zero.  XFS considers zero a
@@ -66,7 +65,7 @@ xfs_fs_encode_fh(
        int                     len;
 
        /* Directories don't need their parent encoded, they have ".." */
-       if (S_ISDIR(inode->i_mode))
+       if (S_ISDIR(inode->i_mode) || !connectable)
                fileid_type = FILEID_INO32_GEN;
        else
                fileid_type = FILEID_INO32_GEN_PARENT;
@@ -134,13 +133,13 @@ xfs_nfs_get_inode(
        if (!ip)
                return ERR_PTR(-EIO);
 
-       if (!ip->i_d.di_mode || ip->i_d.di_gen != generation) {
+       if (ip->i_d.di_gen != generation) {
                xfs_iput_new(ip, XFS_ILOCK_SHARED);
                return ERR_PTR(-ENOENT);
        }
 
        xfs_iunlock(ip, XFS_ILOCK_SHARED);
-       return ip->i_vnode;
+       return VFS_I(ip);
 }
 
 STATIC struct dentry *
@@ -149,7 +148,6 @@ xfs_fs_fh_to_dentry(struct super_block *sb, struct fid *fid,
 {
        struct xfs_fid64        *fid64 = (struct xfs_fid64 *)fid;
        struct inode            *inode = NULL;
-       struct dentry           *result;
 
        if (fh_len < xfs_fileid_length(fileid_type))
                return NULL;
@@ -165,16 +163,7 @@ xfs_fs_fh_to_dentry(struct super_block *sb, struct fid *fid,
                break;
        }
 
-       if (!inode)
-               return NULL;
-       if (IS_ERR(inode))
-               return ERR_PTR(PTR_ERR(inode));
-       result = d_alloc_anon(inode);
-       if (!result) {
-               iput(inode);
-               return ERR_PTR(-ENOMEM);
-       }
-       return result;
+       return d_obtain_alias(inode);
 }
 
 STATIC struct dentry *
@@ -183,7 +172,6 @@ xfs_fs_fh_to_parent(struct super_block *sb, struct fid *fid,
 {
        struct xfs_fid64        *fid64 = (struct xfs_fid64 *)fid;
        struct inode            *inode = NULL;
-       struct dentry           *result;
 
        switch (fileid_type) {
        case FILEID_INO32_GEN_PARENT:
@@ -196,16 +184,7 @@ xfs_fs_fh_to_parent(struct super_block *sb, struct fid *fid,
                break;
        }
 
-       if (!inode)
-               return NULL;
-       if (IS_ERR(inode))
-               return ERR_PTR(PTR_ERR(inode));
-       result = d_alloc_anon(inode);
-       if (!result) {
-               iput(inode);
-               return ERR_PTR(-ENOMEM);
-       }
-       return result;
+       return d_obtain_alias(inode);
 }
 
 STATIC struct dentry *
@@ -213,20 +192,13 @@ xfs_fs_get_parent(
        struct dentry           *child)
 {
        int                     error;
-       bhv_vnode_t             *cvp;
-       struct dentry           *parent;
+       struct xfs_inode        *cip;
 
-       cvp = NULL;
-       error = xfs_lookup(XFS_I(child->d_inode), &dotdot, &cvp);
+       error = xfs_lookup(XFS_I(child->d_inode), &xfs_name_dotdot, &cip, NULL);
        if (unlikely(error))
                return ERR_PTR(-error);
 
-       parent = d_alloc_anon(vn_to_inode(cvp));
-       if (unlikely(!parent)) {
-               VN_RELE(cvp);
-               return ERR_PTR(-ENOMEM);
-       }
-       return parent;
+       return d_obtain_alias(VFS_I(cip));
 }
 
 const struct export_operations xfs_export_operations = {