+ struct ll_getname_data *lgd = cookie;
+#else
+ll_nfs_get_name_filldir(struct dir_context *ctx, const char *name, int namelen,
+ loff_t hash, u64 ino, unsigned type)
+{
+ struct ll_getname_data *lgd =
+ container_of(ctx, struct ll_getname_data, ctx);
+#endif /* HAVE_FILLDIR_USE_CTX */
+ /* It is hack to access lde_fid for comparison with lgd_fid.
+ * So the input 'name' must be part of the 'lu_dirent'. */
+ struct lu_dirent *lde = container_of0(name, struct lu_dirent, lde_name);
+ struct lu_fid fid;
+
+ fid_le_to_cpu(&fid, &lde->lde_fid);
+ if (lu_fid_eq(&fid, &lgd->lgd_fid)) {
+ memcpy(lgd->lgd_name, name, namelen);
+ lgd->lgd_name[namelen] = 0;
+ lgd->lgd_found = 1;
+ }
+ 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 = {
+ .lgd_name = name,
+ .lgd_fid = ll_i2info(child->d_inode)->lli_fid,
+#ifdef HAVE_DIR_CONTEXT
+ .ctx.actor = ll_nfs_get_name_filldir,
+#endif
+ .lgd_found = 0,
+ };
+ struct md_op_data *op_data;
+ __u64 pos = 0;
+ int rc;
+ ENTRY;
+
+ if (!dir || !S_ISDIR(dir->i_mode))
+ GOTO(out, rc = -ENOTDIR);
+
+ if (!dir->i_fop)
+ GOTO(out, rc = -EINVAL);
+
+ op_data = ll_prep_md_op_data(NULL, dir, dir, NULL, 0, 0,
+ LUSTRE_OPC_ANY, dir);
+ if (IS_ERR(op_data))
+ GOTO(out, rc = PTR_ERR(op_data));
+
+ op_data->op_max_pages = ll_i2sbi(dir)->ll_md_brw_pages;
+ mutex_lock(&dir->i_mutex);
+#ifdef HAVE_DIR_CONTEXT
+ rc = ll_dir_read(dir, &pos, op_data, &lgd.ctx);
+#else
+ rc = ll_dir_read(dir, &pos, op_data, &lgd, ll_nfs_get_name_filldir);
+#endif
+ mutex_unlock(&dir->i_mutex);
+ ll_finish_md_op_data(op_data);
+ if (!rc && !lgd.lgd_found)
+ rc = -ENOENT;
+ EXIT;
+out:
+ return rc;
+}