+ return lgd->lgd_found;
+}
+
+static int ll_get_name(struct dentry *dentry, char *name,
+ struct dentry *child)
+{
+ struct inode *dir = dentry->d_inode;
+ struct ll_getname_data lgd;
+ __u64 offset = 0;
+ int rc;
+ ENTRY;
+
+ if (!dir || !S_ISDIR(dir->i_mode))
+ GOTO(out, rc = -ENOTDIR);
+
+ if (!dir->i_fop)
+ GOTO(out, rc = -EINVAL);
+
+ lgd.lgd_name = name;
+ lgd.lgd_fid = ll_i2info(child->d_inode)->lli_fid;
+ lgd.lgd_found = 0;
+
+ cfs_mutex_lock(&dir->i_mutex);
+ rc = ll_dir_read(dir, &offset, &lgd, ll_nfs_get_name_filldir);
+ cfs_mutex_unlock(&dir->i_mutex);
+ if (!rc && !lgd.lgd_found)
+ rc = -ENOENT;
+ EXIT;
+
+out:
+ return rc;
+}
+
+#ifdef HAVE_FH_TO_DENTRY
+static struct dentry *ll_fh_to_dentry(struct super_block *sb, struct fid *fid,
+ int fh_len, int fh_type)
+{
+ struct lustre_nfs_fid *nfs_fid = (struct lustre_nfs_fid *)fid;
+
+ if (fh_type != LUSTRE_NFS_FID)
+ RETURN(ERR_PTR(-EPROTO));
+
+ RETURN(ll_iget_for_nfs(sb, &nfs_fid->lnf_child, &nfs_fid->lnf_parent));
+}
+
+static struct dentry *ll_fh_to_parent(struct super_block *sb, struct fid *fid,
+ int fh_len, int fh_type)
+{
+ struct lustre_nfs_fid *nfs_fid = (struct lustre_nfs_fid *)fid;
+
+ if (fh_type != LUSTRE_NFS_FID)
+ RETURN(ERR_PTR(-EPROTO));
+
+ RETURN(ll_iget_for_nfs(sb, &nfs_fid->lnf_parent, NULL));
+}
+
+#else
+
+/*
+ * This length is counted as amount of __u32,
+ * It is composed of a fid and a mode
+ */
+static struct dentry *ll_decode_fh(struct super_block *sb, __u32 *fh, int fh_len,
+ int fh_type,
+ int (*acceptable)(void *, struct dentry *),
+ void *context)
+{
+ struct lustre_nfs_fid *nfs_fid = (void *)fh;
+ struct dentry *entry;
+ ENTRY;
+
+ CDEBUG(D_INFO, "decoding for "DFID" fh_len=%d fh_type=%x\n",
+ PFID(&nfs_fid->lnf_child), fh_len, fh_type);
+
+ if (fh_type != LUSTRE_NFS_FID)
+ RETURN(ERR_PTR(-EPROTO));
+
+ entry = sb->s_export_op->find_exported_dentry(sb, &nfs_fid->lnf_child,
+ &nfs_fid->lnf_parent,
+ acceptable, context);
+ RETURN(entry);
+}
+
+static struct dentry *ll_get_dentry(struct super_block *sb, void *data)
+{
+ struct dentry *entry;
+ ENTRY;
+
+ entry = ll_iget_for_nfs(sb, data, NULL);
+ RETURN(entry);
+}
+#endif
+static struct dentry *ll_get_parent(struct dentry *dchild)
+{
+ struct ptlrpc_request *req = NULL;
+ struct inode *dir = dchild->d_inode;
+ struct ll_sb_info *sbi;
+ struct dentry *result = NULL;
+ struct mdt_body *body;
+ static char dotdot[] = "..";
+ struct md_op_data *op_data;
+ int rc;
+ ENTRY;
+
+ LASSERT(dir && S_ISDIR(dir->i_mode));
+
+ sbi = ll_s2sbi(dir->i_sb);
+
+ CDEBUG(D_INFO, "getting parent for (%lu,"DFID")\n",
+ dir->i_ino, PFID(ll_inode2fid(dir)));
+
+ op_data = ll_prep_md_op_data(NULL, dir, NULL, dotdot,
+ strlen(dotdot), 0,
+ LUSTRE_OPC_ANY, NULL);
+ if (IS_ERR(op_data))
+ RETURN((void *)op_data);
+
+ rc = md_getattr_name(sbi->ll_md_exp, op_data, &req);
+ ll_finish_md_op_data(op_data);
+ if (rc) {
+ CERROR("failure %d inode %lu get parent\n", rc, dir->i_ino);
+ RETURN(ERR_PTR(rc));