summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/server/src
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-09-03 11:46:21 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-04 01:45:41 -0700
commit2c400f60cad3ac0b9dbf1be06b48675d40fcc824 (patch)
treed2593d77e0e24a9ffc63f247a2e737c70bde2571 /xlators/protocol/server/src
parent64443fa783c9c43a597440164b35fd8131b7f4d3 (diff)
gfid: protocol/xdr changes to handle gfid based fops.
Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand V. Avati <avati@blackhole.gluster.com> Signed-off-by: Anand V. Avati <avati@amp.gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 971 (dynamic volume management) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971
Diffstat (limited to 'xlators/protocol/server/src')
-rw-r--r--xlators/protocol/server/src/server-resolve.c4
-rw-r--r--xlators/protocol/server/src/server.h2
-rw-r--r--xlators/protocol/server/src/server3_1-fops.c242
3 files changed, 188 insertions, 60 deletions
diff --git a/xlators/protocol/server/src/server-resolve.c b/xlators/protocol/server/src/server-resolve.c
index eba34bdf768..1a489f6ef4c 100644
--- a/xlators/protocol/server/src/server-resolve.c
+++ b/xlators/protocol/server/src/server-resolve.c
@@ -150,9 +150,9 @@ resolve_deep_continue (call_frame_t *frame)
resolve->op_ret = 0;
resolve->op_errno = 0;
- if (resolve->par)
+ if (resolve->pargfid)
ret = resolve_entry_simple (frame);
- else if (resolve->ino)
+ else if (resolve->gfid)
ret = resolve_inode_simple (frame);
else if (resolve->path)
ret = resolve_path_simple (frame);
diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h
index 453eee57e1c..a86c6b31824 100644
--- a/xlators/protocol/server/src/server.h
+++ b/xlators/protocol/server/src/server.h
@@ -126,6 +126,8 @@ typedef struct {
ino_t ino;
uint64_t gen;
ino_t par;
+ u_char gfid[16];
+ u_char pargfid[16];
char *path;
char *bname;
char *resolved;
diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c
index 17348162824..ddcc423fd4e 100644
--- a/xlators/protocol/server/src/server3_1-fops.c
+++ b/xlators/protocol/server/src/server3_1-fops.c
@@ -2682,8 +2682,7 @@ server_stat (rpcsvc_request_t *req)
}
state->resolve.type = RESOLVE_MUST;
- state->resolve.ino = args.ino;
- state->resolve.gen = args.gen;
+ memcpy (state->resolve.gfid, args.gfid, 16);
state->resolve.path = gf_strdup (args.path);
resolve_and_resume (frame, server_stat_resume);
@@ -2727,8 +2726,7 @@ server_setattr (rpcsvc_request_t *req)
}
state->resolve.type = RESOLVE_MUST;
- state->resolve.ino = args.ino;
- state->resolve.gen = args.gen;
+ memcpy (state->resolve.gfid, args.gfid, 16);
state->resolve.path = gf_strdup (args.path);
gf_stat_to_iatt (&args.stbuf, &state->stbuf);
@@ -2818,8 +2816,7 @@ server_readlink (rpcsvc_request_t *req)
}
state->resolve.type = RESOLVE_MUST;
- state->resolve.ino = args.ino;
- state->resolve.gen = args.gen;
+ memcpy (state->resolve.gfid, args.gfid, 16);
state->resolve.path = gf_strdup (args.path);
state->size = args.size;
@@ -2835,10 +2832,12 @@ server_create (rpcsvc_request_t *req)
{
server_state_t *state = NULL;
call_frame_t *frame = NULL;
+ dict_t *params = NULL;
+ char *buf = NULL;
gfs3_create_req args = {0,};
char path[SERVER_PATH_MAX] = {0,};
char bname[SERVER_PATH_MAX] = {0,};
-
+ int ret = 0;
if (!req)
return 0;
@@ -2865,18 +2864,53 @@ server_create (rpcsvc_request_t *req)
req->rpc_err = GARBAGE_ARGS;
goto out;
}
+ if (args.dict.dict_len) {
+ /* Unserialize the dictionary */
+ params = dict_new ();
+
+ buf = memdup (args.dict.dict_val, args.dict.dict_len);
+ if (buf == NULL) {
+ gf_log (state->conn->bound_xl->name, GF_LOG_ERROR,
+ "out of memory");
+ goto out;
+ }
+
+ ret = dict_unserialize (buf, args.dict.dict_len,
+ &params);
+ if (ret < 0) {
+ gf_log (state->conn->bound_xl->name, GF_LOG_ERROR,
+ "%"PRId64": %s (%"PRId64"): failed to "
+ "unserialize req-buffer to dictionary",
+ frame->root->unique, state->resolve.path,
+ state->resolve.ino);
+ goto out;
+ }
+
+ state->dict = params;
+
+ params->extra_free = buf;
+
+ buf = NULL;
+ }
state->resolve.type = RESOLVE_NOT;
- state->resolve.par = args.par;
- state->resolve.gen = args.gen;
state->resolve.path = gf_strdup (args.path);
state->resolve.bname = gf_strdup (args.bname);
state->mode = args.mode;
state->flags = gf_flags_to_flags (args.flags);
+ memcpy (state->resolve.pargfid, args.pargfid, 16);
resolve_and_resume (frame, server_create_resume);
+ return 0;
out:
+ if (params)
+ dict_unref (params);
+
+ if (buf) {
+ GF_FREE (buf);
+ }
return 0;
+
}
@@ -2915,8 +2949,7 @@ server_open (rpcsvc_request_t *req)
}
state->resolve.type = RESOLVE_MUST;
- state->resolve.ino = args.ino;
- state->resolve.gen = args.gen;
+ memcpy (state->resolve.gfid, args.gfid, 16);
state->resolve.path = gf_strdup (args.path);
state->flags = gf_flags_to_flags (args.flags);
@@ -3283,8 +3316,7 @@ server_truncate (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.path = gf_strdup (args.path);
- state->resolve.ino = args.ino;
- state->resolve.gen = args.gen;
+ memcpy (state->resolve.gfid, args.gfid, 16);
state->offset = args.offset;
resolve_and_resume (frame, server_truncate_resume);
@@ -3331,10 +3363,9 @@ server_unlink (rpcsvc_request_t *req)
}
state->resolve.type = RESOLVE_MUST;
- state->resolve.par = args.par;
- state->resolve.gen = args.gen;
state->resolve.path = gf_strdup (args.path);
state->resolve.bname = gf_strdup (args.bname);
+ memcpy (state->resolve.pargfid, args.pargfid, 16);
resolve_and_resume (frame, server_unlink_resume);
out:
@@ -3386,9 +3417,8 @@ server_setxattr (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.path = gf_strdup (args.path);
- state->resolve.ino = args.ino;
- state->resolve.gen = args.gen;
state->flags = args.flags;
+ memcpy (state->resolve.gfid, args.gfid, 16);
if (args.dict.dict_len) {
dict = dict_new ();
@@ -3547,10 +3577,8 @@ server_fxattrop (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.fd_no = args.fd;
-
- state->resolve.ino = args.ino;
- state->resolve.gen = args.gen;
state->flags = args.flags;
+ memcpy (state->resolve.gfid, args.gfid, 16);
if (args.dict.dict_len) {
/* Unserialize the dictionary */
@@ -3631,9 +3659,8 @@ server_xattrop (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.path = gf_strdup (args.path);
- state->resolve.ino = args.ino;
- state->resolve.gen = args.gen;
state->flags = args.flags;
+ memcpy (state->resolve.gfid, args.gfid, 16);
if (args.dict.dict_len) {
/* Unserialize the dictionary */
@@ -3707,8 +3734,7 @@ server_getxattr (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.path = gf_strdup (args.path);
- state->resolve.ino = args.ino;
- state->resolve.gen = args.gen;
+ memcpy (state->resolve.gfid, args.gfid, 16);
if (args.namelen)
state->name = gf_strdup (args.name);
@@ -3802,8 +3828,7 @@ server_removexattr (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.path = gf_strdup (args.path);
- state->resolve.ino = args.ino;
- state->resolve.gen = args.gen;
+ memcpy (state->resolve.gfid, args.gfid, 16);
state->name = gf_strdup (args.name);
resolve_and_resume (frame, server_removexattr_resume);
@@ -3850,8 +3875,7 @@ server_opendir (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.path = gf_strdup (args.path);
- state->resolve.ino = args.ino;
- state->resolve.gen = args.gen;
+ memcpy (state->resolve.gfid, args.gfid, 16);
resolve_and_resume (frame, server_opendir_resume);
out:
@@ -4010,9 +4034,12 @@ server_mknod (rpcsvc_request_t *req)
{
server_state_t *state = NULL;
call_frame_t *frame = NULL;
+ dict_t *params = NULL;
+ char *buf = NULL;
gfs3_mknod_req args = {0,};
char bname[SERVER_PATH_MAX] = {0,};
char path[SERVER_PATH_MAX] = {0,};
+ int ret = 0;
if (!req)
return 0;
@@ -4041,9 +4068,37 @@ server_mknod (rpcsvc_request_t *req)
goto out;
}
+ if (args.dict.dict_len) {
+ /* Unserialize the dictionary */
+ params = dict_new ();
+
+ buf = memdup (args.dict.dict_val, args.dict.dict_len);
+ if (buf == NULL) {
+ gf_log (state->conn->bound_xl->name, GF_LOG_ERROR,
+ "out of memory");
+ goto out;
+ }
+
+ ret = dict_unserialize (buf, args.dict.dict_len,
+ &params);
+ if (ret < 0) {
+ gf_log (state->conn->bound_xl->name, GF_LOG_ERROR,
+ "%"PRId64": %s (%"PRId64"): failed to "
+ "unserialize req-buffer to dictionary",
+ frame->root->unique, state->resolve.path,
+ state->resolve.ino);
+ goto out;
+ }
+
+ state->dict = params;
+
+ params->extra_free = buf;
+
+ buf = NULL;
+ }
+
state->resolve.type = RESOLVE_NOT;
- state->resolve.par = args.par;
- state->resolve.gen = args.gen;
+ memcpy (state->resolve.pargfid, args.pargfid, 16);
state->resolve.path = gf_strdup (args.path);
state->resolve.bname = gf_strdup (args.bname);
@@ -4051,8 +4106,16 @@ server_mknod (rpcsvc_request_t *req)
state->dev = args.dev;
resolve_and_resume (frame, server_mknod_resume);
+ return 0;
out:
+ if (params)
+ dict_unref (params);
+
+ if (buf) {
+ GF_FREE (buf);
+ }
return 0;
+
}
@@ -4061,9 +4124,12 @@ server_mkdir (rpcsvc_request_t *req)
{
server_state_t *state = NULL;
call_frame_t *frame = NULL;
+ dict_t *params = NULL;
+ char *buf = NULL;
gfs3_mkdir_req args = {0,};
char bname[SERVER_PATH_MAX] = {0,};
char path[SERVER_PATH_MAX] = {0,};
+ int ret = 0;
if (!req)
return 0;
@@ -4091,18 +4157,53 @@ server_mkdir (rpcsvc_request_t *req)
req->rpc_err = GARBAGE_ARGS;
goto out;
}
+ if (args.dict.dict_len) {
+ /* Unserialize the dictionary */
+ params = dict_new ();
+
+ buf = memdup (args.dict.dict_val, args.dict.dict_len);
+ if (buf == NULL) {
+ gf_log (state->conn->bound_xl->name, GF_LOG_ERROR,
+ "out of memory");
+ goto out;
+ }
+
+ ret = dict_unserialize (buf, args.dict.dict_len,
+ &params);
+ if (ret < 0) {
+ gf_log (state->conn->bound_xl->name, GF_LOG_ERROR,
+ "%"PRId64": %s (%"PRId64"): failed to "
+ "unserialize req-buffer to dictionary",
+ frame->root->unique, state->resolve.path,
+ state->resolve.ino);
+ goto out;
+ }
+
+ state->dict = params;
+
+ params->extra_free = buf;
+
+ buf = NULL;
+ }
state->resolve.type = RESOLVE_NOT;
- state->resolve.par = args.par;
- state->resolve.gen = args.gen;
+ memcpy (state->resolve.pargfid, args.pargfid, 16);
state->resolve.path = gf_strdup (args.path);
state->resolve.bname = gf_strdup (args.bname);
state->mode = args.mode;
resolve_and_resume (frame, server_mkdir_resume);
+ return 0;
out:
+ if (params)
+ dict_unref (params);
+
+ if (buf) {
+ GF_FREE (buf);
+ }
return 0;
+
}
@@ -4143,8 +4244,7 @@ server_rmdir (rpcsvc_request_t *req)
}
state->resolve.type = RESOLVE_MUST;
- state->resolve.par = args.par;
- state->resolve.gen = args.gen;
+ memcpy (state->resolve.pargfid, args.pargfid, 16);
state->resolve.path = gf_strdup (args.path);
state->resolve.bname = gf_strdup (args.bname);
@@ -4193,8 +4293,7 @@ server_inodelk (rpcsvc_request_t *req)
}
state->resolve.type = RESOLVE_EXACT;
- state->resolve.ino = args.ino;
- state->resolve.gen = args.gen;
+ memcpy (state->resolve.gfid, args.gfid, 16);
state->resolve.path = gf_strdup (args.path);
cmd = args.cmd;
@@ -4344,8 +4443,7 @@ server_entrylk (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_EXACT;
state->resolve.path = gf_strdup (args.path);
- state->resolve.ino = args.ino;
- state->resolve.gen = args.gen;
+ memcpy (state->resolve.gfid, args.gfid, 16);
if (args.namelen)
state->name = gf_strdup (args.name);
@@ -4442,8 +4540,7 @@ server_access (rpcsvc_request_t *req)
}
state->resolve.type = RESOLVE_MUST;
- state->resolve.ino = args.ino;
- state->resolve.gen = args.gen;
+ memcpy (state->resolve.gfid, args.gfid, 16);
state->resolve.path = gf_strdup (args.path);
state->mask = args.mask;
@@ -4459,10 +4556,13 @@ server_symlink (rpcsvc_request_t *req)
{
server_state_t *state = NULL;
call_frame_t *frame = NULL;
+ dict_t *params = NULL;
+ char *buf = NULL;
gfs3_symlink_req args = {0,};
char linkname[4096] = {0,};
char path[SERVER_PATH_MAX] = {0,};
char bname[4096] = {0,};
+ int ret = 0;
if (!req)
return 0;
@@ -4492,15 +4592,50 @@ server_symlink (rpcsvc_request_t *req)
goto out;
}
+ if (args.dict.dict_len) {
+ /* Unserialize the dictionary */
+ params = dict_new ();
+
+ buf = memdup (args.dict.dict_val, args.dict.dict_len);
+ if (buf == NULL) {
+ gf_log (state->conn->bound_xl->name, GF_LOG_ERROR,
+ "out of memory");
+ goto out;
+ }
+
+ ret = dict_unserialize (buf, args.dict.dict_len,
+ &params);
+ if (ret < 0) {
+ gf_log (state->conn->bound_xl->name, GF_LOG_ERROR,
+ "%"PRId64": %s (%"PRId64"): failed to "
+ "unserialize req-buffer to dictionary",
+ frame->root->unique, state->resolve.path,
+ state->resolve.ino);
+ goto out;
+ }
+
+ state->dict = params;
+
+ params->extra_free = buf;
+
+ buf = NULL;
+ }
+
state->resolve.type = RESOLVE_NOT;
- state->resolve.par = args.par;
- state->resolve.gen = args.gen;
+ memcpy (state->resolve.pargfid, args.pargfid, 16);
state->resolve.path = gf_strdup (args.path);
state->resolve.bname = gf_strdup (args.bname);
state->name = gf_strdup (args.linkname);
resolve_and_resume (frame, server_symlink_resume);
+ return 0;
out:
+ if (params)
+ dict_unref (params);
+
+ if (buf) {
+ GF_FREE (buf);
+ }
return 0;
}
@@ -4546,14 +4681,12 @@ server_link (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.path = gf_strdup (args.oldpath);
- state->resolve.ino = args.oldino;
- state->resolve.gen = args.oldgen;
+ memcpy (state->resolve.gfid, args.oldgfid, 16);
state->resolve2.type = RESOLVE_NOT;
state->resolve2.path = gf_strdup (args.newpath);
state->resolve2.bname = gf_strdup (args.newbname);
- state->resolve2.par = args.newpar;
- state->resolve2.gen = args.newgen;
+ memcpy (state->resolve2.pargfid, args.newgfid, 16);
resolve_and_resume (frame, server_link_resume);
out:
@@ -4603,14 +4736,12 @@ server_rename (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.path = gf_strdup (args.oldpath);
state->resolve.bname = gf_strdup (args.oldbname);
- state->resolve.par = args.oldpar;
- state->resolve.gen = args.oldgen;
+ memcpy (state->resolve.pargfid, args.oldgfid, 16);
state->resolve2.type = RESOLVE_MAY;
state->resolve2.path = gf_strdup (args.newpath);
state->resolve2.bname = gf_strdup (args.newbname);
- state->resolve2.par = args.newpar;
- state->resolve2.gen = args.newgen;
+ memcpy (state->resolve2.pargfid, args.newgfid, 16);
resolve_and_resume (frame, server_rename_resume);
out:
@@ -4796,13 +4927,10 @@ server_lookup (rpcsvc_request_t *req)
req->rpc_err = GARBAGE_ARGS;
goto out;
}
- state->resolve.ino = args.ino;
- if (state->resolve.ino != 1)
- state->resolve.ino = 0;
+ memcpy (state->resolve.gfid, args.gfid, 16);
state->resolve.type = RESOLVE_DONTCARE;
- state->resolve.par = args.par;
- state->resolve.gen = args.gen;
+ memcpy (state->resolve.pargfid, args.pargfid, 16);
state->resolve.path = gf_strdup (args.path);
if (IS_NOT_ROOT (STRLEN_0 (args.path))) {
@@ -4889,9 +5017,7 @@ server_statfs (rpcsvc_request_t *req)
}
state->resolve.type = RESOLVE_MUST;
- state->resolve.ino = args.ino;
- if (!state->resolve.ino)
- state->resolve.ino = 1;
+ memcpy (state->resolve.gfid, args.gfid, 16);
state->resolve.gen = args.gen;
state->resolve.path = gf_strdup (args.path);