diff options
author | Pranith Kumar K <pranithk@gluster.com> | 2012-04-27 18:43:23 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-05-08 13:39:01 -0700 |
commit | 11a19ce031932640584f8bc207274f4e08d97c5f (patch) | |
tree | ee5a986280dfaac50c5868e38d28fdde13123a9a /libglusterfs | |
parent | f233e26f99decc0b2552ed10cd81c30c684139ac (diff) |
Resolve: Assign correct path while resolving
Change-Id: Ia17ff38a60225dd2e9115aaa298bed42f9e43f56
BUG: 812277
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/3248
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r-- | libglusterfs/src/inode.c | 7 | ||||
-rw-r--r-- | libglusterfs/src/inode.h | 1 | ||||
-rw-r--r-- | libglusterfs/src/xlator.c | 36 | ||||
-rw-r--r-- | libglusterfs/src/xlator.h | 1 |
4 files changed, 42 insertions, 3 deletions
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c index 1db8297923a..c1a7efc0942 100644 --- a/libglusterfs/src/inode.c +++ b/libglusterfs/src/inode.c @@ -1095,8 +1095,9 @@ __inode_path (inode_t *inode, const char *name, char **bufp) int len = 0; char *buf = NULL; - if (!inode) { - gf_log_callingfn (THIS->name, GF_LOG_WARNING, "inode not found"); + if (!inode || uuid_is_null (inode->gfid)) { + GF_ASSERT (0); + gf_log_callingfn (THIS->name, GF_LOG_WARNING, "invalid inode"); return -1; } @@ -1153,7 +1154,7 @@ __inode_path (inode_t *inode, const char *name, char **bufp) if (!__is_root_gfid (itrav->gfid)) { snprintf (&buf[i-GFID_STR_PFX_LEN], GFID_STR_PFX_LEN, - "<gfid:%s>", uuid_utoa (itrav->gfid)); + INODE_PATH_FMT, uuid_utoa (itrav->gfid)); buf[i-1] = '>'; } diff --git a/libglusterfs/src/inode.h b/libglusterfs/src/inode.h index f6401c5b9b1..7a296e0d23d 100644 --- a/libglusterfs/src/inode.h +++ b/libglusterfs/src/inode.h @@ -29,6 +29,7 @@ #include <sys/types.h> #define DEFAULT_INODE_MEMPOOL_ENTRIES 32 * 1024 +#define INODE_PATH_FMT "<gfid:%s>" struct _inode_table; typedef struct _inode_table inode_table_t; diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index 1641a1909f6..16a931716f5 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -552,6 +552,42 @@ loc_wipe (loc_t *loc) memset (loc, 0, sizeof (*loc)); } +int +loc_path (loc_t *loc, const char *bname) +{ + int ret = 0; + + if (loc->path) + goto out; + + ret = -1; + + if (bname && !strlen (bname)) + bname = NULL; + + if (!bname) + goto inode_path; + + if (loc->parent && !uuid_is_null (loc->parent->gfid)) { + ret = inode_path (loc->parent, bname, (char**)&loc->path); + } else if (!uuid_is_null (loc->pargfid)) { + ret = gf_asprintf ((char**)&loc->path, INODE_PATH_FMT"/%s", + uuid_utoa (loc->pargfid), bname); + } + + if (loc->path) + goto out; + +inode_path: + if (loc->inode && !uuid_is_null (loc->inode->gfid)) { + ret = inode_path (loc->inode, NULL, (char **)&loc->path); + } else if (!uuid_is_null (loc->gfid)) { + ret = gf_asprintf ((char**)&loc->path, INODE_PATH_FMT, + uuid_utoa (loc->gfid)); + } +out: + return ret; +} int loc_copy (loc_t *dst, loc_t *src) diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h index 2663b041a38..4c55e979f2f 100644 --- a/libglusterfs/src/xlator.h +++ b/libglusterfs/src/xlator.h @@ -876,6 +876,7 @@ void inode_destroy_notify (inode_t *inode, const char *xlname); int loc_copy (loc_t *dst, loc_t *src); #define loc_dup(src, dst) loc_copy(dst, src) void loc_wipe (loc_t *loc); +int loc_path (loc_t *loc, const char *bname); int xlator_mem_acct_init (xlator_t *xl, int num_types); int is_gf_log_command (xlator_t *trans, const char *name, char *value); int glusterd_check_log_level (const char *value); |