summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/client/src/client3_1-fops.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/protocol/client/src/client3_1-fops.c')
-rw-r--r--xlators/protocol/client/src/client3_1-fops.c159
1 files changed, 129 insertions, 30 deletions
diff --git a/xlators/protocol/client/src/client3_1-fops.c b/xlators/protocol/client/src/client3_1-fops.c
index f1f6bd0a4..80281bca0 100644
--- a/xlators/protocol/client/src/client3_1-fops.c
+++ b/xlators/protocol/client/src/client3_1-fops.c
@@ -2530,10 +2530,17 @@ client3_1_lookup (call_frame_t *frame, xlator_t *this,
loc_copy (&local->loc, args->loc);
frame->local = local;
- if (args->loc->parent)
- memcpy (req.pargfid, args->loc->parent->gfid, 16);
- else
- memcpy (req.gfid, args->loc->inode->gfid, 16);
+ if (args->loc->parent) {
+ if (!uuid_is_null (args->loc->parent->gfid))
+ memcpy (req.pargfid, args->loc->parent->gfid, 16);
+ else
+ memcpy (req.pargfid, args->loc->pargfid, 16);
+ } else {
+ if (!uuid_is_null (args->loc->inode->gfid))
+ memcpy (req.gfid, args->loc->inode->gfid, 16);
+ else
+ memcpy (req.gfid, args->loc->gfid, 16);
+ }
if (args->dict) {
content = dict_get (args->dict, GF_CONTENT_KEY);
@@ -2640,7 +2647,11 @@ client3_1_stat (call_frame_t *frame, xlator_t *this,
if (!(args->loc && args->loc->inode))
goto unwind;
- memcpy (req.gfid, args->loc->inode->gfid, 16);
+ if (!uuid_is_null (args->loc->inode->gfid))
+ memcpy (req.gfid, args->loc->inode->gfid, 16);
+ else
+ memcpy (req.gfid, args->loc->gfid, 16);
+
req.path = (char *)args->loc->path;
conf = this->private;
@@ -2679,7 +2690,11 @@ client3_1_truncate (call_frame_t *frame, xlator_t *this,
if (!(args->loc && args->loc->inode))
goto unwind;
- memcpy (req.gfid, args->loc->inode->gfid, 16);
+ if (!uuid_is_null (args->loc->inode->gfid))
+ memcpy (req.gfid, args->loc->inode->gfid, 16);
+ else
+ memcpy (req.gfid, args->loc->gfid, 16);
+
req.path = (char *)args->loc->path;
req.offset = args->offset;
@@ -2780,7 +2795,11 @@ client3_1_access (call_frame_t *frame, xlator_t *this,
if (!(args->loc && args->loc->inode))
goto unwind;
- memcpy (req.gfid, args->loc->inode->gfid, 16);
+ if (!uuid_is_null (args->loc->inode->gfid))
+ memcpy (req.gfid, args->loc->inode->gfid, 16);
+ else
+ memcpy (req.gfid, args->loc->gfid, 16);
+
req.path = (char *)args->loc->path;
req.mask = args->mask;
@@ -2821,7 +2840,11 @@ client3_1_readlink (call_frame_t *frame, xlator_t *this,
if (!(args->loc && args->loc->inode))
goto unwind;
- memcpy (req.gfid, args->loc->inode->gfid, 16);
+ if (!uuid_is_null (args->loc->inode->gfid))
+ memcpy (req.gfid, args->loc->inode->gfid, 16);
+ else
+ memcpy (req.gfid, args->loc->gfid, 16);
+
req.path = (char *)args->loc->path;
req.size = args->size;
conf = this->private;
@@ -2864,7 +2887,11 @@ client3_1_unlink (call_frame_t *frame, xlator_t *this,
if (!(args->loc && args->loc->parent))
goto unwind;
- memcpy (req.pargfid, args->loc->parent->gfid, 16);
+ if (!uuid_is_null (args->loc->parent->gfid))
+ memcpy (req.pargfid, args->loc->parent->gfid, 16);
+ else
+ memcpy (req.pargfid, args->loc->pargfid, 16);
+
req.path = (char *)args->loc->path;
req.bname = (char *)args->loc->name;
conf = this->private;
@@ -2905,7 +2932,11 @@ client3_1_rmdir (call_frame_t *frame, xlator_t *this,
if (!(args->loc && args->loc->parent))
goto unwind;
- memcpy (req.pargfid, args->loc->parent->gfid, 16);
+ if (!uuid_is_null (args->loc->parent->gfid))
+ memcpy (req.pargfid, args->loc->parent->gfid, 16);
+ else
+ memcpy (req.pargfid, args->loc->pargfid, 16);
+
req.path = (char *)args->loc->path;
req.bname = (char *)args->loc->name;
req.flags = args->flags;
@@ -2956,7 +2987,11 @@ client3_1_symlink (call_frame_t *frame, xlator_t *this,
loc_copy (&local->loc, args->loc);
frame->local = local;
- memcpy (req.pargfid, args->loc->parent->gfid, 16);
+ if (!uuid_is_null (args->loc->parent->gfid))
+ memcpy (req.pargfid, args->loc->parent->gfid, 16);
+ else
+ memcpy (req.pargfid, args->loc->pargfid, 16);
+
req.path = (char *)args->loc->path;
req.linkname = (char *)args->linkname;
req.bname = (char *)args->loc->name;
@@ -3023,8 +3058,15 @@ client3_1_rename (call_frame_t *frame, xlator_t *this,
args->newloc->parent))
goto unwind;
- memcpy (req.oldgfid, args->oldloc->parent->gfid, 16);
- memcpy (req.newgfid, args->newloc->parent->gfid, 16);
+ if (!uuid_is_null (args->oldloc->parent->gfid))
+ memcpy (req.oldgfid, args->oldloc->parent->gfid, 16);
+ else
+ memcpy (req.oldgfid, args->oldloc->pargfid, 16);
+
+ if (!uuid_is_null (args->newloc->parent->gfid))
+ memcpy (req.newgfid, args->newloc->parent->gfid, 16);
+ else
+ memcpy (req.newgfid, args->newloc->pargfid, 16);
req.oldpath = (char *)args->oldloc->path;
req.oldbname = (char *)args->oldloc->name;
@@ -3069,8 +3111,15 @@ client3_1_link (call_frame_t *frame, xlator_t *this,
args->newloc->parent))
goto unwind;
- memcpy (req.oldgfid, args->oldloc->inode->gfid, 16);
- memcpy (req.newgfid, args->newloc->parent->gfid, 16);
+ if (!uuid_is_null (args->oldloc->inode->gfid))
+ memcpy (req.oldgfid, args->oldloc->inode->gfid, 16);
+ else
+ memcpy (req.oldgfid, args->oldloc->gfid, 16);
+
+ if (!uuid_is_null (args->newloc->parent->gfid))
+ memcpy (req.newgfid, args->newloc->parent->gfid, 16);
+ else
+ memcpy (req.newgfid, args->newloc->pargfid, 16);
local = GF_CALLOC (1, sizeof (*local), gf_client_mt_clnt_local_t);
if (!local) {
@@ -3131,7 +3180,11 @@ client3_1_mknod (call_frame_t *frame, xlator_t *this,
loc_copy (&local->loc, args->loc);
frame->local = local;
- memcpy (req.pargfid, args->loc->parent->gfid, 16);
+ if (!uuid_is_null (args->loc->parent->gfid))
+ memcpy (req.pargfid, args->loc->parent->gfid, 16);
+ else
+ memcpy (req.pargfid, args->loc->pargfid, 16);
+
req.path = (char *)args->loc->path;
req.bname = (char *)args->loc->name;
req.mode = args->mode;
@@ -3209,7 +3262,11 @@ client3_1_mkdir (call_frame_t *frame, xlator_t *this,
loc_copy (&local->loc, args->loc);
frame->local = local;
- memcpy (req.pargfid, args->loc->parent->gfid, 16);
+ if (!uuid_is_null (args->loc->parent->gfid))
+ memcpy (req.pargfid, args->loc->parent->gfid, 16);
+ else
+ memcpy (req.pargfid, args->loc->pargfid, 16);
+
req.path = (char *)args->loc->path;
req.bname = (char *)args->loc->name;
req.mode = args->mode;
@@ -3287,7 +3344,11 @@ client3_1_create (call_frame_t *frame, xlator_t *this,
loc_copy (&local->loc, args->loc);
frame->local = local;
- memcpy (req.pargfid, args->loc->parent->gfid, 16);
+ if (!uuid_is_null (args->loc->parent->gfid))
+ memcpy (req.pargfid, args->loc->parent->gfid, 16);
+ else
+ memcpy (req.pargfid, args->loc->pargfid, 16);
+
req.path = (char *)args->loc->path;
req.bname = (char *)args->loc->name;
req.mode = args->mode;
@@ -3366,7 +3427,11 @@ client3_1_open (call_frame_t *frame, xlator_t *this,
loc_copy (&local->loc, args->loc);
frame->local = local;
- memcpy (req.gfid, args->loc->inode->gfid, 16);
+ if (!uuid_is_null (args->loc->inode->gfid))
+ memcpy (req.gfid, args->loc->inode->gfid, 16);
+ else
+ memcpy (req.gfid, args->loc->gfid, 16);
+
req.flags = gf_flags_from_flags (args->flags);
req.wbflags = args->wbflags;
req.path = (char *)args->loc->path;
@@ -3774,7 +3839,11 @@ client3_1_opendir (call_frame_t *frame, xlator_t *this,
loc_copy (&local->loc, args->loc);
frame->local = local;
- memcpy (req.gfid, args->loc->inode->gfid, 16);
+ if (!uuid_is_null (args->loc->inode->gfid))
+ memcpy (req.gfid, args->loc->inode->gfid, 16);
+ else
+ memcpy (req.gfid, args->loc->gfid, 16);
+
req.path = (char *)args->loc->path;
conf = this->private;
@@ -3877,9 +3946,12 @@ client3_1_statfs (call_frame_t *frame, xlator_t *this,
if (!args->loc)
goto unwind;
- if (args->loc->inode)
- memcpy (req.gfid, args->loc->inode->gfid, 16);
- else
+ if (args->loc->inode) {
+ if (!uuid_is_null (args->loc->inode->gfid))
+ memcpy (req.gfid, args->loc->inode->gfid, 16);
+ else
+ memcpy (req.gfid, args->loc->gfid, 16);
+ } else
req.gfid[15] = 1;
req.path = (char *)args->loc->path;
@@ -3922,7 +3994,11 @@ client3_1_setxattr (call_frame_t *frame, xlator_t *this,
if (!(args->loc && args->loc->inode))
goto unwind;
- memcpy (req.gfid, args->loc->inode->gfid, 16);
+ if (!uuid_is_null (args->loc->inode->gfid))
+ memcpy (req.gfid, args->loc->inode->gfid, 16);
+ else
+ memcpy (req.gfid, args->loc->gfid, 16);
+
if (args->dict) {
ret = dict_allocate_and_serialize (args->dict,
&req.dict.dict_val,
@@ -4224,7 +4300,10 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this,
local->iobref = rsp_iobref;
rsp_iobref = NULL;
- memcpy (req.gfid, args->loc->inode->gfid, 16);
+ if (!uuid_is_null (args->loc->inode->gfid))
+ memcpy (req.gfid, args->loc->inode->gfid, 16);
+ else
+ memcpy (req.gfid, args->loc->gfid, 16);
req.namelen = 1; /* Use it as a flag */
req.path = (char *)args->loc->path;
req.name = (char *)args->name;
@@ -4343,7 +4422,11 @@ client3_1_xattrop (call_frame_t *frame, xlator_t *this,
local->iobref = rsp_iobref;
rsp_iobref = NULL;
- memcpy (req.gfid, args->loc->inode->gfid, 16);
+ if (!uuid_is_null (args->loc->inode->gfid))
+ memcpy (req.gfid, args->loc->inode->gfid, 16);
+ else
+ memcpy (req.gfid, args->loc->gfid, 16);
+
if (args->dict) {
ret = dict_allocate_and_serialize (args->dict,
&req.dict.dict_val,
@@ -4551,7 +4634,11 @@ client3_1_removexattr (call_frame_t *frame, xlator_t *this,
if (!(args->loc && args->loc->inode))
goto unwind;
- memcpy (req.gfid, args->loc->inode->gfid, 16);
+ if (!uuid_is_null (args->loc->inode->gfid))
+ memcpy (req.gfid, args->loc->inode->gfid, 16);
+ else
+ memcpy (req.gfid, args->loc->gfid, 16);
+
req.path = (char *)args->loc->path;
req.name = (char *)args->name;
@@ -4686,7 +4773,11 @@ client3_1_inodelk (call_frame_t *frame, xlator_t *this,
if (!(args->loc && args->loc->inode))
goto unwind;
- memcpy (req.gfid, args->loc->inode->gfid, 16);
+ if (!uuid_is_null (args->loc->inode->gfid))
+ memcpy (req.gfid, args->loc->inode->gfid, 16);
+ else
+ memcpy (req.gfid, args->loc->gfid, 16);
+
if (args->cmd == F_GETLK || args->cmd == F_GETLK64)
gf_cmd = GF_LK_GETLK;
else if (args->cmd == F_SETLK || args->cmd == F_SETLK64)
@@ -4845,7 +4936,11 @@ client3_1_entrylk (call_frame_t *frame, xlator_t *this,
if (!(args->loc && args->loc->inode))
goto unwind;
- memcpy (req.gfid, args->loc->inode->gfid, 16);
+ if (!uuid_is_null (args->loc->inode->gfid))
+ memcpy (req.gfid, args->loc->inode->gfid, 16);
+ else
+ memcpy (req.gfid, args->loc->gfid, 16);
+
req.path = (char *)args->loc->path;
req.cmd = args->cmd_entrylk;
req.type = args->type;
@@ -5255,7 +5350,11 @@ client3_1_setattr (call_frame_t *frame, xlator_t *this,
if (!(args->loc && args->loc->inode))
goto unwind;
- memcpy (req.gfid, args->loc->inode->gfid, 16);
+ if (!uuid_is_null (args->loc->inode->gfid))
+ memcpy (req.gfid, args->loc->inode->gfid, 16);
+ else
+ memcpy (req.gfid, args->loc->gfid, 16);
+
req.path = (char *)args->loc->path;
req.valid = args->valid;
gf_stat_from_iatt (&req.stbuf, args->stbuf);