summaryrefslogtreecommitdiffstats
path: root/xlators/mount/fuse/src/fuse-bridge.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mount/fuse/src/fuse-bridge.c')
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c49
1 files changed, 41 insertions, 8 deletions
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
index fd07f5f0def..bf63697233b 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -4150,18 +4150,21 @@ fuse_first_lookup (xlator_t *this)
int
-fuse_nameless_lookup (xlator_t *xl, uuid_t gfid, loc_t *loc)
+fuse_nameless_lookup (xlator_t *xl, uuid_t gfid, loc_t *loc,
+ gf_boolean_t resolve_path)
{
int ret = -1;
dict_t *xattr_req = NULL;
struct iatt iatt = {0, };
inode_t *linked_inode = NULL;
+ inode_t *inode = NULL;
+ char *path = NULL;
+ dict_t *xattr_ret = NULL;
if ((loc == NULL) || (xl == NULL)) {
ret = -EINVAL;
goto out;
}
-
if (loc->inode == NULL) {
loc->inode = inode_new (xl->itable);
if (loc->inode == NULL) {
@@ -4171,6 +4174,9 @@ fuse_nameless_lookup (xlator_t *xl, uuid_t gfid, loc_t *loc)
}
gf_uuid_copy (loc->gfid, gfid);
+ if (gf_uuid_is_null (loc->gfid)) {
+ goto out;
+ }
xattr_req = dict_new ();
if (xattr_req == NULL) {
@@ -4178,20 +4184,42 @@ fuse_nameless_lookup (xlator_t *xl, uuid_t gfid, loc_t *loc)
goto out;
}
- ret = syncop_lookup (xl, loc, &iatt, NULL, xattr_req, NULL);
+ if (resolve_path) {
+ /*
+ * setting virtual xattr glusterfs.ancestry.path to get
+ * the path of the parent directory.
+ */
+ ret = dict_set_int32 (xattr_req, GET_ANCESTRY_PATH_KEY, 42);
+ if (ret)
+ goto out;
+ }
+
+ ret = syncop_lookup (xl, loc, &iatt, NULL, xattr_req, &xattr_ret);
if (ret < 0)
goto out;
- linked_inode = inode_link (loc->inode, NULL, NULL, &iatt);
- inode_unref (loc->inode);
- loc->inode = linked_inode;
-
+ if (resolve_path) {
+ ret = dict_get_str (xattr_ret, GET_ANCESTRY_PATH_KEY, &path);
+ }
+ if (path) {
+ inode = loc->inode;
+ loc->inode = fuse_resolve_path (xl, path);
+ inode_unref (inode);
+ } else {
+ linked_inode = inode_link (loc->inode, NULL, NULL, &iatt);
+ inode_unref (loc->inode);
+ loc->inode = linked_inode;
+ }
ret = 0;
out:
if (xattr_req != NULL) {
dict_unref (xattr_req);
}
+ if (xattr_ret) {
+ dict_unref (xattr_ret);
+ }
+
return ret;
}
@@ -4222,8 +4250,13 @@ fuse_migrate_fd_open (xlator_t *this, fd_t *basefd, fd_t *oldfd,
loc.inode = inode_find (new_subvol->itable, basefd->inode->gfid);
if (loc.inode == NULL) {
+
+ /* setting the get_resolve_path to send lookup
+ * on parent directories
+ * */
+
ret = fuse_nameless_lookup (new_subvol, basefd->inode->gfid,
- &loc);
+ &loc, _gf_true);
if (ret < 0) {
gf_log ("glusterfs-fuse", GF_LOG_WARNING,
"name-less lookup of gfid (%s) failed (%s)"