From 00e247ee44067f2b3e7ca5f7e6dc2f7934c97181 Mon Sep 17 00:00:00 2001 From: Santosh Kumar Pradhan Date: Wed, 9 Apr 2014 10:19:43 +0530 Subject: gNFS: Support wildcard in RPC auth allow/reject RFE: Support wildcard in "nfs.rpc-auth-allow" and "nfs.rpc-auth-reject". e.g. *.redhat.com 192.168.1[1-5].* 192.168.1[1-5].*, *.redhat.com, 192.168.21.9 Along with wildcard, support for subnetwork or IP range e.g. 192.168.10.23/24 The option will be validated for following categories: 1) Anonymous i.e. "*" 2) Wildcard pattern i.e. string containing any ('*', '?', '[') 3) IPv4 address 4) IPv6 address 5) FQDN 6) subnetwork or IPv4 range Currently this does not support IPv6 subnetwork. Change-Id: Iac8caf5e490c8174d61111dad47fd547d4f67bf4 BUG: 1086097 Signed-off-by: Santosh Kumar Pradhan Reviewed-on: http://review.gluster.org/7485 Reviewed-by: Poornima G Reviewed-by: Harshavardhana Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- rpc/rpc-lib/src/rpcsvc.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 2 deletions(-) (limited to 'rpc/rpc-lib') diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c index 8be64c18a..34ee6f21b 100644 --- a/rpc/rpc-lib/src/rpcsvc.c +++ b/rpc/rpc-lib/src/rpcsvc.c @@ -59,6 +59,9 @@ int rpcsvc_notify (rpc_transport_t *trans, void *mydata, rpc_transport_event_t event, void *data, ...); +static int +match_subnet_v4 (const char *addrtok, const char *ipaddr); + rpcsvc_notify_wrapper_t * rpcsvc_notify_wrapper_alloc (void) { @@ -2181,6 +2184,13 @@ rpcsvc_transport_peer_check_search (dict_t *options, char *pattern, goto err; } + /* Compare IPv4 subnetwork */ + if (strchr (addrtok, '/')) { + ret = match_subnet_v4 (addrtok, ip); + if (ret == 0) + goto err; + } + addrtok = strtok_r (NULL, ",", &svptr); } @@ -2327,8 +2337,20 @@ rpcsvc_auth_check (rpcsvc_t *svc, char *volname, ret = dict_get_str (options, srchstr, &reject_str); GF_FREE (srchstr); - if (reject_str == NULL && !strcmp ("*", allow_str)) - return RPCSVC_AUTH_ACCEPT; + + /* + * If "reject_str" is being set as '*' (anonymous), then NFS-server + * would reject everything. If the "reject_str" is not set and + * "allow_str" is set as '*' (anonymous), then NFS-server would + * accept mount requests from all clients. + */ + if (reject_str != NULL) { + if (!strcmp ("*", reject_str)) + return RPCSVC_AUTH_REJECT; + } else { + if (!strcmp ("*", allow_str)) + return RPCSVC_AUTH_ACCEPT; + } /* Non-default rule, authenticate */ if (!get_host_name (client_ip, &ip)) @@ -2461,6 +2483,71 @@ out: return addrstr; } +/* + * match_subnet_v4() takes subnetwork address pattern and checks + * if the target IPv4 address has the same network address with + * the help of network mask. + * + * Returns 0 for SUCCESS and -1 otherwise. + * + * NB: Validation of subnetwork address pattern is not required + * as it's already being done at the time of CLI SET. + */ +static int +match_subnet_v4 (const char *addrtok, const char *ipaddr) +{ + char *slash = NULL; + char *netaddr = NULL; + long prefixlen = -1; + int ret = -1; + uint32_t shift = 0; + struct sockaddr_in sin1 = {0, }; + struct sockaddr_in sin2 = {0, }; + struct sockaddr_in mask = {0, }; + + /* Copy the input */ + netaddr = gf_strdup (addrtok); + if (netaddr == NULL) /* ENOMEM */ + goto out; + + /* Find the network socket addr of target */ + if (inet_pton (AF_INET, ipaddr, &sin1.sin_addr) == 0) + goto out; + + /* Find the network socket addr of subnet pattern */ + slash = strchr (netaddr, '/'); + *slash = '\0'; + if (inet_pton (AF_INET, netaddr, &sin2.sin_addr) == 0) + goto out; + + /* + * Find the network mask in network byte order. + * NB: 32 : Max len of IPv4 address. + */ + prefixlen = atoi (slash + 1); + shift = 32 - (uint32_t)prefixlen; + mask.sin_addr.s_addr = htonl ((uint32_t)~0 << shift); + + /* + * Check if both have same network address. + * Extract the network address from the IP addr by applying the + * network mask. If they match, return SUCCESS. i.e. + * + * (x == y) <=> (x ^ y == 0) + * (x & y) ^ (x & z) <=> x & (y ^ z) + * + * ((ip1 & mask) == (ip2 & mask)) <=> ((mask & (ip1 ^ ip2)) == 0) + */ + if (((mask.sin_addr.s_addr) & + (sin1.sin_addr.s_addr ^ sin2.sin_addr.s_addr)) != 0) + goto out; + + ret = 0; /* SUCCESS */ +out: + GF_FREE (netaddr); + return ret; +} + rpcsvc_actor_t gluster_dump_actors[] = { [GF_DUMP_NULL] = {"NULL", GF_DUMP_NULL, NULL, NULL, 0, DRC_NA}, -- cgit From a3cb38e3edf005bef73da4c9cfd958474a14d50f Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 17 Apr 2014 15:54:34 -0700 Subject: build: MacOSX Porting fixes git@forge.gluster.org:~schafdog/glusterfs-core/osx-glusterfs Working functionality on MacOSX - GlusterD (management daemon) - GlusterCLI (management cli) - GlusterFS FUSE (using OSXFUSE) - GlusterNFS (without NLM - issues with rpc.statd) Change-Id: I20193d3f8904388e47344e523b3787dbeab044ac BUG: 1089172 Signed-off-by: Harshavardhana Signed-off-by: Dennis Schafroth Tested-by: Harshavardhana Tested-by: Dennis Schafroth Reviewed-on: http://review.gluster.org/7503 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- rpc/rpc-lib/src/Makefile.am | 4 ++-- rpc/rpc-lib/src/rpc-clnt.c | 7 ++++--- rpc/rpc-lib/src/rpc-drc.c | 2 +- rpc/rpc-lib/src/rpcsvc.c | 39 +++++++++++++++++---------------------- rpc/rpc-lib/src/xdr-common.h | 6 ++++-- rpc/rpc-lib/src/xdr-rpc.h | 17 +++++++++++++++++ 6 files changed, 45 insertions(+), 30 deletions(-) (limited to 'rpc/rpc-lib') diff --git a/rpc/rpc-lib/src/Makefile.am b/rpc/rpc-lib/src/Makefile.am index 4cdeaad0b..ee2f27b25 100644 --- a/rpc/rpc-lib/src/Makefile.am +++ b/rpc/rpc-lib/src/Makefile.am @@ -2,10 +2,10 @@ lib_LTLIBRARIES = libgfrpc.la libgfrpc_la_SOURCES = auth-unix.c rpcsvc-auth.c rpcsvc.c auth-null.c \ rpc-transport.c xdr-rpc.c xdr-rpcclnt.c rpc-clnt.c auth-glusterfs.c \ - rpc-drc.c + rpc-drc.c $(CONTRIBDIR)/sunrpc/xdr_sizeof.c libgfrpc_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la -libgfrpc_la_LDFLAGS = -version-info $(LIBGFRPC_LT_VERSION) +libgfrpc_la_LDFLAGS = -version-info $(LIBGFRPC_LT_VERSION) $(GF_LDFLAGS) noinst_HEADERS = rpcsvc.h rpc-transport.h xdr-common.h xdr-rpc.h xdr-rpcclnt.h \ rpc-clnt.h rpcsvc-common.h protocol-common.h rpc-drc.h diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c index e095c55b3..3106342e9 100644 --- a/rpc/rpc-lib/src/rpc-clnt.c +++ b/rpc/rpc-lib/src/rpc-clnt.c @@ -717,8 +717,9 @@ rpc_clnt_handle_cbk (struct rpc_clnt *clnt, rpc_transport_pollin_t *msg) } gf_log (clnt->conn.name, GF_LOG_TRACE, - "received rpc message (XID: 0x%lx, " - "Ver: %ld, Program: %ld, ProgVers: %ld, Proc: %ld) " + "receivd rpc message (XID: 0x%" GF_PRI_RPC_XID ", " + "Ver: %" GF_PRI_RPC_VERSION ", Program: %" GF_PRI_RPC_PROG_ID ", " + "ProgVers: %" GF_PRI_RPC_PROG_VERS ", Proc: %" GF_PRI_RPC_PROC ") " "from rpc-transport (%s)", rpc_call_xid (&rpcmsg), rpc_call_rpcvers (&rpcmsg), rpc_call_program (&rpcmsg), rpc_call_progver (&rpcmsg), rpc_call_progproc (&rpcmsg), @@ -1141,7 +1142,7 @@ xdr_serialize_glusterfs_auth (char *dest, struct auth_glusterfs_parms_v2 *au) { ssize_t ret = -1; XDR xdr; - uint64_t ngroups = 0; + u_long ngroups = 0; int max_groups = 0; if ((!dest) || (!au)) diff --git a/rpc/rpc-lib/src/rpc-drc.c b/rpc/rpc-lib/src/rpc-drc.c index 7e77e038e..0babb9bc4 100644 --- a/rpc/rpc-lib/src/rpc-drc.c +++ b/rpc/rpc-lib/src/rpc-drc.c @@ -460,7 +460,7 @@ rpcsvc_vacate_drc_entries (rpcsvc_drc_globals_t *drc) client = reply->client; - (void *)rb_delete (client->rbtree, reply); + rb_delete (client->rbtree, reply); rpcsvc_drc_op_destroy (drc, reply); rpcsvc_drc_client_unref (drc, client); diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c index 34ee6f21b..f2cdfb238 100644 --- a/rpc/rpc-lib/src/rpcsvc.c +++ b/rpc/rpc-lib/src/rpcsvc.c @@ -423,9 +423,10 @@ rpcsvc_request_create (rpcsvc_t *svc, rpc_transport_t *trans, ret = -1; rpcsvc_request_init (svc, trans, &rpcmsg, progmsg, msg, req); - gf_log (GF_RPCSVC, GF_LOG_TRACE, "received rpc-message (XID: 0x%lx, " - "Ver: %ld, Program: %ld, ProgVers: %ld, Proc: %ld) from" - " rpc-transport (%s)", rpc_call_xid (&rpcmsg), + gf_log (GF_RPCSVC, GF_LOG_TRACE, "received rpc-message " + "(XID: 0x%" GF_PRI_RPC_XID ", Ver: %" GF_PRI_RPC_VERSION ", Program: %" GF_PRI_RPC_PROG_ID ", " + "ProgVers: %" GF_PRI_RPC_PROG_VERS ", Proc: %" GF_PRI_RPC_PROC ") " + "from rpc-transport (%s)", rpc_call_xid (&rpcmsg), rpc_call_rpcvers (&rpcmsg), rpc_call_program (&rpcmsg), rpc_call_progver (&rpcmsg), rpc_call_progproc (&rpcmsg), trans->name); @@ -434,8 +435,9 @@ rpcsvc_request_create (rpcsvc_t *svc, rpc_transport_t *trans, /* LOG- TODO: print rpc version, also print the peerinfo from transport */ gf_log (GF_RPCSVC, GF_LOG_ERROR, "RPC version not supported " - "(XID: 0x%lx, Ver: %ld, Prog: %ld, ProgVers: %ld, " - "Proc: %ld) from trans (%s)", rpc_call_xid (&rpcmsg), + "(XID: 0x%" GF_PRI_RPC_XID ", Ver: %" GF_PRI_RPC_VERSION ", Program: %" GF_PRI_RPC_PROG_ID ", " + "ProgVers: %" GF_PRI_RPC_PROG_VERS ", Proc: %" GF_PRI_RPC_PROC ") " + "from trans (%s)", rpc_call_xid (&rpcmsg), rpc_call_rpcvers (&rpcmsg), rpc_call_program (&rpcmsg), rpc_call_progver (&rpcmsg), rpc_call_progproc (&rpcmsg), trans->name); @@ -451,8 +453,9 @@ rpcsvc_request_create (rpcsvc_t *svc, rpc_transport_t *trans, */ rpcsvc_request_seterr (req, AUTH_ERROR); gf_log (GF_RPCSVC, GF_LOG_ERROR, "auth failed on request. " - "(XID: 0x%lx, Ver: %ld, Prog: %ld, ProgVers: %ld, " - "Proc: %ld) from trans (%s)", rpc_call_xid (&rpcmsg), + "(XID: 0x%" GF_PRI_RPC_XID ", Ver: %" GF_PRI_RPC_VERSION ", Program: %" GF_PRI_RPC_PROG_ID ", " + "ProgVers: %" GF_PRI_RPC_PROG_VERS ", Proc: %" GF_PRI_RPC_PROC ") " + "from trans (%s)", rpc_call_xid (&rpcmsg), rpc_call_rpcvers (&rpcmsg), rpc_call_program (&rpcmsg), rpc_call_progver (&rpcmsg), rpc_call_progproc (&rpcmsg), trans->name); @@ -797,15 +800,9 @@ err: return txrecord; } -static inline int -rpcsvc_get_callid (rpcsvc_t *rpc) -{ - return GF_UNIVERSAL_ANSWER; -} - int rpcsvc_fill_callback (int prognum, int progver, int procnum, int payload, - uint64_t xid, struct rpc_msg *request) + uint32_t xid, struct rpc_msg *request) { int ret = -1; @@ -870,9 +867,9 @@ out: return txrecord; } -struct iobuf * +static struct iobuf * rpcsvc_callback_build_record (rpcsvc_t *rpc, int prognum, int progver, - int procnum, size_t payload, uint64_t xid, + int procnum, size_t payload, u_long xid, struct iovec *recbuf) { struct rpc_msg request = {0, }; @@ -892,7 +889,7 @@ rpcsvc_callback_build_record (rpcsvc_t *rpc, int prognum, int progver, &request); if (ret == -1) { gf_log ("rpcsvc", GF_LOG_WARNING, "cannot build a rpc-request " - "xid (%"PRIu64")", xid); + "xid (%" GF_PRI_RPC_XID ")", xid); goto out; } @@ -939,7 +936,6 @@ rpcsvc_callback_submit (rpcsvc_t *rpc, rpc_transport_t *trans, rpc_transport_req_t req; int ret = -1; int proglen = 0; - uint64_t callid = 0; if (!rpc) { goto out; @@ -947,15 +943,14 @@ rpcsvc_callback_submit (rpcsvc_t *rpc, rpc_transport_t *trans, memset (&req, 0, sizeof (req)); - callid = rpcsvc_get_callid (rpc); - if (proghdr) { proglen += iov_length (proghdr, proghdrcount); } request_iob = rpcsvc_callback_build_record (rpc, prog->prognum, prog->progver, procnum, - proglen, callid, + proglen, + GF_UNIVERSAL_ANSWER, &rpchdr); if (!request_iob) { gf_log ("rpcsvc", GF_LOG_WARNING, @@ -1256,7 +1251,7 @@ rpcsvc_program_register_portmap (rpcsvc_program_t *newprog, uint32_t port) if (!(pmap_set (newprog->prognum, newprog->progver, IPPROTO_TCP, port))) { gf_log (GF_RPCSVC, GF_LOG_ERROR, "Could not register with" - " portmap"); + " portmap %d %d %u", newprog->prognum, newprog->progver, port); goto out; } diff --git a/rpc/rpc-lib/src/xdr-common.h b/rpc/rpc-lib/src/xdr-common.h index f221192ad..78c72e509 100644 --- a/rpc/rpc-lib/src/xdr-common.h +++ b/rpc/rpc-lib/src/xdr-common.h @@ -18,8 +18,8 @@ #include #include -#include #include +#include #include #ifdef __NetBSD__ @@ -68,7 +68,9 @@ enum gf_dump_procnum { #define xdr_u_quad_t xdr_u_int64_t #define xdr_quad_t xdr_int64_t #define xdr_uint32_t xdr_u_int32_t -#define uint64_t u_int64_t +#define xdr_uint64_t xdr_u_int64_t + +unsigned long xdr_sizeof (xdrproc_t func, void *data); #endif #if defined(__NetBSD__) diff --git a/rpc/rpc-lib/src/xdr-rpc.h b/rpc/rpc-lib/src/xdr-rpc.h index f5f4a941e..4663ef796 100644 --- a/rpc/rpc-lib/src/xdr-rpc.h +++ b/rpc/rpc-lib/src/xdr-rpc.h @@ -78,4 +78,21 @@ xdr_to_auth_unix_cred (char *msgbuf, int msglen, struct authunix_parms *au, #define rpc_call_verf_flavour(call) (rpc_opaque_auth_flavour ((&(call)->ru.RM_cmb.cb_verf))) #define rpc_call_verf_len(call) (rpc_opaque_auth_len ((&(call)->ru.RM_cmb.cb_verf))) + +#ifdef GF_DARWIN_HOST_OS +#define GF_PRI_RPC_XID PRIu32 +#define GF_PRI_RPC_VERSION PRIu32 +#define GF_PRI_RPC_PROG_ID PRIu32 +#define GF_PRI_RPC_PROG_VERS PRIu32 +#define GF_PRI_RPC_PROC PRIu32 +#define GF_PRI_RPC_PROC_VERSION PRIu32 +#else +#define GF_PRI_RPC_XID PRIu64 +#define GF_PRI_RPC_VERSION PRIu64 +#define GF_PRI_RPC_PROG_ID PRIu64 +#define GF_PRI_RPC_PROG_VERS PRIu64 +#define GF_PRI_RPC_PROC PRIu64 +#define GF_PRI_RPC_PROC_VERSION PRIu64 +#endif + #endif -- cgit From bc434b3ca961757ade8c6093f4ff0dbe4b3a4672 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Wed, 23 Apr 2014 14:05:10 +0530 Subject: rpcsvc: Ignore INODELK/ENTRYLK/LK for throttling Problem: When iozone is in progress, number of blocking inodelks sometimes becomes greater than the threshold number of rpc requests allowed for that client (RPCSVC_DEFAULT_OUTSTANDING_RPC_LIMIT). Subsequent requests from that client will not be read until all the outstanding requests are processed and replied to. But because no more requests are read from that client, unlocks on the already granted locks will never come thus the number of outstanding requests would never come down. This leads to a ping-timeout on the client. Fix: Do not account INODELK/ENTRYLK/LK for throttling Change-Id: I59c6b54e7ec24ed7375ff977e817a9cb73469806 BUG: 1089470 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/7531 Tested-by: Gluster Build System Reviewed-by: Krutika Dhananjay Reviewed-by: Anand Avati --- rpc/rpc-lib/src/rpcsvc.c | 70 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 16 deletions(-) (limited to 'rpc/rpc-lib') diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c index f2cdfb238..1c13048f2 100644 --- a/rpc/rpc-lib/src/rpcsvc.c +++ b/rpc/rpc-lib/src/rpcsvc.c @@ -29,6 +29,7 @@ #include "rpc-common-xdr.h" #include "syncop.h" #include "rpc-drc.h" +#include "protocol-common.h" #include #include @@ -132,32 +133,67 @@ rpcsvc_get_program_vector_sizer (rpcsvc_t *svc, uint32_t prognum, return NULL; } +gf_boolean_t +rpcsvc_can_outstanding_req_be_ignored (rpcsvc_request_t *req) +{ + /* + * If outstanding_rpc_limit is reached because of blocked locks and + * throttling is attempted then no unlock requests will be received. So + * the outstanding request count will never change i.e. it will always + * be equal to the limit. This also leads to ping timer expiry on + * client. + */ + + /* + * This is a hack and a necessity until grantedlock == fop completion. + * Ideally if we get a blocking lock request which cannot be granted + * right now, we should unwind the fop saying “request registered, will + * notify you when granted”, which is very hard to implement at the + * moment. Until we bring in such mechanism, we will need to live with + * not rate-limiting INODELK/ENTRYLK/LK fops + */ + + if ((req->prognum == GLUSTER_FOP_PROGRAM) && + (req->progver == GLUSTER_FOP_VERSION)) { + if ((req->procnum == GFS3_OP_INODELK) || + (req->procnum == GFS3_OP_FINODELK) || + (req->procnum == GFS3_OP_ENTRYLK) || + (req->procnum == GFS3_OP_FENTRYLK) || + (req->procnum == GFS3_OP_LK)) + return _gf_true; + } + return _gf_false; +} + int -rpcsvc_request_outstanding (rpcsvc_t *svc, rpc_transport_t *trans, int delta) +rpcsvc_request_outstanding (rpcsvc_request_t *req, int delta) { int ret = 0; int old_count = 0; int new_count = 0; int limit = 0; - pthread_mutex_lock (&trans->lock); + if (rpcsvc_can_outstanding_req_be_ignored (req)) + return 0; + + pthread_mutex_lock (&req->trans->lock); { - limit = svc->outstanding_rpc_limit; + limit = req->svc->outstanding_rpc_limit; if (!limit) goto unlock; - old_count = trans->outstanding_rpc_count; - trans->outstanding_rpc_count += delta; - new_count = trans->outstanding_rpc_count; + old_count = req->trans->outstanding_rpc_count; + req->trans->outstanding_rpc_count += delta; + new_count = req->trans->outstanding_rpc_count; if (old_count <= limit && new_count > limit) - ret = rpc_transport_throttle (trans, _gf_true); + ret = rpc_transport_throttle (req->trans, _gf_true); if (old_count > limit && new_count <= limit) - ret = rpc_transport_throttle (trans, _gf_false); + ret = rpc_transport_throttle (req->trans, _gf_false); } unlock: - pthread_mutex_unlock (&trans->lock); + pthread_mutex_unlock (&req->trans->lock); return ret; } @@ -318,7 +354,8 @@ rpcsvc_request_destroy (rpcsvc_request_t *req) to the client. It is time to decrement the outstanding request counter by 1. */ - rpcsvc_request_outstanding (req->svc, req->trans, -1); + if (req->prognum) //Only for initialized requests + rpcsvc_request_outstanding (req, -1); rpc_transport_unref (req->trans); @@ -400,12 +437,6 @@ rpcsvc_request_create (rpcsvc_t *svc, rpc_transport_t *trans, goto err; } - /* We just received a new request from the wire. Account for - it in the outsanding request counter to make sure we don't - ingest too many concurrent requests from the same client. - */ - ret = rpcsvc_request_outstanding (svc, trans, +1); - msgbuf = msg->vector[0].iov_base; msglen = msg->vector[0].iov_len; @@ -431,6 +462,13 @@ rpcsvc_request_create (rpcsvc_t *svc, rpc_transport_t *trans, rpc_call_progver (&rpcmsg), rpc_call_progproc (&rpcmsg), trans->name); + /* We just received a new request from the wire. Account for + it in the outsanding request counter to make sure we don't + ingest too many concurrent requests from the same client. + */ + if (req->prognum) //Only for initialized requests + ret = rpcsvc_request_outstanding (req, +1); + if (rpc_call_rpcvers (&rpcmsg) != 2) { /* LOG- TODO: print rpc version, also print the peerinfo from transport */ -- cgit From 9819fcedf10f1430d4969c86e6df4dfe975b7dcf Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 22 Apr 2014 13:27:35 -0700 Subject: rpcgen: Remove autogenerated files instead build on demand Avoid modifying autogenerated files and keeping them in repository - autogenerate them on demand from ".x" files Change-Id: I2cdb1fe9b99768ceb80a8cb100fa00bd1d8fe2c6 BUG: 1090807 Signed-off-by: Harshavardhana Reviewed-on: http://review.gluster.org/7526 Tested-by: Gluster Build System Reviewed-by: Niels de Vos Reviewed-by: Anand Avati --- rpc/rpc-lib/src/xdr-common.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'rpc/rpc-lib') diff --git a/rpc/rpc-lib/src/xdr-common.h b/rpc/rpc-lib/src/xdr-common.h index 78c72e509..631f4b284 100644 --- a/rpc/rpc-lib/src/xdr-common.h +++ b/rpc/rpc-lib/src/xdr-common.h @@ -64,12 +64,17 @@ enum gf_dump_procnum { #define GF_AUTH_GLUSTERFS_MAX_LKOWNER(groups_len) \ (95 - groups_len) -#if GF_DARWIN_HOST_OS +#ifdef GF_LINUX_HOST_OS +#define xdr_u_int32_t xdr_uint32_t +#define xdr_u_int64_t xdr_uint64_t +#endif + +#ifdef GF_DARWIN_HOST_OS #define xdr_u_quad_t xdr_u_int64_t #define xdr_quad_t xdr_int64_t #define xdr_uint32_t xdr_u_int32_t #define xdr_uint64_t xdr_u_int64_t - +#define uint64_t u_int64_t unsigned long xdr_sizeof (xdrproc_t func, void *data); #endif @@ -80,13 +85,11 @@ unsigned long xdr_sizeof (xdrproc_t func, void *data); #define xdr_uint64_t xdr_u_int64_t #endif - -#if GF_SOLARIS_HOST_OS +#ifdef GF_SOLARIS_HOST_OS #define u_quad_t uint64_t #define quad_t int64_t #define xdr_u_quad_t xdr_uint64_t #define xdr_quad_t xdr_int64_t -#define xdr_uint32_t xdr_uint32_t #endif /* Returns the address of the byte that follows the -- cgit From 0af287791f0d50b5d2975cb2e2c902c797b05860 Mon Sep 17 00:00:00 2001 From: Avra Sengupta Date: Wed, 2 Apr 2014 05:39:22 +0000 Subject: glusterd/snapshot-handshake: Perform handshake of missed_snaps_list. In a handshake, create a union of the missed_snap_lists of the two peers. If an entry is present, its no op. If an entry is pendng, and the peer entry is done, mark own entry as done. If an entry is done, and the peer ertry is pending, its a no-op. If its a new entry, add it. Change-Id: Idbfa49cc34871631ba8c7c56d915666311024887 BUG: 1061685 Signed-off-by: Avra Sengupta Reviewed-on: http://review.gluster.org/7453 Tested-by: Gluster Build System Reviewed-by: Rajesh Joseph Reviewed-by: Vijay Bellur --- rpc/rpc-lib/src/protocol-common.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'rpc/rpc-lib') diff --git a/rpc/rpc-lib/src/protocol-common.h b/rpc/rpc-lib/src/protocol-common.h index 97d47c433..8129b8131 100644 --- a/rpc/rpc-lib/src/protocol-common.h +++ b/rpc/rpc-lib/src/protocol-common.h @@ -107,7 +107,8 @@ enum gf_probe_resp { GF_PROBE_SAME_UUID, GF_PROBE_UNKNOWN_PEER, GF_PROBE_ADD_FAILED, - GF_PROBE_QUORUM_NOT_MET + GF_PROBE_QUORUM_NOT_MET, + GF_PROBE_MISSED_SNAP_CONFLICT, }; enum gf_deprobe_resp { -- cgit From 49733d307f010bfeb3d2440402ff51a5366262f5 Mon Sep 17 00:00:00 2001 From: Yuan Ding Date: Mon, 21 Apr 2014 22:10:13 +0800 Subject: gNFS: gNFS drc cache failed to detecte duplicates. After the drc cache get full, message "DRC failed to detect duplicates" keep printed in the log. The root cause is drc_compare_reqs use the wrong compare type. This function should use type drc_cache_op_t as its input type. Since all rbtree related code (except function rpcsvc_drc_lookup) in drc cache pass drc_cache_op_t as compare type. Only rpcsvc_drc_lookup use type rpcsvc_request_t. It has been modified too. Change-Id: I925c097debe6b82f267986961fd4e7755f3de9af BUG: 1089676 Signed-off-by: Yuan Ding Reviewed-on: http://review.gluster.org/7519 Reviewed-by: Niels de Vos Reviewed-by: Santosh Pradhan Tested-by: Gluster Build System Reviewed-by: Anand Avati --- rpc/rpc-lib/src/rpc-drc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'rpc/rpc-lib') diff --git a/rpc/rpc-lib/src/rpc-drc.c b/rpc/rpc-lib/src/rpc-drc.c index 0babb9bc4..bc37324d3 100644 --- a/rpc/rpc-lib/src/rpc-drc.c +++ b/rpc/rpc-lib/src/rpc-drc.c @@ -127,14 +127,14 @@ int drc_compare_reqs (const void *item, const void *rb_node_data, void *param) { int ret = -1; - rpcsvc_request_t *req = NULL; + drc_cached_op_t *req = NULL; drc_cached_op_t *reply = NULL; GF_ASSERT (item); GF_ASSERT (rb_node_data); GF_ASSERT (param); - req = (rpcsvc_request_t *)item; + req = (drc_cached_op_t *)item; reply = (drc_cached_op_t *)rb_node_data; ret = req->xid - reply->xid; @@ -143,7 +143,7 @@ drc_compare_reqs (const void *item, const void *rb_node_data, void *param) if (req->prognum == reply->prognum && req->procnum == reply->procnum && - req->progver == reply->progversion) + req->progversion == reply->progversion) return 0; return 1; @@ -331,6 +331,12 @@ rpcsvc_drc_lookup (rpcsvc_request_t *req) { drc_client_t *client = NULL; drc_cached_op_t *reply = NULL; + drc_cached_op_t new = { + .xid = req->xid, + .prognum = req->prognum, + .progversion = req->progver, + .procnum = req->procnum, + }; GF_ASSERT (req); @@ -347,7 +353,7 @@ rpcsvc_drc_lookup (rpcsvc_request_t *req) if (client->op_count == 0) goto out; - reply = rb_find (client->rbtree, req); + reply = rb_find (client->rbtree, &new); out: if (client) -- cgit From 54a5a42848870ee17b923c6c37d65fdfe4a5fec9 Mon Sep 17 00:00:00 2001 From: Avra Sengupta Date: Tue, 22 Apr 2014 00:52:57 +0000 Subject: glusterd/snapshot: Compare and update snapshots during peer handshake During a peer-handshake, after the volumes have synced, and the list of missed snapshots have synced, the node will perform the pending deletes and restores on this list. At this point, the current snapshot list in the node will be updated, and hence in case of conflicts arising during snapshot handshake, the peer hosting the bricks will be given precedence Likewise, if there will be a conflict, and both peers will be in the same state, i.e either both would be hosting bricks or both would not be hosting bricks, then a decision can't be taken and a peer-reject will happen. glusterd_compare_and_update_snap() implements the following algorithm to perform the above task: Step 1: Start. Step 2: Check if the peer is missing a delete on the said snap. If yes, goto step 6. Step 3: Check if there is a conflict between the peer's data and the local snap. If no, goto step 5. Step 4: As there is a conflict, check if both the peer and the local nodes are hosting bricks. Based on the results perform the following: Peer Hosts Bricks Local Node Hosts Bricks Action Yes Yes Goto Step 7 No No Goto Step 7 Yes No Goto Step 8 No Yes Goto Step 6 Step 5: Check if the local node is missing the peer's data. If yes, goto step 9. Step 6: It's a no-op. Goto step 10 Step 7: Peer Reject. Goto step 10 Step 8: Delete local node's data. Step 9: Accept Peer Data. Step 10: Stop Change-Id: I79be0f0f5f2a4f5c72277a4e77c2be732af432e1 BUG: 1061685 Signed-off-by: Avra Sengupta Reviewed-on: http://review.gluster.org/7525 Tested-by: Gluster Build System Reviewed-by: Krishnan Parthasarathi Reviewed-by: Rajesh Joseph Reviewed-by: Atin Mukherjee Reviewed-by: Vijay Bellur --- rpc/rpc-lib/src/protocol-common.h | 1 + 1 file changed, 1 insertion(+) (limited to 'rpc/rpc-lib') diff --git a/rpc/rpc-lib/src/protocol-common.h b/rpc/rpc-lib/src/protocol-common.h index 8129b8131..e4f7fbf3a 100644 --- a/rpc/rpc-lib/src/protocol-common.h +++ b/rpc/rpc-lib/src/protocol-common.h @@ -109,6 +109,7 @@ enum gf_probe_resp { GF_PROBE_ADD_FAILED, GF_PROBE_QUORUM_NOT_MET, GF_PROBE_MISSED_SNAP_CONFLICT, + GF_PROBE_SNAP_CONFLICT, }; enum gf_deprobe_resp { -- cgit