summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorSoumya Koduri <skoduri@redhat.com>2014-05-12 15:46:57 +0530
committerNiels de Vos <ndevos@redhat.com>2014-05-12 08:14:52 -0700
commit0c87b67ba9659a2d029d8136835331301b7b6ceb (patch)
treee5240e57b3dfe55ef312aa9aa315e90e023347d2 /rpc
parent29a5a7642d1762f2336ef8e89b81039e25810e1a (diff)
libgfapi: Added support to fetch volume info from glusterd and store in glfs object.
Defined new APIs in the libgfapi module, given a glfs object, * to send handshake RPC call to glusterd process to fetch UUID of the volume * store it in the glusterfs_context linked to the glfs object. * to parse UUID from its cannonical string format into 16-byte array before sending it to the libgfapi users. Defined a RPC call in glusterd which can be used to query volume related info by other processes using 'clnt_handshake_procs'. Note - Currently this RPC call to glusterd process is used only to fetch UUID. But it can be extended to get other volume related structures as well. In addition to the above, defined a new variable to keep track of such handshake RPCs still in progress to make sure all the corresponding RPC callbacks have been processed before libgfapi returns the glfs object initialized. Also bumping up the GFAPI current version number since there is a new API "glfs_get_volume_id" defined and exposed by libgfapi as part of these changes. Cherry picked from commit 5adb10b9ac1c634334f29732e062b12d747ae8c5: > Change-Id: I303f76d7177d32d25bdb301b1dbcf5cd73f42807 > BUG: 1095775 > Signed-off-by: Soumya Koduri <skoduri@redhat.com> > Reviewed-on: http://review.gluster.org/7218 > Reviewed-by: Anand Avati <avati@redhat.com> > Reviewed-by: Harshavardhana <harsha@harshavardhana.net> > Tested-by: Gluster Build System <jenkins@build.gluster.com> > Reviewed-by: Vijay Bellur <vbellur@redhat.com> This change differs a little from the patch in the master branch: - libgfapi in 3.5 does not have glfs_get_volfile(), so there were some merge conflicts resolved, - libgfapi in 3.5 is not versioned, the configure.ac changes related to the versioning have been skipped, - in the master branch only the XDR .x files are available, release-3.5 requires a manual re-generation of the relates .h and .c files. Change-Id: I52c32d0e69a52a7f4285f74164bca6fd83c4f3b3 BUG: 1095775 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/7741 Reviewed-by: Niels de Vos <ndevos@redhat.com> Tested-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'rpc')
-rw-r--r--rpc/rpc-lib/src/protocol-common.h8
-rw-r--r--rpc/xdr/src/glusterfs3-xdr.c79
-rw-r--r--rpc/xdr/src/glusterfs3-xdr.h56
-rw-r--r--rpc/xdr/src/glusterfs3-xdr.x10
4 files changed, 109 insertions, 44 deletions
diff --git a/rpc/rpc-lib/src/protocol-common.h b/rpc/rpc-lib/src/protocol-common.h
index 5876a500bdf..d44de48377c 100644
--- a/rpc/rpc-lib/src/protocol-common.h
+++ b/rpc/rpc-lib/src/protocol-common.h
@@ -69,6 +69,7 @@ enum gf_handshake_procnum {
GF_HNDSK_PING,
GF_HNDSK_SET_LK_VER,
GF_HNDSK_EVENT_NOTIFY,
+ GF_HNDSK_GET_VOLUME_INFO,
GF_HNDSK_MAXVALUE,
};
@@ -238,6 +239,13 @@ struct gf_gsync_detailed_status_ {
typedef struct gf_gsync_detailed_status_ gf_gsync_status_t;
+enum gf_get_volume_info_type {
+ GF_GET_VOLUME_NONE, /* 0 */
+ GF_GET_VOLUME_UUID
+};
+
+typedef enum gf_get_volume_info_type gf_get_volume_info_type;
+
#define GLUSTER_HNDSK_PROGRAM 14398633 /* Completely random */
#define GLUSTER_HNDSK_VERSION 2 /* 0.0.2 */
diff --git a/rpc/xdr/src/glusterfs3-xdr.c b/rpc/xdr/src/glusterfs3-xdr.c
index 3205c551e5b..45efd860a0d 100644
--- a/rpc/xdr/src/glusterfs3-xdr.c
+++ b/rpc/xdr/src/glusterfs3-xdr.c
@@ -1587,44 +1587,41 @@ xdr_gfs3_discard_rsp (XDR *xdrs, gfs3_discard_rsp *objp)
bool_t
xdr_gfs3_zerofill_req (XDR *xdrs, gfs3_zerofill_req *objp)
{
- register int32_t *buf;
+ register int32_t *buf;
buf = NULL;
- if (!xdr_opaque (xdrs, objp->gfid, 16))
- return FALSE;
- if (!xdr_quad_t (xdrs, &objp->fd))
- return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->offset))
- return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->size))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->xdata.xdata_val,
- (u_int *) &objp->xdata.xdata_len, ~0))
- return FALSE;
- return TRUE;
+ if (!xdr_opaque (xdrs, objp->gfid, 16))
+ return FALSE;
+ if (!xdr_quad_t (xdrs, &objp->fd))
+ return FALSE;
+ if (!xdr_u_quad_t (xdrs, &objp->offset))
+ return FALSE;
+ if (!xdr_u_quad_t (xdrs, &objp->size))
+ return FALSE;
+ if (!xdr_bytes (xdrs, (char **)&objp->xdata.xdata_val, (u_int *) &objp->xdata.xdata_len, ~0))
+ return FALSE;
+ return TRUE;
}
bool_t
xdr_gfs3_zerofill_rsp (XDR *xdrs, gfs3_zerofill_rsp *objp)
{
- register int32_t *buf;
+ register int32_t *buf;
buf = NULL;
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_gf_iatt (xdrs, &objp->statpre))
- return FALSE;
- if (!xdr_gf_iatt (xdrs, &objp->statpost))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->xdata.xdata_val,
- (u_int *) &objp->xdata.xdata_len, ~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_gf_iatt (xdrs, &objp->statpre))
+ return FALSE;
+ if (!xdr_gf_iatt (xdrs, &objp->statpost))
+ return FALSE;
+ if (!xdr_bytes (xdrs, (char **)&objp->xdata.xdata_val, (u_int *) &objp->xdata.xdata_len, ~0))
+ return FALSE;
+ return TRUE;
}
-
bool_t
xdr_gfs3_rchecksum_req (XDR *xdrs, gfs3_rchecksum_req *objp)
{
@@ -1763,6 +1760,34 @@ xdr_gf_getspec_rsp (XDR *xdrs, gf_getspec_rsp *objp)
}
bool_t
+xdr_gf_get_volume_info_req (XDR *xdrs, gf_get_volume_info_req *objp)
+{
+ register int32_t *buf;
+ buf = NULL;
+
+ if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_gf_get_volume_info_rsp (XDR *xdrs, gf_get_volume_info_rsp *objp)
+{
+ register int32_t *buf;
+ buf = NULL;
+
+ if (!xdr_int (xdrs, &objp->op_ret))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->op_errno))
+ return FALSE;
+ if (!xdr_string (xdrs, &objp->op_errstr, ~0))
+ return FALSE;
+ if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
xdr_gf_mgmt_hndsk_req (XDR *xdrs, gf_mgmt_hndsk_req *objp)
{
register int32_t *buf;
diff --git a/rpc/xdr/src/glusterfs3-xdr.h b/rpc/xdr/src/glusterfs3-xdr.h
index 13566e69447..ac74cca5cc1 100644
--- a/rpc/xdr/src/glusterfs3-xdr.h
+++ b/rpc/xdr/src/glusterfs3-xdr.h
@@ -937,30 +937,29 @@ struct gfs3_discard_rsp {
typedef struct gfs3_discard_rsp gfs3_discard_rsp;
struct gfs3_zerofill_req {
- char gfid[16];
- quad_t fd;
- u_quad_t offset;
- u_quad_t size;
- struct {
- u_int xdata_len;
- char *xdata_val;
- } xdata;
+ char gfid[16];
+ quad_t fd;
+ u_quad_t offset;
+ u_quad_t size;
+ struct {
+ u_int xdata_len;
+ char *xdata_val;
+ } xdata;
};
typedef struct gfs3_zerofill_req gfs3_zerofill_req;
struct gfs3_zerofill_rsp {
- int op_ret;
- int op_errno;
- struct gf_iatt statpre;
- struct gf_iatt statpost;
- struct {
- u_int xdata_len;
- char *xdata_val;
- } xdata;
+ int op_ret;
+ int op_errno;
+ struct gf_iatt statpre;
+ struct gf_iatt statpost;
+ struct {
+ u_int xdata_len;
+ char *xdata_val;
+ } xdata;
};
typedef struct gfs3_zerofill_rsp gfs3_zerofill_rsp;
-
struct gfs3_rchecksum_req {
quad_t fd;
u_quad_t offset;
@@ -1026,6 +1025,25 @@ struct gf_getspec_rsp {
};
typedef struct gf_getspec_rsp gf_getspec_rsp;
+struct gf_get_volume_info_req {
+ struct {
+ u_int dict_len;
+ char *dict_val;
+ } dict;
+};
+typedef struct gf_get_volume_info_req gf_get_volume_info_req;
+
+struct gf_get_volume_info_rsp {
+ int op_ret;
+ int op_errno;
+ char *op_errstr;
+ struct {
+ u_int dict_len;
+ char *dict_val;
+ } dict;
+};
+typedef struct gf_get_volume_info_rsp gf_get_volume_info_rsp;
+
struct gf_mgmt_hndsk_req {
struct {
u_int hndsk_len;
@@ -1268,6 +1286,8 @@ extern bool_t xdr_gf_setvolume_req (XDR *, gf_setvolume_req*);
extern bool_t xdr_gf_setvolume_rsp (XDR *, gf_setvolume_rsp*);
extern bool_t xdr_gf_getspec_req (XDR *, gf_getspec_req*);
extern bool_t xdr_gf_getspec_rsp (XDR *, gf_getspec_rsp*);
+extern bool_t xdr_gf_get_volume_info_req (XDR *, gf_get_volume_info_req*);
+extern bool_t xdr_gf_get_volume_info_rsp (XDR *, gf_get_volume_info_rsp*);
extern bool_t xdr_gf_mgmt_hndsk_req (XDR *, gf_mgmt_hndsk_req*);
extern bool_t xdr_gf_mgmt_hndsk_rsp (XDR *, gf_mgmt_hndsk_rsp*);
extern bool_t xdr_gf_log_req (XDR *, gf_log_req*);
@@ -1368,6 +1388,8 @@ extern bool_t xdr_gf_setvolume_req ();
extern bool_t xdr_gf_setvolume_rsp ();
extern bool_t xdr_gf_getspec_req ();
extern bool_t xdr_gf_getspec_rsp ();
+extern bool_t xdr_gf_get_volume_info_req ();
+extern bool_t xdr_gf_get_volume_info_rsp ();
extern bool_t xdr_gf_mgmt_hndsk_req ();
extern bool_t xdr_gf_mgmt_hndsk_rsp ();
extern bool_t xdr_gf_log_req ();
diff --git a/rpc/xdr/src/glusterfs3-xdr.x b/rpc/xdr/src/glusterfs3-xdr.x
index 1edbda3ada9..1c6bf4be244 100644
--- a/rpc/xdr/src/glusterfs3-xdr.x
+++ b/rpc/xdr/src/glusterfs3-xdr.x
@@ -653,6 +653,16 @@ struct gfs3_fstat_req {
opaque xdata<>; /* Extra data */
} ;
+ struct gf_get_volume_info_req {
+ opaque dict<>; /* Extra data */
+} ;
+ struct gf_get_volume_info_rsp {
+ int op_ret;
+ int op_errno;
+ string op_errstr<>;
+ opaque dict<>; /* Extra data */
+} ;
+
struct gf_mgmt_hndsk_req {
opaque hndsk<>;
} ;