diff options
author | Venky Shankar <vshankar@redhat.com> | 2014-01-23 12:40:09 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2014-01-27 07:51:53 -0800 |
commit | 0c80a202d475a4abb8a5738f144739234d7557c6 (patch) | |
tree | 1ec58ccd214baf29340eb54d779ba813daec2680 /libglusterfs | |
parent | 4e8b968de0a102b538c3436f216913686f0e07ea (diff) |
features/gfid-access: fix lookup on .gfid/<parent>/bname
In gfid translator, lookup was not handling the case when
the lookup is sent on .gfid/<parent>/bname. In this case,
we flip with fake inode of the parent with the real inode
in loc and send it downwards.
Change-Id: I639ff1dce10ffc045da419e333d455e208b6a0f0
BUG: 1057881
Signed-off-by: Venky Shankar <vshankar@redhat.com>
Reviewed-on: http://review.gluster.org/6795
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Reviewed-on: http://review.gluster.org/6807
Diffstat (limited to 'libglusterfs')
-rw-r--r-- | libglusterfs/src/xlator.c | 39 | ||||
-rw-r--r-- | libglusterfs/src/xlator.h | 2 |
2 files changed, 41 insertions, 0 deletions
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index 7c8c3cdba36..9ce52407f9e 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -650,6 +650,45 @@ loc_gfid_utoa (loc_t *loc) } int +loc_copy_overload_parent (loc_t *dst, loc_t *src, inode_t *parent) +{ + int ret = -1; + + GF_VALIDATE_OR_GOTO ("xlator", dst, err); + GF_VALIDATE_OR_GOTO ("xlator", src, err); + GF_VALIDATE_OR_GOTO ("xlator", parent, err); + + uuid_copy (dst->gfid, src->gfid); + uuid_copy (dst->pargfid, parent->gfid); + + if (src->inode) + dst->inode = inode_ref (src->inode); + + if (parent) + dst->parent = inode_ref (parent); + + if (src->path) { + dst->path = gf_strdup (src->path); + + if (!dst->path) + goto out; + + if (src->name) + dst->name = strrchr (dst->path, '/'); + if (dst->name) + dst->name++; + } + + ret = 0; +out: + if (ret == -1) + loc_wipe (dst); + +err: + return ret; +} + +int loc_copy (loc_t *dst, loc_t *src) { int ret = -1; diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h index 2f3bc9d6fb2..1daa06ec2ed 100644 --- a/libglusterfs/src/xlator.h +++ b/libglusterfs/src/xlator.h @@ -937,6 +937,8 @@ xlator_t *xlator_search_by_name (xlator_t *any, const char *name); void inode_destroy_notify (inode_t *inode, const char *xlname); int loc_copy (loc_t *dst, loc_t *src); +int loc_copy_overload_parent (loc_t *dst, + loc_t *src, inode_t *parent); #define loc_dup(src, dst) loc_copy(dst, src) void loc_wipe (loc_t *loc); int loc_path (loc_t *loc, const char *bname); |