]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/ocfs2/export.c
[PATCH] switch all filesystems over to d_obtain_alias
[linux-2.6-omap-h63xx.git] / fs / ocfs2 / export.c
index bc48177bd183eac14ae94ff2c1f787d6ce013649..2f27b332d8b316949b131eb8172c1e1bdf4d1362 100644 (file)
@@ -45,9 +45,9 @@ struct ocfs2_inode_handle
        u32 ih_generation;
 };
 
-static struct dentry *ocfs2_get_dentry(struct super_block *sb, void *vobjp)
+static struct dentry *ocfs2_get_dentry(struct super_block *sb,
+               struct ocfs2_inode_handle *handle)
 {
-       struct ocfs2_inode_handle *handle = vobjp;
        struct inode *inode;
        struct dentry *result;
 
@@ -58,7 +58,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb, void *vobjp)
                return ERR_PTR(-ESTALE);
        }
 
-       inode = ocfs2_iget(OCFS2_SB(sb), handle->ih_blkno, 0);
+       inode = ocfs2_iget(OCFS2_SB(sb), handle->ih_blkno, 0, 0);
 
        if (IS_ERR(inode))
                return (void *)inode;
@@ -68,14 +68,9 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb, void *vobjp)
                return ERR_PTR(-ESTALE);
        }
 
-       result = d_alloc_anon(inode);
-
-       if (!result) {
-               iput(inode);
-               mlog_errno(-ENOMEM);
-               return ERR_PTR(-ENOMEM);
-       }
-       result->d_op = &ocfs2_dentry_ops;
+       result = d_obtain_alias(inode);
+       if (!IS_ERR(result))
+               result->d_op = &ocfs2_dentry_ops;
 
        mlog_exit_ptr(result);
        return result;
@@ -86,10 +81,7 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)
        int status;
        u64 blkno;
        struct dentry *parent;
-       struct inode *inode;
        struct inode *dir = child->d_inode;
-       struct buffer_head *dirent_bh = NULL;
-       struct ocfs2_dir_entry *dirent;
 
        mlog_entry("(0x%p, '%.*s')\n", child,
                   child->d_name.len, child->d_name.name);
@@ -97,7 +89,7 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)
        mlog(0, "find parent of directory %llu\n",
             (unsigned long long)OCFS2_I(dir)->ip_blkno);
 
-       status = ocfs2_meta_lock(dir, NULL, 0);
+       status = ocfs2_inode_lock(dir, NULL, 0);
        if (status < 0) {
                if (status != -ENOENT)
                        mlog_errno(status);
@@ -105,34 +97,18 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)
                goto bail;
        }
 
-       status = ocfs2_find_files_on_disk("..", 2, &blkno, dir, &dirent_bh,
-                                         &dirent);
+       status = ocfs2_lookup_ino_from_name(dir, "..", 2, &blkno);
        if (status < 0) {
                parent = ERR_PTR(-ENOENT);
                goto bail_unlock;
        }
 
-       inode = ocfs2_iget(OCFS2_SB(dir->i_sb), blkno, 0);
-       if (IS_ERR(inode)) {
-               mlog(ML_ERROR, "Unable to create inode %llu\n",
-                    (unsigned long long)blkno);
-               parent = ERR_PTR(-EACCES);
-               goto bail_unlock;
-       }
-
-       parent = d_alloc_anon(inode);
-       if (!parent) {
-               iput(inode);
-               parent = ERR_PTR(-ENOMEM);
-       }
-
-       parent->d_op = &ocfs2_dentry_ops;
+       parent = d_obtain_alias(ocfs2_iget(OCFS2_SB(dir->i_sb), blkno, 0, 0));
+       if (!IS_ERR(parent))
+               parent->d_op = &ocfs2_dentry_ops;
 
 bail_unlock:
-       ocfs2_meta_unlock(dir, 0);
-
-       if (dirent_bh)
-               brelse(dirent_bh);
+       ocfs2_inode_unlock(dir, 0);
 
 bail:
        mlog_exit_ptr(parent);
@@ -200,54 +176,37 @@ bail:
        return type;
 }
 
-static struct dentry *ocfs2_decode_fh(struct super_block *sb, u32 *fh_in,
-                                     int fh_len, int fileid_type,
-                                     int (*acceptable)(void *context,
-                                                       struct dentry *de),
-                                     void *context)
+static struct dentry *ocfs2_fh_to_dentry(struct super_block *sb,
+               struct fid *fid, int fh_len, int fh_type)
 {
-       struct ocfs2_inode_handle handle, parent;
-       struct dentry *ret = NULL;
-       __le32 *fh = (__force __le32 *) fh_in;
+       struct ocfs2_inode_handle handle;
 
-       mlog_entry("(0x%p, 0x%p, %d, %d, 0x%p, 0x%p)\n",
-                  sb, fh, fh_len, fileid_type, acceptable, context);
+       if (fh_len < 3 || fh_type > 2)
+               return NULL;
 
-       if (fh_len < 3 || fileid_type > 2)
-               goto bail;
-
-       if (fileid_type == 2) {
-               if (fh_len < 6)
-                       goto bail;
-
-               parent.ih_blkno = (u64)le32_to_cpu(fh[3]) << 32;
-               parent.ih_blkno |= (u64)le32_to_cpu(fh[4]);
-               parent.ih_generation = le32_to_cpu(fh[5]);
-
-               mlog(0, "Decoding parent: blkno: %llu, generation: %u\n",
-                    (unsigned long long)parent.ih_blkno,
-                    parent.ih_generation);
-       }
-
-       handle.ih_blkno = (u64)le32_to_cpu(fh[0]) << 32;
-       handle.ih_blkno |= (u64)le32_to_cpu(fh[1]);
-       handle.ih_generation = le32_to_cpu(fh[2]);
+       handle.ih_blkno = (u64)le32_to_cpu(fid->raw[0]) << 32;
+       handle.ih_blkno |= (u64)le32_to_cpu(fid->raw[1]);
+       handle.ih_generation = le32_to_cpu(fid->raw[2]);
+       return ocfs2_get_dentry(sb, &handle);
+}
 
-       mlog(0, "Encoding fh: blkno: %llu, generation: %u\n",
-            (unsigned long long)handle.ih_blkno, handle.ih_generation);
+static struct dentry *ocfs2_fh_to_parent(struct super_block *sb,
+               struct fid *fid, int fh_len, int fh_type)
+{
+       struct ocfs2_inode_handle parent;
 
-       ret = ocfs2_export_ops.find_exported_dentry(sb, &handle, &parent,
-                                                   acceptable, context);
+       if (fh_type != 2 || fh_len < 6)
+               return NULL;
 
-bail:
-       mlog_exit_ptr(ret);
-       return ret;
+       parent.ih_blkno = (u64)le32_to_cpu(fid->raw[3]) << 32;
+       parent.ih_blkno |= (u64)le32_to_cpu(fid->raw[4]);
+       parent.ih_generation = le32_to_cpu(fid->raw[5]);
+       return ocfs2_get_dentry(sb, &parent);
 }
 
-struct export_operations ocfs2_export_ops = {
-       .decode_fh      = ocfs2_decode_fh,
+const struct export_operations ocfs2_export_ops = {
        .encode_fh      = ocfs2_encode_fh,
-
+       .fh_to_dentry   = ocfs2_fh_to_dentry,
+       .fh_to_parent   = ocfs2_fh_to_parent,
        .get_parent     = ocfs2_get_parent,
-       .get_dentry     = ocfs2_get_dentry,
 };