diff options
-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 | ||||
-rw-r--r-- | xlators/mount/fuse/src/fuse-resolve.c | 5 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-resolve.c | 15 |
6 files changed, 49 insertions, 16 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); diff --git a/xlators/mount/fuse/src/fuse-resolve.c b/xlators/mount/fuse/src/fuse-resolve.c index abb11dbb1d9..b1eff83dcda 100644 --- a/xlators/mount/fuse/src/fuse-resolve.c +++ b/xlators/mount/fuse/src/fuse-resolve.c @@ -197,12 +197,11 @@ fuse_resolve_gfid (fuse_state_t *state) } resolve_loc->inode = inode_new (state->itable); - ret = inode_path (resolve_loc->inode, NULL, - (char **)&resolve_loc->path); + ret = loc_path (resolve_loc, NULL); if (ret <= 0) { gf_log (THIS->name, GF_LOG_WARNING, - "failed to get the path from inode %s", + "failed to get the path for inode %s", uuid_utoa (resolve->gfid)); } diff --git a/xlators/protocol/server/src/server-resolve.c b/xlators/protocol/server/src/server-resolve.c index 4992fb53095..e44fc2de328 100644 --- a/xlators/protocol/server/src/server-resolve.c +++ b/xlators/protocol/server/src/server-resolve.c @@ -179,17 +179,13 @@ resolve_gfid (call_frame_t *frame) resolve = state->resolve_now; resolve_loc = &resolve->resolve_loc; - if (!uuid_is_null (resolve->pargfid)) { + if (!uuid_is_null (resolve->pargfid)) uuid_copy (resolve_loc->gfid, resolve->pargfid); - resolve_loc->inode = inode_new (state->itable); - ret = inode_path (resolve_loc->inode, NULL, - (char **)&resolve_loc->path); - } else if (!uuid_is_null (resolve->gfid)) { + else if (!uuid_is_null (resolve->gfid)) uuid_copy (resolve_loc->gfid, resolve->gfid); - resolve_loc->inode = inode_new (state->itable); - ret = inode_path (resolve_loc->inode, NULL, - (char **)&resolve_loc->path); - } + + resolve_loc->inode = inode_new (state->itable); + ret = loc_path (resolve_loc, NULL); STACK_WIND (frame, resolve_gfid_cbk, BOUND_XL (frame), BOUND_XL (frame)->fops->lookup, @@ -197,7 +193,6 @@ resolve_gfid (call_frame_t *frame) return 0; } - int resolve_continue (call_frame_t *frame) { |