summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-07-07 08:05:58 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-07-08 02:24:23 -0700
commitc85998fec484a0060c2a7cbcbf7ed42a109c6478 (patch)
tree91aa4b8254c98dadc7907b6627e57daed5c540aa /xlators
parent44604ecf4bfbef991bfcf5f0524ff044177d81a1 (diff)
make DUMP as another program
* on server side, make it a rpc program. * on client its another program at protocol Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 875 (Implement a new protocol to provide proper backward/forward compatibility) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=875
Diffstat (limited to 'xlators')
-rw-r--r--xlators/protocol/client/src/client-handshake.c140
-rw-r--r--xlators/protocol/client/src/client.c3
-rw-r--r--xlators/protocol/client/src/client.h1
-rw-r--r--xlators/protocol/lib/src/glusterfs-xdr.c32
-rw-r--r--xlators/protocol/lib/src/glusterfs-xdr.h23
-rw-r--r--xlators/protocol/lib/src/glusterfs3.x21
-rw-r--r--xlators/protocol/lib/src/msg-xdr.c32
-rw-r--r--xlators/protocol/lib/src/msg-xdr.h12
-rw-r--r--xlators/protocol/lib/src/protocol-common.h1
-rw-r--r--xlators/protocol/server/src/server-handshake.c57
10 files changed, 79 insertions, 243 deletions
diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c
index 1c239d0cb0f..f45cc84aa61 100644
--- a/xlators/protocol/client/src/client-handshake.c
+++ b/xlators/protocol/client/src/client-handshake.c
@@ -596,88 +596,59 @@ fail:
}
int
-select_server_supported_programs (xlator_t *this, char *msg)
+select_server_supported_programs (xlator_t *this, gf_prog_detail *prog)
{
- clnt_conf_t *conf = NULL;
- char *tmp_str = NULL;
- char *prog_str = NULL;
- char *dup_str = NULL;
- char *tmp_str1 = NULL;
- char *tmp_msg = NULL;
- char *progname = NULL;
- char *progver_str = NULL;
- char *prognum_str = NULL;
- int ret = -1;
- int progver = 0;
- int prognum = 0;
-
- if (!this || !msg)
+ gf_prog_detail *trav = NULL;
+ clnt_conf_t *conf = NULL;
+ int ret = -1;
+
+ if (!this || !prog)
goto out;
conf = this->private;
+ trav = prog;
- /* Reply in "Name:Program-Number:Program-Version,..." format */
- tmp_msg = gf_strdup (msg);
- prog_str = strtok_r (tmp_msg, ",", &tmp_str);
- while (prog_str) {
- dup_str = gf_strdup (prog_str);
-
- progname = strtok_r (dup_str, ":", &tmp_str1);
- prognum_str = strtok_r (NULL, ":", &tmp_str1);
- if (!prognum_str) {
- gf_log (this->name, GF_LOG_WARNING,
- "Supported versions not formatted");
- goto out;
- }
- sscanf (prognum_str, "%d", &prognum);
- progver_str = strtok_r (NULL, ":", &tmp_str1);
- if (!progver_str) {
- gf_log (this->name, GF_LOG_WARNING,
- "Supported versions not formatted");
- goto out;
- }
- sscanf (progver_str, "%d", &progver);
-
+ while (trav) {
/* Select 'programs' */
- if ((clnt3_1_fop_prog.prognum == prognum) &&
- (clnt3_1_fop_prog.progver == progver)) {
+ if ((clnt3_1_fop_prog.prognum == trav->prognum) &&
+ (clnt3_1_fop_prog.progver == trav->progver)) {
conf->fops = &clnt3_1_fop_prog;
gf_log (this->name, GF_LOG_INFO,
- "Using Program %s, Num (%s), Version (%s)",
- progname, prognum_str, progver_str);
+ "Using Program %s, Num (%"PRId64"), "
+ "Version (%"PRId64")",
+ trav->progname, trav->prognum, trav->progver);
ret = 0;
}
- if ((clnt3_1_mgmt_prog.prognum == prognum) &&
- (clnt3_1_mgmt_prog.progver == progver)) {
+ if ((clnt3_1_mgmt_prog.prognum == trav->prognum) &&
+ (clnt3_1_mgmt_prog.progver == trav->progver)) {
conf->mgmt = &clnt3_1_mgmt_prog;
gf_log (this->name, GF_LOG_INFO,
- "Using Program %s, Num (%s), Version (%s)",
- progname, prognum_str, progver_str);
+ "Using Program %s, Num (%"PRId64"), "
+ "Version (%"PRId64")",
+ trav->progname, trav->prognum, trav->progver);
ret = 0;
}
-
- prog_str = strtok_r (NULL, ",", &tmp_str);
- GF_FREE (dup_str);
+ if (ret) {
+ gf_log (this->name, GF_LOG_TRACE,
+ "%s (%"PRId64") not supported", trav->progname,
+ trav->progver);
+ }
+ trav = trav->next;
}
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "none of the server versions are supported by client");
- }
- ret = 0;
out:
- if (tmp_msg)
- GF_FREE (tmp_msg);
return ret;
}
int
client_dump_version_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe)
{
- gf_dump_version_rsp rsp = {0,};
- call_frame_t *frame = NULL;
- clnt_conf_t *conf = NULL;
- int ret = 0;
+ gf_dump_rsp rsp = {0,};
+ gf_prog_detail *trav = NULL;
+ gf_prog_detail *next = NULL;
+ call_frame_t *frame = NULL;
+ clnt_conf_t *conf = NULL;
+ int ret = 0;
frame = myframe;
conf = frame->this->private;
@@ -687,7 +658,7 @@ client_dump_version_cbk (struct rpc_req *req, struct iovec *iov, int count, void
goto out;
}
- ret = xdr_to_dump_version_rsp (*iov, &rsp);
+ ret = xdr_to_dump_rsp (*iov, &rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -700,12 +671,11 @@ client_dump_version_cbk (struct rpc_req *req, struct iovec *iov, int count, void
/* Check for the proper version string */
/* Reply in "Name:Program-Number:Program-Version,..." format */
- ret = select_server_supported_programs (frame->this,
- rsp.msg.msg_val);
+ ret = select_server_supported_programs (frame->this, rsp.prog);
if (ret) {
gf_log (frame->this->name, GF_LOG_ERROR,
"Server versions are not present in this "
- "release (%s)", rsp.msg.msg_val);
+ "release");
goto out;
}
@@ -713,8 +683,13 @@ client_dump_version_cbk (struct rpc_req *req, struct iovec *iov, int count, void
out:
/* don't use GF_FREE, buffer was allocated by libc */
- if (rsp.msg.msg_val) {
- free (rsp.msg.msg_val);
+ if (rsp.prog) {
+ trav = rsp.prog;
+ while (trav) {
+ next = trav->next;
+ free (trav);
+ trav = next;
+ }
}
STACK_DESTROY (frame->root);
@@ -724,10 +699,10 @@ out:
int
client_handshake (xlator_t *this, struct rpc_clnt *rpc)
{
- call_frame_t *frame = NULL;
- clnt_conf_t *conf = NULL;
- gf_dump_version_req req = {0,};
- int ret = 0;
+ call_frame_t *frame = NULL;
+ clnt_conf_t *conf = NULL;
+ gf_dump_req req = {0,};
+ int ret = 0;
conf = this->private;
if (!conf->handshake)
@@ -737,24 +712,17 @@ client_handshake (xlator_t *this, struct rpc_clnt *rpc)
if (!frame)
goto out;
- req.key = "fop-handshake";
- req.gfs_id = 123456;
- ret = client_submit_request (this, &req, frame, conf->handshake,
- GF_HNDSK_DUMP_VERSION,
- client_dump_version_cbk,
- NULL, xdr_from_dump_version_req);
+ req.gfs_id = 0xbabe;
+ ret = client_submit_request (this, &req, frame, conf->dump,
+ GF_DUMP_DUMP, client_dump_version_cbk,
+ NULL, xdr_from_dump_req);
out:
return ret;
}
-
-/* */
-/* This table should ideally remain same irrespective of versions */
-
char *clnt_handshake_procs[GF_HNDSK_MAXVALUE] = {
[GF_HNDSK_NULL] = "NULL",
- [GF_HNDSK_DUMP_VERSION] = "VERSION",
[GF_HNDSK_SETVOLUME] = "SETVOLUME",
[GF_HNDSK_GETSPEC] = "GETSPEC",
[GF_HNDSK_PING] = "PING",
@@ -766,3 +734,15 @@ rpc_clnt_prog_t clnt_handshake_prog = {
.progver = GLUSTER_HNDSK_VERSION,
.procnames = clnt_handshake_procs,
};
+
+char *clnt_dump_proc[GF_DUMP_MAXVALUE] = {
+ [GF_DUMP_NULL] = "NULL",
+ [GF_DUMP_DUMP] = "DUMP",
+};
+
+rpc_clnt_prog_t clnt_dump_prog = {
+ .progname = "GF-DUMP",
+ .prognum = GLUSTER_DUMP_PROGRAM,
+ .progver = GLUSTER_DUMP_VERSION,
+ .procnames = clnt_dump_proc,
+};
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
index 6ad5944007f..97e638dfcbe 100644
--- a/xlators/protocol/client/src/client.c
+++ b/xlators/protocol/client/src/client.c
@@ -32,6 +32,8 @@
#include "compat-errno.h"
extern rpc_clnt_prog_t clnt_handshake_prog;
+extern rpc_clnt_prog_t clnt_dump_prog;
+
int
client_handshake (xlator_t *this, struct rpc_clnt *rpc);
@@ -1558,6 +1560,7 @@ init (xlator_t *this)
goto out;
conf->handshake = &clnt_handshake_prog;
+ conf->dump = &clnt_dump_prog;
this->private = conf;
ret = 0;
diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h
index 1422c7abeda..26679cf630a 100644
--- a/xlators/protocol/client/src/client.h
+++ b/xlators/protocol/client/src/client.h
@@ -48,6 +48,7 @@ typedef struct clnt_conf {
rpc_clnt_prog_t *fops;
rpc_clnt_prog_t *mgmt;
rpc_clnt_prog_t *handshake;
+ rpc_clnt_prog_t *dump;
} clnt_conf_t;
typedef struct _client_fd_ctx {
diff --git a/xlators/protocol/lib/src/glusterfs-xdr.c b/xlators/protocol/lib/src/glusterfs-xdr.c
index cbc4d7cef47..92b8c2ed247 100644
--- a/xlators/protocol/lib/src/glusterfs-xdr.c
+++ b/xlators/protocol/lib/src/glusterfs-xdr.c
@@ -1667,38 +1667,6 @@ xdr_gf_common_rsp (XDR *xdrs, gf_common_rsp *objp)
bool_t
-xdr_gf_dump_version_req (XDR *xdrs, gf_dump_version_req *objp)
-{
-
- if (!xdr_u_quad_t (xdrs, &objp->gfs_id))
- return FALSE;
- if (!xdr_u_int (xdrs, &objp->flags))
- return FALSE;
- if (!xdr_string (xdrs, &objp->key, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf_dump_version_rsp (XDR *xdrs, gf_dump_version_rsp *objp)
-{
-
- if (!xdr_u_quad_t (xdrs, &objp->gfs_id))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_u_int (xdrs, &objp->flags))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->msg.msg_val, (u_int *) &objp->msg.msg_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-
-
-bool_t
xdr_gfs3_dirlist (XDR *xdrs, gfs3_dirlist *objp)
{
if (!xdr_u_quad_t (xdrs, &objp->d_ino))
diff --git a/xlators/protocol/lib/src/glusterfs-xdr.h b/xlators/protocol/lib/src/glusterfs-xdr.h
index 45ce3ff9bed..a3afe8861ac 100644
--- a/xlators/protocol/lib/src/glusterfs-xdr.h
+++ b/xlators/protocol/lib/src/glusterfs-xdr.h
@@ -1063,25 +1063,6 @@ struct gf_common_rsp {
};
typedef struct gf_common_rsp gf_common_rsp;
-struct gf_dump_version_req {
- u_quad_t gfs_id;
- u_int flags;
- char *key;
-};
-typedef struct gf_dump_version_req gf_dump_version_req;
-
-struct gf_dump_version_rsp {
- u_quad_t gfs_id;
- int op_ret;
- int op_errno;
- u_int flags;
- struct {
- u_int msg_len;
- char *msg_val;
- } msg;
-};
-typedef struct gf_dump_version_rsp gf_dump_version_rsp;
-
struct gfs3_dirlist {
u_quad_t d_ino;
u_quad_t d_off;
@@ -1208,8 +1189,6 @@ extern bool_t xdr_gf_notify_rsp (XDR *, gf_notify_rsp*);
extern bool_t xdr_gfs3_releasedir_req (XDR *, gfs3_releasedir_req*);
extern bool_t xdr_gfs3_release_req (XDR *, gfs3_release_req*);
extern bool_t xdr_gf_common_rsp (XDR *, gf_common_rsp*);
-extern bool_t xdr_gf_dump_version_req (XDR *, gf_dump_version_req *);
-extern bool_t xdr_gf_dump_version_rsp (XDR *, gf_dump_version_rsp *);
#else /* K&R C */
extern bool_t xdr_gf_statfs ();
@@ -1297,8 +1276,6 @@ extern bool_t xdr_gf_log_req ();
extern bool_t xdr_gf_notify_req ();
extern bool_t xdr_gf_notify_rsp ();
extern bool_t xdr_gf_common_rsp ();
-extern bool_t xdr_gf_dump_version_req ();
-extern bool_t xdr_gf_dump_version_rsp ();
#endif /* K&R C */
diff --git a/xlators/protocol/lib/src/glusterfs3.x b/xlators/protocol/lib/src/glusterfs3.x
index b2eb9556c02..cafe965efaf 100644
--- a/xlators/protocol/lib/src/glusterfs3.x
+++ b/xlators/protocol/lib/src/glusterfs3.x
@@ -732,19 +732,20 @@ struct gf_common_rsp {
} ;
-struct gf_dump_version_req {
- unsigned hyper gfs_id;
- unsigned int flags;
- string key<>;
+struct gf_dump_req {
+ unsigned hyper gfs_id;
};
+struct gf_prog_detail {
+ string progname<>;
+ unsigned hyper prognum;
+ unsigned hyper progver;
+ struct gf_prog_detail *next;
+};
-struct gf_dump_version_rsp {
- unsigned hyper gfs_id;
- int op_ret;
- int op_errno;
- unsigned int flags;
- opaque msg<>;
+struct gf_dump_rsp {
+ unsigned hyper gfs_id;
+ struct gf_prog_detail *prog;
};
struct auth_glusterfs_parms {
diff --git a/xlators/protocol/lib/src/msg-xdr.c b/xlators/protocol/lib/src/msg-xdr.c
index 3fe5ad5f65d..9227e715fd3 100644
--- a/xlators/protocol/lib/src/msg-xdr.c
+++ b/xlators/protocol/lib/src/msg-xdr.c
@@ -341,24 +341,6 @@ xdr_serialize_ftruncate_rsp (struct iovec outmsg, void *rsp)
ssize_t
-xdr_serialize_dump_version_rsp (struct iovec outmsg, void *rsp)
-{
- return xdr_serialize_generic (outmsg, (void *)rsp,
- (xdrproc_t)xdr_gf_dump_version_rsp);
-}
-
-
-/* Decode */
-
-
-ssize_t
-xdr_to_dump_version_req (struct iovec inmsg, void *args)
-{
- return xdr_to_generic (inmsg, (void *)args,
- (xdrproc_t)xdr_gf_dump_version_req);
-}
-
-ssize_t
xdr_to_lookup_req (struct iovec inmsg, void *args)
{
return xdr_to_generic (inmsg, (void *)args,
@@ -960,13 +942,6 @@ xdr_from_setvolume_req (struct iovec outmsg, void *req)
}
ssize_t
-xdr_from_dump_version_req (struct iovec outmsg, void *req)
-{
- return xdr_serialize_generic (outmsg, (void *)req,
- (xdrproc_t)xdr_gf_dump_version_req);
-
-}
-ssize_t
xdr_from_rmdir_req (struct iovec outmsg, void *req)
{
return xdr_serialize_generic (outmsg, (void *)req,
@@ -1207,13 +1182,6 @@ xdr_to_setvolume_rsp (struct iovec outmsg, void *rsp)
}
ssize_t
-xdr_to_dump_version_rsp (struct iovec outmsg, void *rsp)
-{
- return xdr_to_generic (outmsg, (void *)rsp,
- (xdrproc_t)xdr_gf_dump_version_rsp);
-
-}
-ssize_t
xdr_to_rmdir_rsp (struct iovec outmsg, void *rsp)
{
return xdr_to_generic (outmsg, (void *)rsp,
diff --git a/xlators/protocol/lib/src/msg-xdr.h b/xlators/protocol/lib/src/msg-xdr.h
index 59b6ca30112..025b7f8c717 100644
--- a/xlators/protocol/lib/src/msg-xdr.h
+++ b/xlators/protocol/lib/src/msg-xdr.h
@@ -406,23 +406,11 @@ ssize_t
xdr_from_release_req (struct iovec outmsg, void *args);
ssize_t
-xdr_from_dump_version_req (struct iovec outmsg, void *args);
-
-ssize_t
xdr_from_setvolume_req (struct iovec outmsg, void *args);
ssize_t
xdr_to_setvolume_rsp (struct iovec inmsg, void *args);
-ssize_t
-xdr_to_dump_version_rsp (struct iovec inmsg, void *args);
-
-
-ssize_t
-xdr_serialize_dump_version_rsp (struct iovec outmsg, void *args);
-
-ssize_t
-xdr_to_dump_version_req (struct iovec inmsg, void *args);
ssize_t
diff --git a/xlators/protocol/lib/src/protocol-common.h b/xlators/protocol/lib/src/protocol-common.h
index 5590960a6d9..78ee2581fdf 100644
--- a/xlators/protocol/lib/src/protocol-common.h
+++ b/xlators/protocol/lib/src/protocol-common.h
@@ -69,7 +69,6 @@ enum gf_fop_procnum {
enum gf_handshake_procnum {
GF_HNDSK_NULL,
- GF_HNDSK_DUMP_VERSION,
GF_HNDSK_SETVOLUME,
GF_HNDSK_GETSPEC,
GF_HNDSK_PING,
diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c
index 94586d20c53..61630d1f625 100644
--- a/xlators/protocol/server/src/server-handshake.c
+++ b/xlators/protocol/server/src/server-handshake.c
@@ -241,52 +241,6 @@ out:
return ret;
}
-int
-build_program_list (server_conf_t *conf, char *list)
-{
- /* Reply in "Name:Program-Number:Program-Version,..." format */
- sprintf (list, "%s:%d:%d",
- glusterfs3_1_fop_prog.progname,
- glusterfs3_1_fop_prog.prognum,
- glusterfs3_1_fop_prog.progver);
- /* TODO: keep adding new versions to the list here */
- return 0;
-}
-
-int
-server_dump_version (rpcsvc_request_t *req)
-{
- char list[8192] = {0,};
- server_conf_t *conf = NULL;
- int ret = -1;
- int op_errno = EINVAL;
- gf_dump_version_req args = {0,};
- gf_dump_version_rsp rsp = {0,};
-
- conf = ((xlator_t *)req->conn->svc->mydata)->private;
-
- if (xdr_to_glusterfs_req (req, &args, xdr_to_dump_version_req)) {
- //failed to decode msg;
- req->rpc_err = GARBAGE_ARGS;
- goto fail;
- }
-
- build_program_list (conf, list);
- rsp.msg.msg_val = list;
- rsp.msg.msg_len = strlen (list) + 1;
- ret = 0;
-fail:
- rsp.op_errno = gf_errno_to_error (op_errno);
- rsp.op_ret = ret;
-
- server_submit_reply (NULL, req, &rsp, NULL, 0, NULL,
- (gfs_serialize_t)xdr_serialize_dump_version_rsp);
-
- if (args.key)
- free (args.key);
-
- return 0;
-}
int
server_getspec (rpcsvc_request_t *req)
@@ -672,11 +626,10 @@ server_ping (rpcsvc_request_t *req)
rpcsvc_actor_t gluster_handshake_actors[] = {
- [GF_HNDSK_NULL] = {"NULL", GF_HNDSK_NULL, server_null, NULL, NULL },
- [GF_HNDSK_DUMP_VERSION] = {"VERSION", GF_HNDSK_DUMP_VERSION, server_dump_version, NULL, NULL },
+ [GF_HNDSK_NULL] = {"NULL", GF_HNDSK_NULL, server_null, NULL, NULL },
[GF_HNDSK_SETVOLUME] = {"SETVOLUME", GF_HNDSK_SETVOLUME, server_setvolume, NULL, NULL },
- [GF_HNDSK_GETSPEC] = {"GETSPEC", GF_HNDSK_GETSPEC, server_getspec, NULL, NULL },
- [GF_HNDSK_PING] = {"PING", GF_HNDSK_PING, server_ping, NULL, NULL },
+ [GF_HNDSK_GETSPEC] = {"GETSPEC", GF_HNDSK_GETSPEC, server_getspec, NULL, NULL },
+ [GF_HNDSK_PING] = {"PING", GF_HNDSK_PING, server_ping, NULL, NULL },
};
@@ -684,8 +637,6 @@ struct rpcsvc_program gluster_handshake_prog = {
.progname = "GlusterFS Handshake",
.prognum = GLUSTER_HNDSK_PROGRAM,
.progver = GLUSTER_HNDSK_VERSION,
-
.actors = gluster_handshake_actors,
- .numactors = 5,
- .progport = 7008,
+ .numactors = GF_HNDSK_MAXVALUE,
};