summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAtin Mukherjee <amukherj@redhat.com>2015-03-24 11:27:52 +0530
committerRaghavendra Bhat <raghavendra@redhat.com>2015-05-28 02:06:43 -0700
commitc395ef6539f877cde96d13b66613a1746e628cf7 (patch)
treeecaae65063896dfc0fcc252579635fe9973ec735
parentd0f62e8b4fc605c522f7971a82cbbf027e06960e (diff)
glusterd: Maintain local xaction_peer list for op-sm
http://review.gluster.org/9269 addresses maintaining local xaction_peers in syncop and mgmt_v3 framework. This patch is to maintain local xaction_peers list for op-sm framework as well. Backport of http://review.gluster.org/#/c/9972/ Change-Id: Idd8484463fed196b3b18c2df7f550a3302c6e138 BUG: 1206429 Signed-off-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-on: http://review.gluster.org/9972 Reviewed-by: Anand Nekkunti <anekkunt@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Tested-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: http://review.gluster.org/10023 Reviewed-by: Kaushal M <kaushal@redhat.com> Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
-rw-r--r--libglusterfs/src/mem-types.h1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c16
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c17
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-syncop.c19
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-syncop.h14
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c19
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h14
8 files changed, 65 insertions, 38 deletions
diff --git a/libglusterfs/src/mem-types.h b/libglusterfs/src/mem-types.h
index 4359488c5f9..2992278a03d 100644
--- a/libglusterfs/src/mem-types.h
+++ b/libglusterfs/src/mem-types.h
@@ -127,6 +127,7 @@ enum gf_common_mem_types_ {
gf_common_mt_regex_t = 111,
gf_common_mt_wr = 112,
gf_common_mt_rdma_arena_mr = 113,
+ gf_common_mt_list_head_t = 114,
gf_common_mt_end
};
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 5541852f044..d3d4a91909b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -518,6 +518,7 @@ glusterd_op_txn_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx,
char *err_str, size_t err_len)
{
int32_t ret = -1;
+ int npeers = 0;
dict_t *dict = NULL;
xlator_t *this = NULL;
glusterd_conf_t *priv = NULL;
@@ -605,6 +606,21 @@ glusterd_op_txn_begin (rpcsvc_request_t *req, glusterd_op_t op, void *ctx,
gf_log (this->name, GF_LOG_DEBUG, "Acquired lock on localhost");
local_locking_done:
+ txn_op_info.local_xaction_peers =
+ GF_CALLOC (1, sizeof (struct list_head),
+ gf_common_mt_list_head_t);
+ if (!txn_op_info.local_xaction_peers) {
+ ret = -1;
+ gf_log (this->name, GF_LOG_ERROR, "Out of memory");
+ goto out;
+ }
+ INIT_LIST_HEAD (txn_op_info.local_xaction_peers);
+
+ /* Maintain xaction_peers on per transaction basis */
+ npeers = gd_build_local_xaction_peers_list
+ (&priv->peers,
+ txn_op_info.local_xaction_peers,
+ op);
/* If no volname is given as a part of the command, locks will
* not be held, hence sending stage event. */
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index a7a612c8152..8c341153db4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -306,6 +306,9 @@ glusterd_clear_txn_opinfo (uuid_t *txn_id)
dict_del(priv->glusterd_txn_opinfo, uuid_utoa (*txn_id));
+ if (txn_op_info.local_xaction_peers)
+ GF_FREE (txn_op_info.local_xaction_peers);
+
gf_log ("", GF_LOG_DEBUG,
"Successfully cleared opinfo for transaction ID : %s",
uuid_utoa (*txn_id));
@@ -2862,7 +2865,8 @@ glusterd_op_ac_send_lock (glusterd_op_sm_event_t *event, void *ctx)
priv = this->private;
GF_ASSERT (priv);
- list_for_each_entry (peerinfo, &priv->peers, uuid_list) {
+ list_for_each_local_xaction_peers (peerinfo,
+ opinfo.local_xaction_peers) {
GF_ASSERT (peerinfo);
if (!peerinfo->connected || !peerinfo->mgmt)
@@ -2951,7 +2955,8 @@ glusterd_op_ac_send_unlock (glusterd_op_sm_event_t *event, void *ctx)
priv = this->private;
GF_ASSERT (priv);
- list_for_each_entry (peerinfo, &priv->peers, uuid_list) {
+ list_for_each_local_xaction_peers (peerinfo,
+ opinfo.local_xaction_peers) {
GF_ASSERT (peerinfo);
if (!peerinfo->connected || !peerinfo->mgmt ||
@@ -3599,7 +3604,8 @@ glusterd_op_ac_send_stage_op (glusterd_op_sm_event_t *event, void *ctx)
if (op == GD_OP_REPLACE_BRICK)
glusterd_rb_use_rsp_dict (NULL, rsp_dict);
- list_for_each_entry (peerinfo, &priv->peers, uuid_list) {
+ list_for_each_local_xaction_peers (peerinfo,
+ opinfo.local_xaction_peers) {
GF_ASSERT (peerinfo);
if (!peerinfo->connected || !peerinfo->mgmt)
@@ -4158,8 +4164,8 @@ glusterd_op_ac_send_commit_op (glusterd_op_sm_event_t *event, void *ctx)
goto out;
}
-
- list_for_each_entry (peerinfo, &priv->peers, uuid_list) {
+ list_for_each_local_xaction_peers (peerinfo,
+ opinfo.local_xaction_peers) {
GF_ASSERT (peerinfo);
if (!peerinfo->connected || !peerinfo->mgmt)
@@ -4474,6 +4480,7 @@ glusterd_op_txn_complete (uuid_t *txn_id)
glusterd_op_clear_op ();
glusterd_op_reset_ctx ();
glusterd_op_clear_errstr ();
+ gd_cleanup_local_xaction_peers_list (opinfo.local_xaction_peers);
/* Based on the op-version, we release the cluster or mgmt_v3 lock */
if (priv->op_version < GD_OP_VERSION_3_6_0) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
index 88fe9ef4c04..3786c9af291 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
@@ -105,7 +105,8 @@ struct glusterd_op_info_ {
int32_t op_ret;
int32_t op_errno;
char *op_errstr;
- struct list_head pending_bricks;
+ struct list_head pending_bricks;
+ struct list_head *local_xaction_peers;
};
typedef struct glusterd_op_info_ glusterd_op_info_t;
diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c
index bca8557d3a2..68d10e58e7f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c
+++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c
@@ -1075,23 +1075,6 @@ gd_build_local_xaction_peers_list (struct list_head *peers,
return npeers;
}
-void
-gd_cleanup_local_xaction_peers_list (struct list_head *xact_peers)
-{
- GF_ASSERT (xact_peers);
-
- if (list_empty (xact_peers))
- return;
-
- glusterd_local_peers_t *local_peers = NULL;
-
- list_for_each_entry (local_peers, xact_peers, op_peers_list) {
- GF_FREE (local_peers);
- /* local_peers->peerinfo need not be freed because it does not
- * ownership of peerinfo, but merely refer it */
- }
-}
-
int
gd_lock_op_phase (glusterd_conf_t *conf, glusterd_op_t op, dict_t *op_ctx,
char **op_errstr, int npeers, uuid_t txn_id,
@@ -1547,7 +1530,7 @@ gd_sync_task_begin (dict_t *op_ctx, rpcsvc_request_t * req)
gf_boolean_t is_acquired = _gf_false;
uuid_t *txn_id = NULL;
struct list_head xaction_peers = {0,};
- glusterd_op_info_t txn_opinfo;
+ glusterd_op_info_t txn_opinfo = {{0},};
this = THIS;
GF_ASSERT (this);
diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.h b/xlators/mgmt/glusterd/src/glusterd-syncop.h
index 1944bb4e143..cdc65a3e931 100644
--- a/xlators/mgmt/glusterd/src/glusterd-syncop.h
+++ b/xlators/mgmt/glusterd/src/glusterd-syncop.h
@@ -36,17 +36,6 @@
synclock_lock (&conf->big_lock); \
} while (0)
-
-#define list_for_each_local_xaction_peers(xact_peer, xact_peers_head) \
- glusterd_local_peers_t *pos = NULL; \
- for (pos = list_entry((xact_peers_head)->next, glusterd_local_peers_t,\
- op_peers_list), \
- xact_peer = pos->peerinfo; \
- &pos->op_peers_list != (xact_peers_head); \
- pos = list_entry(pos->op_peers_list.next, glusterd_local_peers_t,\
- op_peers_list), \
- xact_peer = pos->peerinfo)
-
int gd_syncop_submit_request (struct rpc_clnt *rpc, void *req, void *local,
void *cookie, rpc_clnt_prog_t *prog, int procnum,
fop_cbk_fn_t cbkfn, xdrproc_t xdrproc);
@@ -73,9 +62,6 @@ gd_build_local_xaction_peers_list (struct list_head *peers,
struct list_head *xact_peers,
glusterd_op_t op);
-void
-gd_cleanup_local_xaction_peers_list (struct list_head *peers);
-
int
gd_brick_op_phase (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict,
char **op_errstr);
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 7ac6cf37134..54daa1addeb 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -13798,3 +13798,22 @@ out:
GF_FREE (dup_val);
return exists;
}
+
+void
+gd_cleanup_local_xaction_peers_list (struct list_head *xact_peers)
+{
+ glusterd_local_peers_t *local_peers = NULL;
+ glusterd_local_peers_t *tmp = NULL;
+
+ GF_ASSERT (xact_peers);
+
+ if (list_empty (xact_peers))
+ return;
+
+ list_for_each_entry_safe (local_peers, tmp, xact_peers,
+ op_peers_list) {
+ GF_FREE (local_peers);
+ /* local_peers->peerinfo need not be freed because it does not
+ * ownership of peerinfo, but merely refer it */
+ }
+}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 636f72613d9..49783fb816f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -45,6 +45,16 @@
if (active_count && (peerinfo->quorum_contrib == QUORUM_UP))\
*active_count = *active_count + 1;\
+#define list_for_each_local_xaction_peers(xact_peer, xact_peers_head) \
+ glusterd_local_peers_t *pos = NULL; \
+ for (pos = list_entry ((xact_peers_head)->next, \
+ glusterd_local_peers_t, op_peers_list), \
+ xact_peer = pos->peerinfo; \
+ &pos->op_peers_list != (xact_peers_head); \
+ pos = list_entry(pos->op_peers_list.next, \
+ glusterd_local_peers_t, op_peers_list), \
+ xact_peer = pos->peerinfo)
+
struct glusterd_lock_ {
uuid_t owner;
time_t timestamp;
@@ -915,4 +925,8 @@ mntopts_exists (const char *str, const char *opts);
void
glusterd_get_rebalance_volfile (glusterd_volinfo_t *volinfo,
char *path, int path_len);
+
+void
+gd_cleanup_local_xaction_peers_list (struct list_head *peers);
+
#endif