From 435e0a9cfd3df40498ca835ed573c994da2fc66b Mon Sep 17 00:00:00 2001 From: Milind Changire Date: Mon, 21 May 2018 12:16:42 +0530 Subject: [PATCH 279/282] Revert "rpc: make actor search parallel" This reverts commit 72dc3a3eff84c5e17bbc3bfddec9daf50338464f. > Reviewed-on: https://code.engineering.redhat.com/gerrit/131909 Change-Id: I0ce4f1c6c14f89031a31d5bb7ffb66ea16348cb9 BUG: 1558989 Signed-off-by: Milind Changire Reviewed-on: https://code.engineering.redhat.com/gerrit/139307 Tested-by: RHGS Build Bot Reviewed-by: Raghavendra Gowdappa Reviewed-by: Sunil Kumar Heggodu Gopala Acharya --- rpc/rpc-lib/src/rpcsvc-common.h | 2 +- rpc/rpc-lib/src/rpcsvc.c | 54 ++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/rpc/rpc-lib/src/rpcsvc-common.h b/rpc/rpc-lib/src/rpcsvc-common.h index ab715d3..dd95803 100644 --- a/rpc/rpc-lib/src/rpcsvc-common.h +++ b/rpc/rpc-lib/src/rpcsvc-common.h @@ -42,7 +42,7 @@ typedef struct rpcsvc_state { * other options. */ - pthread_rwlock_t rpclock; + pthread_mutex_t rpclock; unsigned int memfactor; diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c index fbd1071..31b5eb5 100644 --- a/rpc/rpc-lib/src/rpcsvc.c +++ b/rpc/rpc-lib/src/rpcsvc.c @@ -88,11 +88,11 @@ rpcsvc_listener_destroy (rpcsvc_listener_t *listener) goto listener_free; } - pthread_rwlock_wrlock (&svc->rpclock); + pthread_mutex_lock (&svc->rpclock); { list_del_init (&listener->list); } - pthread_rwlock_unlock (&svc->rpclock); + pthread_mutex_unlock (&svc->rpclock); listener_free: GF_FREE (listener); @@ -110,7 +110,7 @@ rpcsvc_get_program_vector_sizer (rpcsvc_t *svc, uint32_t prognum, if (!svc) return NULL; - pthread_rwlock_rdlock (&svc->rpclock); + pthread_mutex_lock (&svc->rpclock); { /* Find the matching RPC program from registered list */ list_for_each_entry (program, &svc->programs, program) { @@ -121,7 +121,7 @@ rpcsvc_get_program_vector_sizer (rpcsvc_t *svc, uint32_t prognum, } } } - pthread_rwlock_unlock (&svc->rpclock); + pthread_mutex_unlock (&svc->rpclock); if (found) { /* Make sure the requested procnum is supported by RPC prog */ @@ -237,7 +237,7 @@ rpcsvc_program_actor (rpcsvc_request_t *req) svc = req->svc; peername = req->trans->peerinfo.identifier; - pthread_rwlock_rdlock (&svc->rpclock); + pthread_mutex_lock (&svc->rpclock); { list_for_each_entry (program, &svc->programs, program) { if (program->prognum == req->prognum) { @@ -251,7 +251,7 @@ rpcsvc_program_actor (rpcsvc_request_t *req) } } } - pthread_rwlock_unlock (&svc->rpclock); + pthread_mutex_unlock (&svc->rpclock); if (!found) { if (err != PROG_MISMATCH) { @@ -735,7 +735,7 @@ rpcsvc_handle_disconnect (rpcsvc_t *svc, rpc_transport_t *trans) event = (trans->listener == NULL) ? RPCSVC_EVENT_LISTENER_DEAD : RPCSVC_EVENT_DISCONNECT; - pthread_rwlock_rdlock (&svc->rpclock); + pthread_mutex_lock (&svc->rpclock); { if (!svc->notify_count) goto unlock; @@ -755,7 +755,7 @@ rpcsvc_handle_disconnect (rpcsvc_t *svc, rpc_transport_t *trans) wrapper_count = i; } unlock: - pthread_rwlock_unlock (&svc->rpclock); + pthread_mutex_unlock (&svc->rpclock); if (wrappers) { for (i = 0; i < wrapper_count; i++) { @@ -1495,7 +1495,7 @@ rpcsvc_get_listener (rpcsvc_t *svc, uint16_t port, rpc_transport_t *trans) goto out; } - pthread_rwlock_rdlock (&svc->rpclock); + pthread_mutex_lock (&svc->rpclock); { list_for_each_entry (listener, &svc->listeners, list) { if (trans != NULL) { @@ -1521,7 +1521,7 @@ rpcsvc_get_listener (rpcsvc_t *svc, uint16_t port, rpc_transport_t *trans) } } } - pthread_rwlock_unlock (&svc->rpclock); + pthread_mutex_unlock (&svc->rpclock); if (!found) { listener = NULL; @@ -1566,7 +1566,7 @@ rpcsvc_program_unregister (rpcsvc_t *svc, rpcsvc_program_t *program) " program failed"); goto out; } - pthread_rwlock_rdlock (&svc->rpclock); + pthread_mutex_lock (&svc->rpclock); { list_for_each_entry (prog, &svc->programs, program) { if ((prog->prognum == program->prognum) @@ -1575,7 +1575,7 @@ rpcsvc_program_unregister (rpcsvc_t *svc, rpcsvc_program_t *program) } } } - pthread_rwlock_unlock (&svc->rpclock); + pthread_mutex_unlock (&svc->rpclock); if (prog == NULL) { ret = -1; @@ -1592,11 +1592,11 @@ rpcsvc_program_unregister (rpcsvc_t *svc, rpcsvc_program_t *program) goto out; } - pthread_rwlock_wrlock (&svc->rpclock); + pthread_mutex_lock (&svc->rpclock); { list_del_init (&prog->program); } - pthread_rwlock_unlock (&svc->rpclock); + pthread_mutex_unlock (&svc->rpclock); ret = 0; out: @@ -1655,11 +1655,11 @@ rpcsvc_listener_alloc (rpcsvc_t *svc, rpc_transport_t *trans) INIT_LIST_HEAD (&listener->list); - pthread_rwlock_wrlock (&svc->rpclock); + pthread_mutex_lock (&svc->rpclock); { list_add_tail (&listener->list, &svc->listeners); } - pthread_rwlock_unlock (&svc->rpclock); + pthread_mutex_unlock (&svc->rpclock); out: return listener; } @@ -1813,7 +1813,7 @@ rpcsvc_unregister_notify (rpcsvc_t *svc, rpcsvc_notify_t notify, void *mydata) goto out; } - pthread_rwlock_wrlock (&svc->rpclock); + pthread_mutex_lock (&svc->rpclock); { list_for_each_entry_safe (wrapper, tmp, &svc->notify, list) { if ((wrapper->notify == notify) @@ -1824,7 +1824,7 @@ rpcsvc_unregister_notify (rpcsvc_t *svc, rpcsvc_notify_t notify, void *mydata) } } } - pthread_rwlock_unlock (&svc->rpclock); + pthread_mutex_unlock (&svc->rpclock); out: return ret; @@ -1844,12 +1844,12 @@ rpcsvc_register_notify (rpcsvc_t *svc, rpcsvc_notify_t notify, void *mydata) wrapper->data = mydata; wrapper->notify = notify; - pthread_rwlock_wrlock (&svc->rpclock); + pthread_mutex_lock (&svc->rpclock); { list_add_tail (&wrapper->list, &svc->notify); svc->notify_count++; } - pthread_rwlock_unlock (&svc->rpclock); + pthread_mutex_unlock (&svc->rpclock); ret = 0; out: @@ -1987,7 +1987,7 @@ rpcsvc_program_register (rpcsvc_t *svc, rpcsvc_program_t *program) goto out; } - pthread_rwlock_rdlock (&svc->rpclock); + pthread_mutex_lock (&svc->rpclock); { list_for_each_entry (newprog, &svc->programs, program) { if ((newprog->prognum == program->prognum) @@ -1997,7 +1997,7 @@ rpcsvc_program_register (rpcsvc_t *svc, rpcsvc_program_t *program) } } } - pthread_rwlock_unlock (&svc->rpclock); + pthread_mutex_unlock (&svc->rpclock); if (already_registered) { ret = 0; @@ -2031,11 +2031,11 @@ rpcsvc_program_register (rpcsvc_t *svc, rpcsvc_program_t *program) } } - pthread_rwlock_wrlock (&svc->rpclock); + pthread_mutex_lock (&svc->rpclock); { list_add_tail (&newprog->program, &svc->programs); } - pthread_rwlock_unlock (&svc->rpclock); + pthread_mutex_unlock (&svc->rpclock); ret = 0; gf_log (GF_RPCSVC, GF_LOG_DEBUG, "New program registered: %s, Num: %d," @@ -2077,7 +2077,7 @@ build_prog_details (rpcsvc_request_t *req, gf_dump_rsp *rsp) if (!req || !req->trans || !req->svc) goto out; - pthread_rwlock_rdlock (&req->svc->rpclock); + pthread_mutex_lock (&req->svc->rpclock); { list_for_each_entry (program, &req->svc->programs, program) { prog = GF_CALLOC (1, sizeof (*prog), 0); @@ -2098,7 +2098,7 @@ build_prog_details (rpcsvc_request_t *req, gf_dump_rsp *rsp) ret = 0; } unlock: - pthread_rwlock_unlock (&req->svc->rpclock); + pthread_mutex_unlock (&req->svc->rpclock); out: return ret; } @@ -2456,7 +2456,7 @@ rpcsvc_init (xlator_t *xl, glusterfs_ctx_t *ctx, dict_t *options, if (!svc) return NULL; - pthread_rwlock_init (&svc->rpclock, NULL); + pthread_mutex_init (&svc->rpclock, NULL); INIT_LIST_HEAD (&svc->authschemes); INIT_LIST_HEAD (&svc->notify); INIT_LIST_HEAD (&svc->listeners); -- 1.8.3.1