summaryrefslogtreecommitdiffstats
path: root/xlators/features/index
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2016-02-25 18:45:20 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2016-03-04 17:26:52 -0800
commit459d0a5e173f9d9f597aec89f81e5377425eb8fb (patch)
treef005f0d6fa289f29916a90075568722e97124eec /xlators/features/index
parentfe382917793c00f4cbedeef175707d35cb208f5d (diff)
features/index: Get gfid type in readdir
Change-Id: I2a6174e1af70a94a52b0b735fd8504800a7ea173 BUG: 1313135 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/13553 Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Anuradha Talur <atalur@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/features/index')
-rw-r--r--xlators/features/index/src/index.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c
index 6e4071ab539..396e950570b 100644
--- a/xlators/features/index/src/index.c
+++ b/xlators/features/index/src/index.c
@@ -11,10 +11,16 @@
#include "options.h"
#include "glusterfs3-xdr.h"
#include "syscall.h"
+#include "syncop.h"
#define XATTROP_SUBDIR "xattrop"
#define DIRTY_SUBDIR "dirty"
+struct index_syncop_args {
+ inode_t *parent;
+ gf_dirent_t *entries;
+};
+
call_stub_t *
__index_dequeue (struct list_head *callstubs)
{
@@ -1175,6 +1181,38 @@ done:
return 0;
}
+int
+index_get_gfid_type (void *opaque)
+{
+ gf_dirent_t *entry = NULL;
+ inode_t *inode = NULL;
+ xlator_t *this = THIS;
+ struct index_syncop_args *args = opaque;
+ loc_t loc = {0};
+ struct iatt iatt = {0};
+ int ret = 0;
+
+ list_for_each_entry (entry, &args->entries->list, list) {
+ loc_wipe (&loc);
+ gf_uuid_parse (entry->d_name, loc.gfid);
+ entry->d_type = IA_INVAL;
+ loc.inode = inode_find (args->parent->table, loc.gfid);
+ if (loc.inode) {
+ entry->d_type = loc.inode->ia_type;
+ continue;
+ }
+ loc.inode = inode_new (args->parent->table);
+ if (!loc.inode)
+ continue;
+ ret = syncop_lookup (FIRST_CHILD (this), &loc, &iatt, 0, 0, 0);
+ if (ret == 0)
+ entry->d_type = iatt.ia_type;
+ }
+ loc_wipe (&loc);
+
+ return 0;
+}
+
int32_t
index_readdir_wrapper (call_frame_t *frame, xlator_t *this,
fd_t *fd, size_t size, off_t off, dict_t *xdata)
@@ -1186,6 +1224,7 @@ index_readdir_wrapper (call_frame_t *frame, xlator_t *this,
int32_t op_errno = 0;
int count = 0;
gf_dirent_t entries;
+ struct index_syncop_args args = {0};
INIT_LIST_HEAD (&entries.list);
@@ -1211,8 +1250,14 @@ index_readdir_wrapper (call_frame_t *frame, xlator_t *this,
/* pick ENOENT to indicate EOF */
op_errno = errno;
op_ret = count;
+ if (xdata && dict_get (xdata, "get-gfid-type")) {
+ args.parent = fd->inode;
+ args.entries = &entries;
+ ret = synctask_new (this->ctx->env, index_get_gfid_type,
+ NULL, NULL, &args);
+ }
done:
- STACK_UNWIND_STRICT (readdir, frame, op_ret, op_errno, &entries, xdata);
+ STACK_UNWIND_STRICT (readdir, frame, op_ret, op_errno, &entries, NULL);
gf_dirent_free (&entries);
return 0;
}