summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand V. Avati <avati@blackhole.gluster.com>2010-08-12 05:05:01 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-08-12 03:55:12 -0700
commitb69a4f1e31726260a07f883cefac28ed29cc6a12 (patch)
tree864d706e8f4d02d6b3296665f74e110020a03d4c
parentf862864468c9d11d646bdcc347a1121fe75a1917 (diff)
portmap functionality in glusterd
Signed-off-by: Anand V. Avati <avati@blackhole.gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1314 (portmapper functionality) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1314
-rw-r--r--rpc/rpc-lib/src/protocol-common.h15
-rw-r--r--rpc/xdr/src/Makefile.am6
-rw-r--r--rpc/xdr/src/portmap-xdr.c192
-rw-r--r--rpc/xdr/src/portmap-xdr.h111
-rw-r--r--rpc/xdr/src/portmap.c189
-rw-r--r--rpc/xdr/src/portmap.h95
-rw-r--r--rpc/xdr/src/portmap.x45
-rw-r--r--xlators/mgmt/glusterd/src/Makefile.am4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-pmap.c336
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-pmap.h55
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c12
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h3
13 files changed, 1066 insertions, 5 deletions
diff --git a/rpc/rpc-lib/src/protocol-common.h b/rpc/rpc-lib/src/protocol-common.h
index 7cff79be3..95ef06aef 100644
--- a/rpc/rpc-lib/src/protocol-common.h
+++ b/rpc/rpc-lib/src/protocol-common.h
@@ -123,6 +123,18 @@ enum gf_cli_procnum {
GF1_CLI_MAXVALUE,
};
+
+enum gf_pmap_procnum {
+ GF_PMAP_NULL = 0,
+ GF_PMAP_PORTBYBRICK,
+ GF_PMAP_BRICKBYPORT,
+ GF_PMAP_SIGNUP,
+ GF_PMAP_SIGNIN,
+ GF_PMAP_SIGNOUT,
+ GF_PMAP_MAXVALUE,
+};
+
+
#define GLUSTER3_1_FOP_PROGRAM 1298437 /* Completely random */
#define GLUSTER3_1_FOP_VERSION 310 /* 3.1.0 */
#define GLUSTER3_1_FOP_PROCCNT GFS3_OP_MAXVALUE
@@ -138,4 +150,7 @@ enum gf_cli_procnum {
#define GLUSTER_HNDSK_PROGRAM 14398633 /* Completely random */
#define GLUSTER_HNDSK_VERSION 1 /* 0.0.1 */
+#define GLUSTER_PMAP_PROGRAM 34123456
+#define GLUSTER_PMAP_VERSION 1
+
#endif /* !_PROTOCOL_COMMON_H */
diff --git a/rpc/xdr/src/Makefile.am b/rpc/xdr/src/Makefile.am
index 79063cd64..981f319b3 100644
--- a/rpc/xdr/src/Makefile.am
+++ b/rpc/xdr/src/Makefile.am
@@ -12,9 +12,11 @@ libgfxdr_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \
libgfxdr_la_SOURCES = xdr-generic.c \
glusterfs3-xdr.c glusterfs3.c \
cli1-xdr.c cli1.c \
- glusterd1-xdr.c glusterd1.c
+ glusterd1-xdr.c glusterd1.c \
+ portmap-xdr.c portmap.c
noinst_HEADERS = xdr-generic.h \
glusterfs3-xdr.h glusterfs3.h \
cli1-xdr.h cli1.h \
- glusterd1-xdr.h glusterd1.h
+ glusterd1-xdr.h glusterd1.h \
+ portmap-xdr.h portmap.h
diff --git a/rpc/xdr/src/portmap-xdr.c b/rpc/xdr/src/portmap-xdr.c
new file mode 100644
index 000000000..a23eef9b3
--- /dev/null
+++ b/rpc/xdr/src/portmap-xdr.c
@@ -0,0 +1,192 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#include "portmap-xdr.h"
+
+bool_t
+xdr_pmap_port_by_brick_req (XDR *xdrs, pmap_port_by_brick_req *objp)
+{
+ if (!xdr_string (xdrs, &objp->brick, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_pmap_port_by_brick_rsp (XDR *xdrs, pmap_port_by_brick_rsp *objp)
+{
+ register int32_t *buf;
+
+
+ if (xdrs->x_op == XDR_ENCODE) {
+ buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_int (xdrs, &objp->op_ret))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->op_errno))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->status))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->port))
+ return FALSE;
+ } else {
+ IXDR_PUT_LONG(buf, objp->op_ret);
+ IXDR_PUT_LONG(buf, objp->op_errno);
+ IXDR_PUT_LONG(buf, objp->status);
+ IXDR_PUT_LONG(buf, objp->port);
+ }
+ return TRUE;
+ } else if (xdrs->x_op == XDR_DECODE) {
+ buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_int (xdrs, &objp->op_ret))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->op_errno))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->status))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->port))
+ return FALSE;
+ } else {
+ objp->op_ret = IXDR_GET_LONG(buf);
+ objp->op_errno = IXDR_GET_LONG(buf);
+ objp->status = IXDR_GET_LONG(buf);
+ objp->port = IXDR_GET_LONG(buf);
+ }
+ return TRUE;
+ }
+
+ if (!xdr_int (xdrs, &objp->op_ret))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->op_errno))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->status))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->port))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_pmap_brick_by_port_req (XDR *xdrs, pmap_brick_by_port_req *objp)
+{
+ if (!xdr_int (xdrs, &objp->port))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_pmap_brick_by_port_rsp (XDR *xdrs, pmap_brick_by_port_rsp *objp)
+{
+ register int32_t *buf;
+
+
+ if (xdrs->x_op == XDR_ENCODE) {
+ buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_int (xdrs, &objp->op_ret))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->op_errno))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->status))
+ return FALSE;
+
+ } else {
+ IXDR_PUT_LONG(buf, objp->op_ret);
+ IXDR_PUT_LONG(buf, objp->op_errno);
+ IXDR_PUT_LONG(buf, objp->status);
+ }
+ if (!xdr_string (xdrs, &objp->brick, ~0))
+ return FALSE;
+ return TRUE;
+ } else if (xdrs->x_op == XDR_DECODE) {
+ buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT);
+ if (buf == NULL) {
+ if (!xdr_int (xdrs, &objp->op_ret))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->op_errno))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->status))
+ return FALSE;
+
+ } else {
+ objp->op_ret = IXDR_GET_LONG(buf);
+ objp->op_errno = IXDR_GET_LONG(buf);
+ objp->status = IXDR_GET_LONG(buf);
+ }
+ if (!xdr_string (xdrs, &objp->brick, ~0))
+ return FALSE;
+ return TRUE;
+ }
+
+ if (!xdr_int (xdrs, &objp->op_ret))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->op_errno))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->status))
+ return FALSE;
+ if (!xdr_string (xdrs, &objp->brick, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_pmap_signup_req (XDR *xdrs, pmap_signup_req *objp)
+{
+ if (!xdr_string (xdrs, &objp->brick, ~0))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->port))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_pmap_signup_rsp (XDR *xdrs, pmap_signup_rsp *objp)
+{
+ if (!xdr_int (xdrs, &objp->op_ret))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->op_errno))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_pmap_signin_req (XDR *xdrs, pmap_signin_req *objp)
+{
+ if (!xdr_string (xdrs, &objp->brick, ~0))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->port))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_pmap_signin_rsp (XDR *xdrs, pmap_signin_rsp *objp)
+{
+ if (!xdr_int (xdrs, &objp->op_ret))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->op_errno))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_pmap_signout_req (XDR *xdrs, pmap_signout_req *objp)
+{
+ if (!xdr_string (xdrs, &objp->brick, ~0))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->port))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_pmap_signout_rsp (XDR *xdrs, pmap_signout_rsp *objp)
+{
+ if (!xdr_int (xdrs, &objp->op_ret))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->op_errno))
+ return FALSE;
+ return TRUE;
+}
diff --git a/rpc/xdr/src/portmap-xdr.h b/rpc/xdr/src/portmap-xdr.h
new file mode 100644
index 000000000..7f8141ab2
--- /dev/null
+++ b/rpc/xdr/src/portmap-xdr.h
@@ -0,0 +1,111 @@
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#ifndef _PORTMAP_H_RPCGEN
+#define _PORTMAP_H_RPCGEN
+
+#include <rpc/rpc.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+struct pmap_port_by_brick_req {
+ char *brick;
+};
+typedef struct pmap_port_by_brick_req pmap_port_by_brick_req;
+
+struct pmap_port_by_brick_rsp {
+ int op_ret;
+ int op_errno;
+ int status;
+ int port;
+};
+typedef struct pmap_port_by_brick_rsp pmap_port_by_brick_rsp;
+
+struct pmap_brick_by_port_req {
+ int port;
+};
+typedef struct pmap_brick_by_port_req pmap_brick_by_port_req;
+
+struct pmap_brick_by_port_rsp {
+ int op_ret;
+ int op_errno;
+ int status;
+ char *brick;
+};
+typedef struct pmap_brick_by_port_rsp pmap_brick_by_port_rsp;
+
+struct pmap_signup_req {
+ char *brick;
+ int port;
+};
+typedef struct pmap_signup_req pmap_signup_req;
+
+struct pmap_signup_rsp {
+ int op_ret;
+ int op_errno;
+};
+typedef struct pmap_signup_rsp pmap_signup_rsp;
+
+struct pmap_signin_req {
+ char *brick;
+ int port;
+};
+typedef struct pmap_signin_req pmap_signin_req;
+
+struct pmap_signin_rsp {
+ int op_ret;
+ int op_errno;
+};
+typedef struct pmap_signin_rsp pmap_signin_rsp;
+
+struct pmap_signout_req {
+ char *brick;
+ int port;
+};
+typedef struct pmap_signout_req pmap_signout_req;
+
+struct pmap_signout_rsp {
+ int op_ret;
+ int op_errno;
+};
+typedef struct pmap_signout_rsp pmap_signout_rsp;
+
+/* the xdr functions */
+
+#if defined(__STDC__) || defined(__cplusplus)
+extern bool_t xdr_pmap_port_by_brick_req (XDR *, pmap_port_by_brick_req*);
+extern bool_t xdr_pmap_port_by_brick_rsp (XDR *, pmap_port_by_brick_rsp*);
+extern bool_t xdr_pmap_brick_by_port_req (XDR *, pmap_brick_by_port_req*);
+extern bool_t xdr_pmap_brick_by_port_rsp (XDR *, pmap_brick_by_port_rsp*);
+extern bool_t xdr_pmap_signup_req (XDR *, pmap_signup_req*);
+extern bool_t xdr_pmap_signup_rsp (XDR *, pmap_signup_rsp*);
+extern bool_t xdr_pmap_signin_req (XDR *, pmap_signin_req*);
+extern bool_t xdr_pmap_signin_rsp (XDR *, pmap_signin_rsp*);
+extern bool_t xdr_pmap_signout_req (XDR *, pmap_signout_req*);
+extern bool_t xdr_pmap_signout_rsp (XDR *, pmap_signout_rsp*);
+
+#else /* K&R C */
+extern bool_t xdr_pmap_port_by_brick_req ();
+extern bool_t xdr_pmap_port_by_brick_rsp ();
+extern bool_t xdr_pmap_brick_by_port_req ();
+extern bool_t xdr_pmap_brick_by_port_rsp ();
+extern bool_t xdr_pmap_signup_req ();
+extern bool_t xdr_pmap_signup_rsp ();
+extern bool_t xdr_pmap_signin_req ();
+extern bool_t xdr_pmap_signin_rsp ();
+extern bool_t xdr_pmap_signout_req ();
+extern bool_t xdr_pmap_signout_rsp ();
+
+#endif /* K&R C */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !_PORTMAP_H_RPCGEN */
diff --git a/rpc/xdr/src/portmap.c b/rpc/xdr/src/portmap.c
new file mode 100644
index 000000000..51c44a7d6
--- /dev/null
+++ b/rpc/xdr/src/portmap.c
@@ -0,0 +1,189 @@
+/*
+ Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+
+#include "portmap.h"
+
+
+ssize_t
+xdr_to_pmap_port_by_brick_req (struct iovec inmsg, void *args)
+{
+ return xdr_to_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_port_by_brick_req);
+}
+
+
+ssize_t
+xdr_to_pmap_port_by_brick_rsp (struct iovec inmsg, void *args)
+{
+ return xdr_to_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_port_by_brick_rsp);
+}
+
+
+ssize_t
+xdr_from_pmap_port_by_brick_req (struct iovec inmsg, void *args)
+{
+ return xdr_serialize_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_port_by_brick_req);
+}
+
+
+ssize_t
+xdr_from_pmap_port_by_brick_rsp (struct iovec inmsg, void *args)
+{
+ return xdr_serialize_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_port_by_brick_rsp);
+}
+
+
+
+ssize_t
+xdr_to_pmap_brick_by_port_req (struct iovec inmsg, void *args)
+{
+ return xdr_to_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_brick_by_port_req);
+}
+
+
+ssize_t
+xdr_to_pmap_brick_by_port_rsp (struct iovec inmsg, void *args)
+{
+ return xdr_to_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_brick_by_port_rsp);
+}
+
+
+ssize_t
+xdr_from_pmap_brick_by_port_req (struct iovec inmsg, void *args)
+{
+ return xdr_serialize_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_brick_by_port_req);
+}
+
+
+ssize_t
+xdr_from_pmap_brick_by_port_rsp (struct iovec inmsg, void *args)
+{
+ return xdr_serialize_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_brick_by_port_rsp);
+}
+
+
+
+
+ssize_t
+xdr_to_pmap_signup_req (struct iovec inmsg, void *args)
+{
+ return xdr_to_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_signup_req);
+}
+
+
+ssize_t
+xdr_to_pmap_signup_rsp (struct iovec inmsg, void *args)
+{
+ return xdr_to_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_signup_rsp);
+}
+
+
+ssize_t
+xdr_from_pmap_signup_req (struct iovec inmsg, void *args)
+{
+ return xdr_serialize_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_signup_req);
+}
+
+
+ssize_t
+xdr_from_pmap_signup_rsp (struct iovec inmsg, void *args)
+{
+ return xdr_serialize_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_signup_rsp);
+}
+
+
+
+
+ssize_t
+xdr_to_pmap_signin_req (struct iovec inmsg, void *args)
+{
+ return xdr_to_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_signin_req);
+}
+
+
+ssize_t
+xdr_to_pmap_signin_rsp (struct iovec inmsg, void *args)
+{
+ return xdr_to_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_signin_rsp);
+}
+
+
+ssize_t
+xdr_from_pmap_signin_req (struct iovec inmsg, void *args)
+{
+ return xdr_serialize_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_signin_req);
+}
+
+
+ssize_t
+xdr_from_pmap_signin_rsp (struct iovec inmsg, void *args)
+{
+ return xdr_serialize_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_signin_rsp);
+}
+
+
+
+
+ssize_t
+xdr_to_pmap_signout_req (struct iovec inmsg, void *args)
+{
+ return xdr_to_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_signout_req);
+}
+
+
+ssize_t
+xdr_to_pmap_signout_rsp (struct iovec inmsg, void *args)
+{
+ return xdr_to_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_signout_rsp);
+}
+
+
+ssize_t
+xdr_from_pmap_signout_req (struct iovec inmsg, void *args)
+{
+ return xdr_serialize_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_signout_req);
+}
+
+
+ssize_t
+xdr_from_pmap_signout_rsp (struct iovec inmsg, void *args)
+{
+ return xdr_serialize_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_pmap_signout_rsp);
+}
+
diff --git a/rpc/xdr/src/portmap.h b/rpc/xdr/src/portmap.h
new file mode 100644
index 000000000..1cfcca3eb
--- /dev/null
+++ b/rpc/xdr/src/portmap.h
@@ -0,0 +1,95 @@
+/*
+ Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+
+#ifndef _PORTMAP_H
+#define _PORTMAP_H
+
+#include <sys/uio.h>
+
+#include "xdr-generic.h"
+#include "portmap-xdr.h"
+
+
+ssize_t
+xdr_to_pmap_port_by_brick_req (struct iovec inmsg, void *args);
+
+ssize_t
+xdr_to_pmap_port_by_brick_rsp (struct iovec inmsg, void *args);
+
+ssize_t
+xdr_from_pmap_port_by_brick_req (struct iovec outmsg, void *args);
+
+ssize_t
+xdr_from_pmap_port_by_brick_rsp (struct iovec outmsg, void *args);
+
+
+ssize_t
+xdr_to_pmap_brick_by_port_req (struct iovec inmsg, void *args);
+
+ssize_t
+xdr_to_pmap_brick_by_port_rsp (struct iovec inmsg, void *args);
+
+ssize_t
+xdr_from_pmap_brick_by_port_req (struct iovec outmsg, void *args);
+
+ssize_t
+xdr_from_pmap_brick_by_port_rsp (struct iovec outmsg, void *args);
+
+
+ssize_t
+xdr_from_pmap_signup_req (struct iovec msg, void *args);
+
+ssize_t
+xdr_from_pmap_signup_rsp (struct iovec msg, void *args);
+
+ssize_t
+xdr_to_pmap_signup_req (struct iovec msg, void *args);
+
+ssize_t
+xdr_to_pmap_signup_rsp (struct iovec msg, void *args);
+
+
+ssize_t
+xdr_from_pmap_signin_req (struct iovec msg, void *args);
+
+ssize_t
+xdr_from_pmap_signin_rsp (struct iovec msg, void *args);
+
+ssize_t
+xdr_to_pmap_signin_req (struct iovec msg, void *args);
+
+ssize_t
+xdr_to_pmap_signin_rsp (struct iovec msg, void *args);
+
+
+ssize_t
+xdr_from_pmap_signout_req (struct iovec msg, void *args);
+
+ssize_t
+xdr_from_pmap_signout_rsp (struct iovec msg, void *args);
+
+ssize_t
+xdr_to_pmap_signout_req (struct iovec msg, void *args);
+
+ssize_t
+xdr_to_pmap_signout_rsp (struct iovec msg, void *args);
+
+
+#endif /* !_PORTMAP_H */
diff --git a/rpc/xdr/src/portmap.x b/rpc/xdr/src/portmap.x
new file mode 100644
index 000000000..6e9f07c45
--- /dev/null
+++ b/rpc/xdr/src/portmap.x
@@ -0,0 +1,45 @@
+
+struct pmap_port_by_brick_req {
+ string brick<>;
+};
+
+struct pmap_port_by_brick_rsp {
+ int op_ret;
+ int op_errno;
+ int status;
+ int port;
+};
+
+
+struct pmap_brick_by_port_req {
+ int port;
+};
+
+struct pmap_brick_by_port_rsp {
+ int op_ret;
+ int op_errno;
+ int status;
+ string brick<>;
+};
+
+
+struct pmap_signup_req {
+};
+
+struct pmap_signup_rsp {
+};
+
+
+struct pmap_signon_req {
+};
+
+struct pmap_signon_rsp {
+};
+
+
+struct pmap_signoff_req {
+};
+
+struct pmap_signoff_rsp {
+};
+
diff --git a/xlators/mgmt/glusterd/src/Makefile.am b/xlators/mgmt/glusterd/src/Makefile.am
index adc7ee30b..f3abd96ef 100644
--- a/xlators/mgmt/glusterd/src/Makefile.am
+++ b/xlators/mgmt/glusterd/src/Makefile.am
@@ -2,7 +2,9 @@ xlator_LTLIBRARIES = glusterd.la
xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/mgmt
glusterd_la_LDFLAGS = -module -avoidversion
glusterd_la_SOURCES = glusterd.c glusterd-handler.c glusterd-sm.c glusterd-op-sm.c \
- glusterd-utils.c glusterd3_1-mops.c glusterd-store.c glusterd-handshake.c
+ glusterd-utils.c glusterd3_1-mops.c glusterd-store.c glusterd-handshake.c \
+ glusterd-pmap.c
+
glusterd_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la\
$(top_builddir)/rpc/xdr/src/libgfxdr.la\
$(top_builddir)/rpc/rpc-lib/src/libgfrpc.la
diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.c b/xlators/mgmt/glusterd/src/glusterd-pmap.c
new file mode 100644
index 000000000..76ad72987
--- /dev/null
+++ b/xlators/mgmt/glusterd/src/glusterd-pmap.c
@@ -0,0 +1,336 @@
+/*
+ Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "glusterfs.h"
+#include "compat-errno.h"
+
+#include "glusterd.h"
+#include "glusterd-utils.h"
+
+#include "portmap.h"
+#include "protocol-common.h"
+#include "rpcsvc.h"
+
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+
+
+int
+pmap_port_isfree (int port)
+{
+ struct sockaddr_in sin;
+ int sock = -1;
+ int ret = 0;
+
+ memset (&sin, 0, sizeof (sin));
+ sin.sin_family = PF_INET;
+ sin.sin_port = hton16 (port);
+
+ sock = socket (PF_INET, SOCK_STREAM, 0);
+ if (sock == -1)
+ return -1;
+
+ ret = bind (sock, (struct sockaddr *)&sin, sizeof (sin));
+ close (sock);
+
+ return ret == 0 ? 1 : 0;
+}
+
+
+struct pmap_registry *
+pmap_registry_new (void)
+{
+ struct pmap_registry *pmap = NULL;
+ int i = 0;
+
+ pmap = CALLOC (sizeof (*pmap), 1);
+ if (!pmap)
+ return NULL;
+
+ for (i = 0; i < 65536; i++) {
+ if (!pmap_port_isfree (i))
+ pmap->ports[i].used = 1;
+ }
+
+ pmap->base_port = 6969;
+ pmap->last_alloc = 6969;
+
+ return pmap;
+}
+
+
+struct pmap_registry *
+pmap_registry_get (xlator_t *this)
+{
+ glusterd_conf_t *priv = NULL;
+ struct pmap_registry *pmap = NULL;
+
+ priv = this->private;
+
+ pmap = priv->pmap;
+ if (!pmap) {
+ pmap = pmap_registry_new ();
+ if (!pmap)
+ return NULL;
+ priv->pmap = pmap;
+ }
+
+ return pmap;
+}
+
+
+int
+pmap_registry_search (xlator_t *this, const char *brickname)
+{
+ glusterd_conf_t *priv = NULL;
+ struct pmap_registry *pmap = NULL;
+ int p = 0;
+ int port = 0;
+
+ priv = this->private;
+
+ pmap = priv->pmap;
+
+ for (p = pmap->base_port; p < 65535; p++) {
+ if (strcmp (pmap->ports[p].brickname, brickname) == 0) {
+ port = p;
+ break;
+ }
+ }
+
+ return port;
+}
+
+
+int
+pmap_registry_alloc (xlator_t *this)
+{
+ glusterd_conf_t *priv = NULL;
+ struct pmap_registry *pmap = NULL;
+ int p = 0;
+ int port = 0;
+
+ priv = this->private;
+
+ pmap = priv->pmap;
+
+ for (p = pmap->base_port; p < 65535; p++) {
+ if (pmap->ports[p].used)
+ continue;
+
+ if (pmap_port_isfree (p)) {
+ pmap->ports[p].used = 1;
+ port = p;
+ break;
+ }
+ }
+
+ return port;
+}
+
+
+
+int
+pmap_registry_bind (xlator_t *this, int port, const char *brickname)
+{
+ glusterd_conf_t *priv = NULL;
+ struct pmap_registry *pmap = NULL;
+ int p = 0;
+
+
+ priv = this->private;
+
+ pmap = priv->pmap;
+
+ pmap->ports[p].used = 1;
+ if (pmap->ports[p].brickname)
+ free (pmap->ports[p].brickname);
+ pmap->ports[p].brickname = strdup (brickname);
+
+ return 0;
+}
+
+
+typedef ssize_t (*gfs_serialize_t) (struct iovec outmsg, void *data);
+
+
+static int
+xdr_to_glusterfs_req (rpcsvc_request_t *req, void *arg, gfs_serialize_t sfunc)
+{
+ int ret = -1;
+
+ if (!req)
+ return -1;
+
+ ret = sfunc (req->msg[0], arg);
+
+ if (ret > 0)
+ ret = 0;
+
+ return ret;
+}
+
+
+int
+gluster_pmap_portbybrick (rpcsvc_request_t *req)
+{
+ pmap_port_by_brick_req args = {0,};
+ pmap_port_by_brick_rsp rsp = {0,};
+ char *brick = NULL;
+ int port = 0;
+
+
+ if (xdr_to_glusterfs_req (req, &args, xdr_to_pmap_port_by_brick_req)) {
+ req->rpc_err = GARBAGE_ARGS;
+ goto fail;
+ }
+
+ brick = args.brick;
+
+ port = pmap_registry_search (THIS, brick);
+
+ rsp.op_ret = 0;
+ rsp.port = port;
+
+fail:
+ glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
+ (gd_serialize_t)xdr_from_pmap_port_by_brick_rsp);
+
+ return 0;
+}
+
+
+int
+gluster_pmap_brickbyport (rpcsvc_request_t *req)
+{
+ pmap_brick_by_port_req args = {0,};
+ pmap_brick_by_port_rsp rsp = {0,};
+
+
+ if (xdr_to_glusterfs_req (req, &args, xdr_to_pmap_brick_by_port_req)) {
+ req->rpc_err = GARBAGE_ARGS;
+ goto fail;
+ }
+
+
+fail:
+
+ glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
+ (gd_serialize_t)xdr_from_pmap_brick_by_port_rsp);
+
+ return 0;
+}
+
+
+
+int
+gluster_pmap_signup (rpcsvc_request_t *req)
+{
+ pmap_signup_req args = {0,};
+ pmap_signup_rsp rsp = {0,};
+
+
+ if (xdr_to_glusterfs_req (req, &args, xdr_to_pmap_signup_req)) {
+ req->rpc_err = GARBAGE_ARGS;
+ goto fail;
+ }
+
+
+fail:
+ glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
+ (gd_serialize_t)xdr_from_pmap_signup_rsp);
+
+ return 0;
+}
+
+
+int
+gluster_pmap_signin (rpcsvc_request_t *req)
+{
+ pmap_signin_req args = {0,};
+ pmap_signin_rsp rsp = {0,};
+
+
+ if (xdr_to_glusterfs_req (req, &args, xdr_to_pmap_signin_req)) {
+ req->rpc_err = GARBAGE_ARGS;
+ goto fail;
+ }
+
+
+fail:
+ glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
+ (gd_serialize_t)xdr_from_pmap_signin_rsp);
+
+ return 0;
+}
+
+
+
+int
+gluster_pmap_signout (rpcsvc_request_t *req)
+{
+ pmap_signout_req args = {0,};
+ pmap_signout_rsp rsp = {0,};
+
+
+ if (xdr_to_glusterfs_req (req, &args, xdr_to_pmap_signout_req)) {
+ //failed to decode msg;
+ req->rpc_err = GARBAGE_ARGS;
+ goto fail;
+ }
+
+
+fail:
+ glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
+ (gd_serialize_t)xdr_from_pmap_signout_rsp);
+
+ return 0;
+}
+
+
+rpcsvc_actor_t gluster_pmap_actors[] = {
+ [GF_PMAP_NULL] = {"NULL", GF_HNDSK_NULL, NULL, NULL, NULL },
+ [GF_PMAP_PORTBYBRICK] = {"PORTBYBRICK", GF_PMAP_PORTBYBRICK,
+ gluster_pmap_portbybrick, NULL, NULL },
+ [GF_PMAP_BRICKBYPORT] = {"BRICKBYPORT", GF_PMAP_BRICKBYPORT,
+ gluster_pmap_brickbyport, NULL, NULL },
+ [GF_PMAP_SIGNIN] = {"SIGNIN", GF_PMAP_SIGNIN,
+ gluster_pmap_signin, NULL, NULL },
+ [GF_PMAP_SIGNOUT] = {"SIGNOUT", GF_PMAP_SIGNOUT,
+ gluster_pmap_signout, NULL, NULL },
+ [GF_PMAP_SIGNUP] = {"SIGNUP", GF_PMAP_SIGNUP,
+ gluster_pmap_signup, NULL, NULL },
+};
+
+
+struct rpcsvc_program gluster_pmap_prog = {
+ .progname = "Gluster Portmap",
+ .prognum = GLUSTER_PMAP_PROGRAM,
+ .progver = GLUSTER_PMAP_VERSION,
+ .actors = gluster_pmap_actors,
+ .numactors = GF_PMAP_MAXVALUE,
+};
diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.h b/xlators/mgmt/glusterd/src/glusterd-pmap.h
new file mode 100644
index 000000000..be028157e
--- /dev/null
+++ b/xlators/mgmt/glusterd/src/glusterd-pmap.h
@@ -0,0 +1,55 @@
+/*
+ Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _GLUSTERD_PMAP_H_
+#define _GLUSTERD_PMAP_H_
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include <pthread.h>
+#include "uuid.h"
+
+#include "glusterfs.h"
+#include "xlator.h"
+#include "logging.h"
+#include "call-stub.h"
+#include "fd.h"
+#include "byte-order.h"
+#include "glusterd.h"
+#include "rpcsvc.h"
+
+
+struct pmap_port_status {
+ int used;
+ char *brickname;
+};
+
+struct pmap_registry {
+ int base_port;
+ int last_alloc;
+ struct pmap_port_status ports[65536];
+};
+
+int pmap_registry_alloc (xlator_t *this);
+int pmap_registry_bind (xlator_t *this, int port, const char *brickname);
+
+#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index c17582341..c135e7526 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -716,7 +716,7 @@ glusterd_volinfo_find (char *volname, glusterd_volinfo_t **volinfo)
int32_t
glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
- glusterd_brickinfo_t *brickinfo,
+ glusterd_brickinfo_t *brickinfo,
int32_t count)
{
int32_t ret = -1;
@@ -727,6 +727,7 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
char path[PATH_MAX] = {0,};
char cmd_str[8192] = {0,};
char rundir[PATH_MAX] = {0,};
+ int port = 0;
GF_ASSERT (volinfo);
GF_ASSERT (brickinfo);
@@ -746,12 +747,19 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
goto out;
}
+ port = pmap_registry_alloc (THIS);
+
GLUSTERD_GET_BRICK_PIDFILE (pidfile, path, brickinfo->hostname, count);
snprintf (volfile, PATH_MAX, "%s/%s-%s-%d.vol", path,
brickinfo->hostname, volinfo->volname, count);
- snprintf (cmd_str, 8192, "glusterfs -f %s -p %s", volfile, pidfile);
+
+ snprintf (cmd_str, 8192,
+ "glusterfs --xlator-option server-tcp.listen-port=%d -f %s -p %s",
+ port, volfile, pidfile);
ret = system (cmd_str);
+ if (ret == 0)
+ pmap_registry_bind (THIS, port, brickinfo->path);
out:
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 7d888d944..d2b271a1b 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -49,6 +49,7 @@ static uuid_t glusterd_uuid;
extern struct rpcsvc_program glusterd1_mop_prog;
extern struct rpcsvc_program gluster_handshake_prog;
extern struct rpc_clnt_program glusterd3_1_mgmt_prog;
+extern struct rpcsvc_program gluster_pmap_prog;
extern glusterd_op_info_t opinfo;
@@ -267,6 +268,13 @@ init (xlator_t *this)
goto out;
}
+ ret = rpcsvc_program_register (rpc, gluster_pmap_prog);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "rpcsvc_program_register returned %d", ret);
+ goto out;
+ }
+
gluster_handshake_prog.options = this->options;
ret = rpcsvc_program_register (rpc, gluster_handshake_prog);
if (ret)
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 2f0937a32..600381243 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -42,6 +42,8 @@
#include "rpcsvc.h"
#include "glusterd-sm.h"
#include "glusterd1-xdr.h"
+#include "glusterd-pmap.h"
+
#define GLUSTERD_MAX_VOLUME_NAME 1000
@@ -64,6 +66,7 @@ typedef struct {
char workdir[PATH_MAX];
rpcsvc_t *rpc;
rpc_clnt_prog_t *mgmt;
+ struct pmap_registry *pmap;
struct list_head volumes;
struct list_head hostnames;
glusterd_store_handle_t *handle;