Use common loc-touchup in fuse/server/gfapi

Change-Id: Id41fb29480bb6d22c34469339163da05b98c1a98
BUG: 1115907
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/8226
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
This commit is contained in:
Pranith Kumar K 2014-06-13 11:45:53 +05:30 committed by Vijay Bellur
parent adef0c8860
commit a25cdf135f
5 changed files with 45 additions and 52 deletions

View File

@ -139,30 +139,15 @@ __glfs_refresh_inode (struct glfs *fs, xlator_t *subvol, inode_t *inode)
int
priv_glfs_loc_touchup (loc_t *loc)
{
char *path = NULL;
int ret = -1;
char *bn = NULL;
int ret = 0;
if (loc->parent)
ret = inode_path (loc->parent, loc->name, &path);
else
ret = inode_path (loc->inode, 0, &path);
ret = loc_touchup (loc, loc->name);
if (ret < 0) {
errno = -ret;
ret = -1;
}
loc->path = path;
if (ret < 0 || !path) {
ret = -1;
errno = ENOMEM;
goto out;
}
bn = strrchr (path, '/');
if (bn)
bn++;
loc->name = bn;
ret = 0;
out:
return ret;
return ret;
}
GFAPI_SYMVER_PRIVATE_DEFAULT(glfs_loc_touchup, 3.4.0);

View File

@ -734,6 +734,39 @@ loc_gfid_utoa (loc_t *loc)
return uuid_utoa (gfid);
}
int
loc_touchup (loc_t *loc, const char *name)
{
char *path = NULL;
int ret = 0;
if (loc->path)
goto out;
if (loc->parent && name && strlen (name)) {
ret = inode_path (loc->parent, name, &path);
if (path) /*Guaranteed to have trailing '/' */
loc->name = strrchr (path, '/') + 1;
if (uuid_is_null (loc->pargfid))
uuid_copy (loc->pargfid, loc->parent->gfid);
} else if (loc->inode) {
ret = inode_path (loc->inode, 0, &path);
if (uuid_is_null (loc->gfid))
uuid_copy (loc->gfid, loc->inode->gfid);
}
if (ret < 0 || !path) {
ret = -ENOMEM;
goto out;
}
loc->path = path;
ret = 0;
out:
return ret;
}
int
loc_copy_overload_parent (loc_t *dst, loc_t *src, inode_t *parent)
{

View File

@ -964,4 +964,7 @@ is_graph_topology_equal (glusterfs_graph_t *graph1, glusterfs_graph_t *graph2);
int
glusterfs_volfile_reconfigure (int oldvollen, FILE *newvolfile_fp,
glusterfs_ctx_t *ctx, const char *oldvolfile);
int
loc_touchup (loc_t *loc, const char *name);
#endif /* _XLATOR_H */

View File

@ -33,27 +33,11 @@ fuse_resolve_loc_touchup (fuse_state_t *state)
{
fuse_resolve_t *resolve = NULL;
loc_t *loc = NULL;
char *path = NULL;
int ret = 0;
resolve = state->resolve_now;
loc = state->loc_now;
if (!loc->path) {
if (loc->parent && resolve->bname) {
ret = inode_path (loc->parent, resolve->bname, &path);
uuid_copy (loc->pargfid, loc->parent->gfid);
loc->name = resolve->bname;
} else if (loc->inode) {
ret = inode_path (loc->inode, NULL, &path);
uuid_copy (loc->gfid, loc->inode->gfid);
}
if (ret)
gf_log (THIS->name, GF_LOG_TRACE,
"return value inode_path %d", ret);
loc->path = path;
}
loc_touchup (loc, resolve->bname);
return 0;
}

View File

@ -42,19 +42,7 @@ resolve_loc_touchup (call_frame_t *frame)
resolve = state->resolve_now;
loc = state->loc_now;
if (!loc->path) {
if (loc->parent && resolve->bname) {
ret = inode_path (loc->parent, resolve->bname, &path);
loc->name = resolve->bname;
} else if (loc->inode) {
ret = inode_path (loc->inode, NULL, &path);
}
if (ret)
gf_log (frame->this->name, GF_LOG_TRACE,
"return value inode_path %d", ret);
loc->path = path;
}
loc_touchup (loc, resolve->bname);
return 0;
}