summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorN Balachandran <nbalacha@redhat.com>2016-10-24 13:54:41 +0530
committerRaghavendra G <rgowdapp@redhat.com>2016-10-25 04:09:22 -0700
commitf4efbf0e3092bd2181f62be1e1f30f202678c866 (patch)
treed23d0131f97ed2548b0c6332a01da15d6e659518 /xlators/cluster
parent48a4c4e525665115f7e8c478d3bf51764427378d (diff)
cluster/dht: Incorrect volname in rebalance events
The rebalance event code was using strtok to parse the volume name which is incorrect. Reworked the code to get the correct volume name using strstr. Change-Id: Ib5f3305a34e6bf1ecfef677d87c5aff96bdeb0e6 BUG: 1388010 Signed-off-by: N Balachandran <nbalacha@redhat.com> Reviewed-on: http://review.gluster.org/15712 NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Raghavendra G <rgowdapp@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c56
1 files changed, 50 insertions, 6 deletions
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index 170fb102462..e41a59e7bfc 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -73,12 +73,40 @@ dht_set_global_defrag_error (gf_defrag_info_t *defrag, int ret)
return;
}
+
+static gf_boolean_t
+dht_is_tier_command (int cmd) {
+
+ gf_boolean_t is_tier = _gf_false;
+
+ switch (cmd) {
+ case GF_DEFRAG_CMD_START_TIER:
+ case GF_DEFRAG_CMD_STATUS_TIER:
+ case GF_DEFRAG_CMD_START_DETACH_TIER:
+ case GF_DEFRAG_CMD_STOP_DETACH_TIER:
+ case GF_DEFRAG_CMD_PAUSE_TIER:
+ case GF_DEFRAG_CMD_RESUME_TIER:
+ is_tier = _gf_true;
+ break;
+ default:
+ break;
+ }
+ return is_tier;
+
+}
+
+
static int
-dht_send_rebalance_event (xlator_t *this, gf_defrag_status_t status)
+dht_send_rebalance_event (xlator_t *this, int cmd, gf_defrag_status_t status)
{
int ret = -1;
char *volname = NULL;
char *tmpstr = NULL;
+ char *ptr = NULL;
+ char *suffix = "-dht";
+ dht_conf_t *conf = NULL;
+ gf_defrag_info_t *defrag = NULL;
+ int len = 0;
eventtypes_t event = EVENT_LAST;
@@ -97,17 +125,33 @@ dht_send_rebalance_event (xlator_t *this, gf_defrag_status_t status)
}
- tmpstr = gf_strdup (this->name);
- if (tmpstr) {
- volname = strtok(tmpstr, "-dht");
+ if (dht_is_tier_command (cmd)) {
+ /* We should have the tier volume name*/
+ conf = this->private;
+ defrag = conf->defrag;
+ volname = defrag->tier_conf.volname;
+ } else {
+ /* DHT volume */
+ len = strlen (this->name);
+ tmpstr = gf_strdup (this->name);
+ if (tmpstr) {
+ ptr = tmpstr + (len - strlen (suffix));
+ if (!strcmp (ptr, suffix)) {
+ tmpstr[len - strlen (suffix)] = '\0';
+ volname = tmpstr;
+ }
+ }
}
- if (!volname)
+ if (!volname) {
+ /* Better than nothing */
volname = this->name;
+ }
if (event != EVENT_LAST) {
ret = gf_event (event, "volume=%s", volname);
}
+
GF_FREE (tmpstr);
return ret;
}
@@ -3873,7 +3917,7 @@ out:
defrag->defrag_status = GF_DEFRAG_STATUS_COMPLETE;
}
- dht_send_rebalance_event (this, defrag->defrag_status);
+ dht_send_rebalance_event (this, defrag->cmd, defrag->defrag_status);
LOCK (&defrag->lock);
{