|
|
d1681e |
From c793a7c0a3672cfab9bd927ae493bc24be8bbc09 Mon Sep 17 00:00:00 2001
|
|
|
d1681e |
From: hari gowtham <hgowtham@redhat.com>
|
|
|
d1681e |
Date: Fri, 24 Nov 2017 11:47:01 +0530
|
|
|
d1681e |
Subject: [PATCH 099/128] Tier: Stop tierd for detach start
|
|
|
d1681e |
|
|
|
d1681e |
back-port of: https://review.gluster.org/#/c/17137/
|
|
|
d1681e |
|
|
|
d1681e |
Problem: tierd was stopped only after detach commit
|
|
|
d1681e |
This makes the detach take a longer time. The detach
|
|
|
d1681e |
demotes the files to the cold brick and if the promotion
|
|
|
d1681e |
frequency is hit, then the tierd starts to promote files to
|
|
|
d1681e |
hot tier again.
|
|
|
d1681e |
|
|
|
d1681e |
Fix: stop tierd after detach start so the files get
|
|
|
d1681e |
demoted faster.
|
|
|
d1681e |
|
|
|
d1681e |
Note: the is_tier_enabled was not maintained properly.
|
|
|
d1681e |
That has been fixed too. some code clean up has been done.
|
|
|
d1681e |
|
|
|
d1681e |
>BUG: 1446381
|
|
|
d1681e |
>Change-Id: I532f7410cea04fbb960105483810ea3560ca149b
|
|
|
d1681e |
>Signed-off-by: hari gowtham <hgowtham@redhat.com>
|
|
|
d1681e |
|
|
|
d1681e |
Signed-off-by: hari gowtham <hgowtham@redhat.com>
|
|
|
d1681e |
Change-Id: I532f7410cea04fbb960105483810ea3560ca149b
|
|
|
d1681e |
BUG: 1509191
|
|
|
d1681e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/125081
|
|
|
d1681e |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
d1681e |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
d1681e |
---
|
|
|
d1681e |
tests/basic/tier/new-tier-cmds.t | 22 ++-
|
|
|
d1681e |
xlators/cluster/dht/src/dht-common.h | 13 +-
|
|
|
d1681e |
xlators/mgmt/glusterd/src/glusterd-messages.h | 8 +
|
|
|
d1681e |
xlators/mgmt/glusterd/src/glusterd-mgmt.c | 2 -
|
|
|
d1681e |
xlators/mgmt/glusterd/src/glusterd-tier.c | 224 +++++++++---------------
|
|
|
d1681e |
xlators/mgmt/glusterd/src/glusterd-tierd-svc.c | 65 ++++---
|
|
|
d1681e |
xlators/mgmt/glusterd/src/glusterd-utils.c | 10 ++
|
|
|
d1681e |
xlators/mgmt/glusterd/src/glusterd-utils.h | 3 +
|
|
|
d1681e |
xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 17 +-
|
|
|
d1681e |
9 files changed, 182 insertions(+), 182 deletions(-)
|
|
|
d1681e |
|
|
|
d1681e |
diff --git a/tests/basic/tier/new-tier-cmds.t b/tests/basic/tier/new-tier-cmds.t
|
|
|
d1681e |
index d341e62..2c48e02 100644
|
|
|
d1681e |
--- a/tests/basic/tier/new-tier-cmds.t
|
|
|
d1681e |
+++ b/tests/basic/tier/new-tier-cmds.t
|
|
|
d1681e |
@@ -14,9 +14,9 @@ function check_peers {
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
function create_dist_tier_vol () {
|
|
|
d1681e |
- TEST $CLI_1 volume create $V0 $H1:$B1/${V0} $H2:$B2/${V0} $H3:$B3/${V0}
|
|
|
d1681e |
+ TEST $CLI_1 volume create $V0 disperse 6 redundancy 2 $H1:$B1/${V0}_b1 $H2:$B2/${V0}_b2 $H3:$B3/${V0}_b3 $H1:$B1/${V0}_b4 $H2:$B2/${V0}_b5 $H3:$B3/${V0}_b6
|
|
|
d1681e |
TEST $CLI_1 volume start $V0
|
|
|
d1681e |
- TEST $CLI_1 volume tier $V0 attach $H1:$B1/${V0}_h1 $H2:$B2/${V0}_h2 $H3:$B3/${V0}_h3
|
|
|
d1681e |
+ TEST $CLI_1 volume tier $V0 attach replica 2 $H1:$B1/${V0}_h1 $H2:$B2/${V0}_h2 $H3:$B3/${V0}_h3 $H1:$B1/${V0}_h4 $H2:$B2/${V0}_h5 $H3:$B3/${V0}_h6
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
function tier_daemon_status {
|
|
|
d1681e |
@@ -59,8 +59,19 @@ EXPECT "Tier command failed" $CLI_1 volume tier $V0 detach status
|
|
|
d1681e |
|
|
|
d1681e |
EXPECT "0" detach_xml_status
|
|
|
d1681e |
|
|
|
d1681e |
-#after starting detach tier the detach tier status should display the status
|
|
|
d1681e |
+#kill a node
|
|
|
d1681e |
+TEST kill_node 2
|
|
|
d1681e |
|
|
|
d1681e |
+#check if we have the rest of the node available printed in the output of detach status
|
|
|
d1681e |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" tier_status_node_down
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST $glusterd_2;
|
|
|
d1681e |
+
|
|
|
d1681e |
+EXPECT_WITHIN $PROBE_TIMEOUT 2 check_peers;
|
|
|
d1681e |
+
|
|
|
d1681e |
+#after starting detach tier the detach tier status should display the status
|
|
|
d1681e |
+sleep 2
|
|
|
d1681e |
+$CLI_1 volume status
|
|
|
d1681e |
TEST $CLI_1 volume tier $V0 detach start
|
|
|
d1681e |
|
|
|
d1681e |
EXPECT "1" detach_xml_status
|
|
|
d1681e |
@@ -73,14 +84,11 @@ TEST kill_node 2
|
|
|
d1681e |
#check if we have the rest of the node available printed in the output of detach status
|
|
|
d1681e |
EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" tier_detach_status_node_down
|
|
|
d1681e |
|
|
|
d1681e |
-#check if we have the rest of the node available printed in the output of tier status
|
|
|
d1681e |
-EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" tier_status_node_down
|
|
|
d1681e |
-
|
|
|
d1681e |
TEST $glusterd_2;
|
|
|
d1681e |
|
|
|
d1681e |
EXPECT_WITHIN $PROBE_TIMEOUT 2 check_peers;
|
|
|
d1681e |
# Make sure we check that the *bricks* are up and not just the node. >:-(
|
|
|
d1681e |
-EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 brick_up_status_1 $V0 $H2 $B2/${V0}
|
|
|
d1681e |
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 brick_up_status_1 $V0 $H2 $B2/${V0}_b2
|
|
|
d1681e |
EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 brick_up_status_1 $V0 $H2 $B2/${V0}_h2
|
|
|
d1681e |
|
|
|
d1681e |
# Parsing normal output doesn't work because of line-wrap issues on our
|
|
|
d1681e |
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
|
|
|
d1681e |
index 6056060..e2afd6c 100644
|
|
|
d1681e |
--- a/xlators/cluster/dht/src/dht-common.h
|
|
|
d1681e |
+++ b/xlators/cluster/dht/src/dht-common.h
|
|
|
d1681e |
@@ -393,10 +393,17 @@ enum gf_defrag_type {
|
|
|
d1681e |
GF_DEFRAG_CMD_PAUSE_TIER = 1 + 9,
|
|
|
d1681e |
GF_DEFRAG_CMD_RESUME_TIER = 1 + 10,
|
|
|
d1681e |
GF_DEFRAG_CMD_DETACH_STATUS = 1 + 11,
|
|
|
d1681e |
- GF_DEFRAG_CMD_DETACH_START = 1 + 12,
|
|
|
d1681e |
- GF_DEFRAG_CMD_DETACH_STOP = 1 + 13,
|
|
|
d1681e |
+ GF_DEFRAG_CMD_STOP_TIER = 1 + 12,
|
|
|
d1681e |
+ GF_DEFRAG_CMD_DETACH_START = 1 + 13,
|
|
|
d1681e |
+ GF_DEFRAG_CMD_DETACH_COMMIT = 1 + 14,
|
|
|
d1681e |
+ GF_DEFRAG_CMD_DETACH_COMMIT_FORCE = 1 + 15,
|
|
|
d1681e |
+ GF_DEFRAG_CMD_DETACH_STOP = 1 + 16,
|
|
|
d1681e |
/* new labels are used so it will help
|
|
|
d1681e |
- * while removing old labels by easily differentiating
|
|
|
d1681e |
+ * while removing old labels by easily differentiating.
|
|
|
d1681e |
+ * A few labels are added so that the count remains same
|
|
|
d1681e |
+ * between this enum and the ones on the xdr file.
|
|
|
d1681e |
+ * different values for the same enum cause errors and
|
|
|
d1681e |
+ * confusion.
|
|
|
d1681e |
*/
|
|
|
d1681e |
};
|
|
|
d1681e |
typedef enum gf_defrag_type gf_defrag_type;
|
|
|
d1681e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h
|
|
|
d1681e |
index 225d59b..4ccf299 100644
|
|
|
d1681e |
--- a/xlators/mgmt/glusterd/src/glusterd-messages.h
|
|
|
d1681e |
+++ b/xlators/mgmt/glusterd/src/glusterd-messages.h
|
|
|
d1681e |
@@ -4976,6 +4976,14 @@
|
|
|
d1681e |
*/
|
|
|
d1681e |
#define GD_MSG_CHANGELOG_GET_FAIL (GLUSTERD_COMP_BASE + 614)
|
|
|
d1681e |
|
|
|
d1681e |
+/*!
|
|
|
d1681e |
+ * @messageid
|
|
|
d1681e |
+ * @diagnosis
|
|
|
d1681e |
+ * @recommendedaction
|
|
|
d1681e |
+ *
|
|
|
d1681e |
+ */
|
|
|
d1681e |
+#define GD_MSG_MANAGER_FUNCTION_FAILED (GLUSTERD_COMP_BASE + 614)
|
|
|
d1681e |
+
|
|
|
d1681e |
/*------------*/
|
|
|
d1681e |
|
|
|
d1681e |
#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
|
|
|
d1681e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c
|
|
|
d1681e |
index 13a4526..8bc1f1b 100644
|
|
|
d1681e |
--- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c
|
|
|
d1681e |
+++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c
|
|
|
d1681e |
@@ -539,8 +539,6 @@ gd_mgmt_v3_post_validate_fn (glusterd_op_t op, int32_t op_ret, dict_t *dict,
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
- volinfo->is_tier_enabled = _gf_true;
|
|
|
d1681e |
-
|
|
|
d1681e |
if (ret) {
|
|
|
d1681e |
gf_msg (this->name, GF_LOG_ERROR, errno,
|
|
|
d1681e |
GD_MSG_DICT_SET_FAILED, "dict set "
|
|
|
d1681e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-tier.c b/xlators/mgmt/glusterd/src/glusterd-tier.c
|
|
|
d1681e |
index 28f02e75..15c4808 100644
|
|
|
d1681e |
--- a/xlators/mgmt/glusterd/src/glusterd-tier.c
|
|
|
d1681e |
+++ b/xlators/mgmt/glusterd/src/glusterd-tier.c
|
|
|
d1681e |
@@ -244,116 +244,6 @@ glusterd_handle_tier (rpcsvc_request_t *req)
|
|
|
d1681e |
return glusterd_big_locked_handler (req, __glusterd_handle_tier);
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
-
|
|
|
d1681e |
-static int
|
|
|
d1681e |
-glusterd_manage_tier (glusterd_volinfo_t *volinfo, int opcode)
|
|
|
d1681e |
-{
|
|
|
d1681e |
- int ret = -1;
|
|
|
d1681e |
- xlator_t *this = NULL;
|
|
|
d1681e |
- glusterd_conf_t *priv = NULL;
|
|
|
d1681e |
-
|
|
|
d1681e |
- this = THIS;
|
|
|
d1681e |
- GF_VALIDATE_OR_GOTO (THIS->name, this, out);
|
|
|
d1681e |
- GF_VALIDATE_OR_GOTO (this->name, volinfo, out);
|
|
|
d1681e |
- priv = this->private;
|
|
|
d1681e |
- GF_VALIDATE_OR_GOTO (this->name, priv, out);
|
|
|
d1681e |
-
|
|
|
d1681e |
- switch (opcode) {
|
|
|
d1681e |
- case GF_DEFRAG_CMD_START_TIER:
|
|
|
d1681e |
- case GF_DEFRAG_CMD_STOP_TIER:
|
|
|
d1681e |
- ret = volinfo->tierd.svc.manager (&(volinfo->tierd.svc),
|
|
|
d1681e |
- volinfo, PROC_START_NO_WAIT);
|
|
|
d1681e |
- break;
|
|
|
d1681e |
- default:
|
|
|
d1681e |
- ret = 0;
|
|
|
d1681e |
- break;
|
|
|
d1681e |
- }
|
|
|
d1681e |
-
|
|
|
d1681e |
-out:
|
|
|
d1681e |
- return ret;
|
|
|
d1681e |
-
|
|
|
d1681e |
-}
|
|
|
d1681e |
-
|
|
|
d1681e |
-static int
|
|
|
d1681e |
-glusterd_tier_enable (glusterd_volinfo_t *volinfo, char **op_errstr)
|
|
|
d1681e |
-{
|
|
|
d1681e |
- int32_t ret = -1;
|
|
|
d1681e |
- xlator_t *this = NULL;
|
|
|
d1681e |
- int32_t tier_online = -1;
|
|
|
d1681e |
- char pidfile[PATH_MAX] = {0};
|
|
|
d1681e |
- int32_t pid = -1;
|
|
|
d1681e |
- glusterd_conf_t *priv = NULL;
|
|
|
d1681e |
-
|
|
|
d1681e |
- this = THIS;
|
|
|
d1681e |
-
|
|
|
d1681e |
- GF_VALIDATE_OR_GOTO (THIS->name, this, out);
|
|
|
d1681e |
- GF_VALIDATE_OR_GOTO (this->name, volinfo, out);
|
|
|
d1681e |
- GF_VALIDATE_OR_GOTO (this->name, op_errstr, out);
|
|
|
d1681e |
- priv = this->private;
|
|
|
d1681e |
- GF_VALIDATE_OR_GOTO (this->name, priv, out);
|
|
|
d1681e |
-
|
|
|
d1681e |
- if (glusterd_is_volume_started (volinfo) == 0) {
|
|
|
d1681e |
- *op_errstr = gf_strdup ("Volume is stopped, start volume "
|
|
|
d1681e |
- "to enable tier.");
|
|
|
d1681e |
- ret = -1;
|
|
|
d1681e |
- goto out;
|
|
|
d1681e |
- }
|
|
|
d1681e |
-
|
|
|
d1681e |
- GLUSTERD_GET_TIER_PID_FILE(pidfile, volinfo, priv);
|
|
|
d1681e |
- tier_online = gf_is_service_running (pidfile, &pid;;
|
|
|
d1681e |
-
|
|
|
d1681e |
- if (tier_online) {
|
|
|
d1681e |
- *op_errstr = gf_strdup ("tier is already enabled");
|
|
|
d1681e |
- ret = -1;
|
|
|
d1681e |
- goto out;
|
|
|
d1681e |
- }
|
|
|
d1681e |
-
|
|
|
d1681e |
- volinfo->is_tier_enabled = _gf_true;
|
|
|
d1681e |
-
|
|
|
d1681e |
- ret = 0;
|
|
|
d1681e |
-out:
|
|
|
d1681e |
- if (ret && op_errstr && !*op_errstr)
|
|
|
d1681e |
- gf_asprintf (op_errstr, "Enabling tier on volume %s has been "
|
|
|
d1681e |
- "unsuccessful", volinfo->volname);
|
|
|
d1681e |
- return ret;
|
|
|
d1681e |
-}
|
|
|
d1681e |
-
|
|
|
d1681e |
-static int
|
|
|
d1681e |
-glusterd_tier_disable (glusterd_volinfo_t *volinfo, char **op_errstr)
|
|
|
d1681e |
-{
|
|
|
d1681e |
- int32_t ret = -1;
|
|
|
d1681e |
- xlator_t *this = NULL;
|
|
|
d1681e |
- int32_t tier_online = -1;
|
|
|
d1681e |
- char pidfile[PATH_MAX] = {0};
|
|
|
d1681e |
- int32_t pid = -1;
|
|
|
d1681e |
- glusterd_conf_t *priv = NULL;
|
|
|
d1681e |
-
|
|
|
d1681e |
- this = THIS;
|
|
|
d1681e |
-
|
|
|
d1681e |
- GF_VALIDATE_OR_GOTO (THIS->name, this, out);
|
|
|
d1681e |
- GF_VALIDATE_OR_GOTO (this->name, volinfo, out);
|
|
|
d1681e |
- GF_VALIDATE_OR_GOTO (this->name, op_errstr, out);
|
|
|
d1681e |
- priv = this->private;
|
|
|
d1681e |
-
|
|
|
d1681e |
- GLUSTERD_GET_TIER_PID_FILE(pidfile, volinfo, priv);
|
|
|
d1681e |
- tier_online = gf_is_service_running (pidfile, &pid;;
|
|
|
d1681e |
-
|
|
|
d1681e |
- if (!tier_online) {
|
|
|
d1681e |
- *op_errstr = gf_strdup ("tier is already disabled");
|
|
|
d1681e |
- ret = -1;
|
|
|
d1681e |
- goto out;
|
|
|
d1681e |
- }
|
|
|
d1681e |
-
|
|
|
d1681e |
- volinfo->is_tier_enabled = _gf_false;
|
|
|
d1681e |
-
|
|
|
d1681e |
- ret = 0;
|
|
|
d1681e |
-out:
|
|
|
d1681e |
- if (ret && op_errstr && !*op_errstr)
|
|
|
d1681e |
- gf_asprintf (op_errstr, "Disabling tier volume %s has "
|
|
|
d1681e |
- "been unsuccessful", volinfo->volname);
|
|
|
d1681e |
- return ret;
|
|
|
d1681e |
-}
|
|
|
d1681e |
-
|
|
|
d1681e |
int
|
|
|
d1681e |
glusterd_op_remove_tier_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
|
|
d1681e |
{
|
|
|
d1681e |
@@ -455,6 +345,19 @@ glusterd_op_remove_tier_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
|
|
d1681e |
continue;
|
|
|
d1681e |
brickinfo->decommissioned = 0;
|
|
|
d1681e |
}
|
|
|
d1681e |
+ volinfo->tier.op = GD_OP_DETACH_NOT_STARTED;
|
|
|
d1681e |
+ ret = volinfo->tierd.svc.manager (&(volinfo->tierd.svc),
|
|
|
d1681e |
+ volinfo,
|
|
|
d1681e |
+ PROC_START_NO_WAIT);
|
|
|
d1681e |
+ if (ret) {
|
|
|
d1681e |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
d1681e |
+ GD_MSG_MANAGER_FUNCTION_FAILED,
|
|
|
d1681e |
+ "Calling manager for tier "
|
|
|
d1681e |
+ "failed on volume: %s for "
|
|
|
d1681e |
+ "detach stop", volinfo->volname);
|
|
|
d1681e |
+ goto out;
|
|
|
d1681e |
+ }
|
|
|
d1681e |
+
|
|
|
d1681e |
ret = glusterd_create_volfiles_and_notify_services
|
|
|
d1681e |
(volinfo);
|
|
|
d1681e |
|
|
|
d1681e |
@@ -473,22 +376,24 @@ glusterd_op_remove_tier_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
|
|
d1681e |
"failed to store volinfo");
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
}
|
|
|
d1681e |
- ret = glusterd_tierdsvc_restart ();
|
|
|
d1681e |
- if (ret) {
|
|
|
d1681e |
- gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
d1681e |
- GD_MSG_TIERD_START_FAIL,
|
|
|
d1681e |
- "Couldn't restart tierd for "
|
|
|
d1681e |
- "vol: %s", volinfo->volname);
|
|
|
d1681e |
- goto out;
|
|
|
d1681e |
- }
|
|
|
d1681e |
-
|
|
|
d1681e |
- volinfo->tier.op = GD_OP_DETACH_NOT_STARTED;
|
|
|
d1681e |
ret = 0;
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
|
|
|
d1681e |
|
|
|
d1681e |
|
|
|
d1681e |
case GF_DEFRAG_CMD_DETACH_START:
|
|
|
d1681e |
+ volinfo->tier.op = GD_OP_DETACH_TIER;
|
|
|
d1681e |
+ svc = &(volinfo->tierd.svc);
|
|
|
d1681e |
+ ret = svc->manager (svc, volinfo,
|
|
|
d1681e |
+ PROC_START_NO_WAIT);
|
|
|
d1681e |
+ if (ret) {
|
|
|
d1681e |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
d1681e |
+ GD_MSG_MANAGER_FUNCTION_FAILED,
|
|
|
d1681e |
+ "calling manager for tier "
|
|
|
d1681e |
+ "failed on volume: %s for "
|
|
|
d1681e |
+ "detach start", volname);
|
|
|
d1681e |
+ goto out;
|
|
|
d1681e |
+ }
|
|
|
d1681e |
ret = dict_get_str (dict, GF_REMOVE_BRICK_TID_KEY,
|
|
|
d1681e |
&task_id_str);
|
|
|
d1681e |
if (ret) {
|
|
|
d1681e |
@@ -504,8 +409,6 @@ glusterd_op_remove_tier_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
|
|
d1681e |
}
|
|
|
d1681e |
force = 0;
|
|
|
d1681e |
|
|
|
d1681e |
- volinfo->tier.op = GD_OP_DETACH_TIER;
|
|
|
d1681e |
- volinfo->tier.defrag_status = GF_DEFRAG_STATUS_STARTED;
|
|
|
d1681e |
break;
|
|
|
d1681e |
|
|
|
d1681e |
case GF_DEFRAG_CMD_DETACH_COMMIT:
|
|
|
d1681e |
@@ -522,6 +425,19 @@ glusterd_op_remove_tier_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
case GF_DEFRAG_CMD_DETACH_COMMIT_FORCE:
|
|
|
d1681e |
+ if (cmd == GF_DEFRAG_CMD_DETACH_COMMIT_FORCE) {
|
|
|
d1681e |
+ svc = &(volinfo->tierd.svc);
|
|
|
d1681e |
+ ret = svc->manager (svc, volinfo,
|
|
|
d1681e |
+ PROC_START_NO_WAIT);
|
|
|
d1681e |
+ if (ret) {
|
|
|
d1681e |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
d1681e |
+ GD_MSG_MANAGER_FUNCTION_FAILED,
|
|
|
d1681e |
+ "calling manager for tier "
|
|
|
d1681e |
+ "failed on volume: %s for "
|
|
|
d1681e |
+ "commit force", volname);
|
|
|
d1681e |
+ goto out;
|
|
|
d1681e |
+ }
|
|
|
d1681e |
+ }
|
|
|
d1681e |
glusterd_op_perform_detach_tier (volinfo);
|
|
|
d1681e |
detach_commit = 1;
|
|
|
d1681e |
|
|
|
d1681e |
@@ -700,11 +616,6 @@ glusterd_op_remove_tier_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
|
|
d1681e |
if (cmd == GF_DEFRAG_CMD_DETACH_START &&
|
|
|
d1681e |
volinfo->status == GLUSTERD_STATUS_STARTED) {
|
|
|
d1681e |
|
|
|
d1681e |
- svc = &(volinfo->tierd.svc);
|
|
|
d1681e |
- ret = svc->reconfigure (volinfo);
|
|
|
d1681e |
- if (ret)
|
|
|
d1681e |
- goto out;
|
|
|
d1681e |
-
|
|
|
d1681e |
ret = glusterd_svcs_reconfigure ();
|
|
|
d1681e |
if (ret) {
|
|
|
d1681e |
gf_msg (this->name, GF_LOG_WARNING, 0,
|
|
|
d1681e |
@@ -773,6 +684,7 @@ glusterd_op_tier_start_stop (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
|
|
d1681e |
glusterd_conf_t *priv = NULL;
|
|
|
d1681e |
int32_t pid = -1;
|
|
|
d1681e |
char pidfile[PATH_MAX] = {0};
|
|
|
d1681e |
+ int is_force = 0;
|
|
|
d1681e |
|
|
|
d1681e |
this = THIS;
|
|
|
d1681e |
GF_VALIDATE_OR_GOTO (THIS->name, this, out);
|
|
|
d1681e |
@@ -814,24 +726,48 @@ glusterd_op_tier_start_stop (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
|
|
d1681e |
if (!retval)
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
|
|
|
d1681e |
+ if (glusterd_is_volume_started (volinfo) == 0) {
|
|
|
d1681e |
+ *op_errstr = gf_strdup ("Volume is stopped, start "
|
|
|
d1681e |
+ "volume to enable/disable tier.");
|
|
|
d1681e |
+ ret = -1;
|
|
|
d1681e |
+ goto out;
|
|
|
d1681e |
+ }
|
|
|
d1681e |
+
|
|
|
d1681e |
+ GLUSTERD_GET_TIER_PID_FILE(pidfile, volinfo, priv);
|
|
|
d1681e |
+
|
|
|
d1681e |
switch (cmd) {
|
|
|
d1681e |
case GF_DEFRAG_CMD_START_TIER:
|
|
|
d1681e |
- GLUSTERD_GET_TIER_PID_FILE(pidfile, volinfo, priv);
|
|
|
d1681e |
/* we check if its running and skip so that we dont get a
|
|
|
d1681e |
* failure during force start
|
|
|
d1681e |
*/
|
|
|
d1681e |
- if (gf_is_service_running (pidfile, &pid))
|
|
|
d1681e |
- goto out;
|
|
|
d1681e |
- ret = glusterd_tier_enable (volinfo, op_errstr);
|
|
|
d1681e |
- if (ret < 0)
|
|
|
d1681e |
- goto out;
|
|
|
d1681e |
- glusterd_store_perform_node_state_store (volinfo);
|
|
|
d1681e |
+ ret = dict_get_int32 (dict, "force", &is_force);
|
|
|
d1681e |
+ if (ret) {
|
|
|
d1681e |
+ gf_msg_debug (this->name, 0, "Unable to get is_force"
|
|
|
d1681e |
+ " from dict");
|
|
|
d1681e |
+ }
|
|
|
d1681e |
+ ret = dict_set_int32 (volinfo->dict, "force", is_force);
|
|
|
d1681e |
+ if (ret) {
|
|
|
d1681e |
+ gf_msg_debug (this->name, errno, "Unable to set"
|
|
|
d1681e |
+ " is_force to dict");
|
|
|
d1681e |
+ }
|
|
|
d1681e |
+
|
|
|
d1681e |
+ if (!is_force) {
|
|
|
d1681e |
+ if (gf_is_service_running (pidfile, &pid)) {
|
|
|
d1681e |
+ gf_asprintf (op_errstr, "Tier is already "
|
|
|
d1681e |
+ "enabled on volume %s." ,
|
|
|
d1681e |
+ volinfo->volname);
|
|
|
d1681e |
+ goto out;
|
|
|
d1681e |
+ }
|
|
|
d1681e |
+ }
|
|
|
d1681e |
+
|
|
|
d1681e |
break;
|
|
|
d1681e |
|
|
|
d1681e |
case GF_DEFRAG_CMD_STOP_TIER:
|
|
|
d1681e |
- ret = glusterd_tier_disable (volinfo, op_errstr);
|
|
|
d1681e |
- if (ret < 0)
|
|
|
d1681e |
+ if (!gf_is_service_running (pidfile, &pid)) {
|
|
|
d1681e |
+ gf_asprintf (op_errstr, "Tier is alreaady disabled on "
|
|
|
d1681e |
+ "volume %s.", volinfo->volname);
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
+ }
|
|
|
d1681e |
break;
|
|
|
d1681e |
default:
|
|
|
d1681e |
gf_asprintf (op_errstr, "tier command failed. Invalid "
|
|
|
d1681e |
@@ -840,7 +776,8 @@ glusterd_op_tier_start_stop (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
- ret = glusterd_manage_tier (volinfo, cmd);
|
|
|
d1681e |
+ ret = volinfo->tierd.svc.manager (&(volinfo->tierd.svc),
|
|
|
d1681e |
+ volinfo, PROC_START_NO_WAIT);
|
|
|
d1681e |
if (ret)
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
|
|
|
d1681e |
@@ -977,6 +914,19 @@ glusterd_op_stage_tier (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
|
|
d1681e |
"start validate failed");
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
}
|
|
|
d1681e |
+ if (volinfo->tier.op == GD_OP_DETACH_TIER) {
|
|
|
d1681e |
+ snprintf (msg, sizeof (msg), "A detach tier task "
|
|
|
d1681e |
+ "exists for volume %s. Either commit it"
|
|
|
d1681e |
+ " or stop it before starting a new task.",
|
|
|
d1681e |
+ volinfo->volname);
|
|
|
d1681e |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
d1681e |
+ GD_MSG_OLD_REMOVE_BRICK_EXISTS,
|
|
|
d1681e |
+ "Earlier detach-tier"
|
|
|
d1681e |
+ " task exists for volume %s.",
|
|
|
d1681e |
+ volinfo->volname);
|
|
|
d1681e |
+ ret = -1;
|
|
|
d1681e |
+ goto out;
|
|
|
d1681e |
+ }
|
|
|
d1681e |
break;
|
|
|
d1681e |
|
|
|
d1681e |
case GF_DEFRAG_CMD_STOP_TIER:
|
|
|
d1681e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-tierd-svc.c b/xlators/mgmt/glusterd/src/glusterd-tierd-svc.c
|
|
|
d1681e |
index c75b378..a2876ae 100644
|
|
|
d1681e |
--- a/xlators/mgmt/glusterd/src/glusterd-tierd-svc.c
|
|
|
d1681e |
+++ b/xlators/mgmt/glusterd/src/glusterd-tierd-svc.c
|
|
|
d1681e |
@@ -72,6 +72,8 @@ glusterd_tierdsvc_init (void *data)
|
|
|
d1681e |
notify = glusterd_svc_common_rpc_notify;
|
|
|
d1681e |
glusterd_store_perform_node_state_store (volinfo);
|
|
|
d1681e |
|
|
|
d1681e |
+ volinfo->type = GF_CLUSTER_TYPE_TIER;
|
|
|
d1681e |
+
|
|
|
d1681e |
glusterd_svc_build_tierd_rundir (volinfo, rundir, sizeof (rundir));
|
|
|
d1681e |
glusterd_svc_create_rundir (rundir);
|
|
|
d1681e |
|
|
|
d1681e |
@@ -150,6 +152,7 @@ glusterd_tierdsvc_manager (glusterd_svc_t *svc, void *data, int flags)
|
|
|
d1681e |
int ret = 0;
|
|
|
d1681e |
xlator_t *this = THIS;
|
|
|
d1681e |
glusterd_volinfo_t *volinfo = NULL;
|
|
|
d1681e |
+ int is_force = 0;
|
|
|
d1681e |
|
|
|
d1681e |
volinfo = data;
|
|
|
d1681e |
GF_VALIDATE_OR_GOTO (this->name, data, out);
|
|
|
d1681e |
@@ -169,25 +172,29 @@ glusterd_tierdsvc_manager (glusterd_svc_t *svc, void *data, int flags)
|
|
|
d1681e |
}
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
- ret = glusterd_is_tierd_enabled (volinfo);
|
|
|
d1681e |
- if (ret == -1) {
|
|
|
d1681e |
- gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
d1681e |
- GD_MSG_VOLINFO_GET_FAIL, "Failed to read volume "
|
|
|
d1681e |
- "options");
|
|
|
d1681e |
- goto out;
|
|
|
d1681e |
+ ret = dict_get_int32 (volinfo->dict, "force", &is_force);
|
|
|
d1681e |
+ if (ret) {
|
|
|
d1681e |
+ gf_msg_debug (this->name, errno, "Unable to get"
|
|
|
d1681e |
+ " is_force from dict");
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
+ if (is_force)
|
|
|
d1681e |
+ ret = 1;
|
|
|
d1681e |
+ else
|
|
|
d1681e |
+ ret = (glusterd_is_tierd_supposed_to_be_enabled (volinfo));
|
|
|
d1681e |
+
|
|
|
d1681e |
if (ret) {
|
|
|
d1681e |
if (!glusterd_is_volume_started (volinfo)) {
|
|
|
d1681e |
if (glusterd_proc_is_running (&svc->proc)) {
|
|
|
d1681e |
ret = svc->stop (svc, SIGTERM);
|
|
|
d1681e |
if (ret)
|
|
|
d1681e |
gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
d1681e |
- GD_MSG_TIERD_STOP_FAIL,
|
|
|
d1681e |
+ GD_MSG_SNAPD_STOP_FAIL,
|
|
|
d1681e |
"Couldn't stop tierd for "
|
|
|
d1681e |
"volume: %s",
|
|
|
d1681e |
volinfo->volname);
|
|
|
d1681e |
} else {
|
|
|
d1681e |
+ /* Since tierd is not running set ret to 0 */
|
|
|
d1681e |
ret = 0;
|
|
|
d1681e |
}
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
@@ -209,6 +216,7 @@ glusterd_tierdsvc_manager (glusterd_svc_t *svc, void *data, int flags)
|
|
|
d1681e |
"tierd for volume: %s", volinfo->volname);
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
}
|
|
|
d1681e |
+ volinfo->is_tier_enabled = _gf_true;
|
|
|
d1681e |
|
|
|
d1681e |
glusterd_volinfo_ref (volinfo);
|
|
|
d1681e |
ret = glusterd_conn_connect (&(svc->conn));
|
|
|
d1681e |
@@ -216,16 +224,19 @@ glusterd_tierdsvc_manager (glusterd_svc_t *svc, void *data, int flags)
|
|
|
d1681e |
glusterd_volinfo_unref (volinfo);
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
}
|
|
|
d1681e |
-
|
|
|
d1681e |
- } else if (glusterd_proc_is_running (&svc->proc)) {
|
|
|
d1681e |
- ret = svc->stop (svc, SIGTERM);
|
|
|
d1681e |
- if (ret) {
|
|
|
d1681e |
- gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
d1681e |
- GD_MSG_TIERD_STOP_FAIL,
|
|
|
d1681e |
- "Couldn't stop tierd for volume: %s",
|
|
|
d1681e |
- volinfo->volname);
|
|
|
d1681e |
- goto out;
|
|
|
d1681e |
+ } else {
|
|
|
d1681e |
+ if (glusterd_proc_is_running (&svc->proc)) {
|
|
|
d1681e |
+ ret = svc->stop (svc, SIGTERM);
|
|
|
d1681e |
+ if (ret) {
|
|
|
d1681e |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
d1681e |
+ GD_MSG_TIERD_STOP_FAIL,
|
|
|
d1681e |
+ "Couldn't stop tierd for volume: %s",
|
|
|
d1681e |
+ volinfo->volname);
|
|
|
d1681e |
+ goto out;
|
|
|
d1681e |
+ }
|
|
|
d1681e |
+ volinfo->is_tier_enabled = _gf_false;
|
|
|
d1681e |
}
|
|
|
d1681e |
+ ret = 0;
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
out:
|
|
|
d1681e |
@@ -361,7 +372,6 @@ out:
|
|
|
d1681e |
return ret;
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
-
|
|
|
d1681e |
int
|
|
|
d1681e |
glusterd_tierdsvc_restart ()
|
|
|
d1681e |
{
|
|
|
d1681e |
@@ -379,15 +389,18 @@ glusterd_tierdsvc_restart ()
|
|
|
d1681e |
cds_list_for_each_entry (volinfo, &conf->volumes, vol_list) {
|
|
|
d1681e |
/* Start per volume tierd svc */
|
|
|
d1681e |
if (volinfo->status == GLUSTERD_STATUS_STARTED &&
|
|
|
d1681e |
- glusterd_is_tierd_enabled (volinfo)) {
|
|
|
d1681e |
+ volinfo->type == GF_CLUSTER_TYPE_TIER) {
|
|
|
d1681e |
svc = &(volinfo->tierd.svc);
|
|
|
d1681e |
- ret = svc->manager (svc, volinfo, PROC_START_NO_WAIT);
|
|
|
d1681e |
- if (ret) {
|
|
|
d1681e |
- gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
d1681e |
- GD_MSG_TIERD_START_FAIL,
|
|
|
d1681e |
- "Couldn't restart tierd for "
|
|
|
d1681e |
- "vol: %s", volinfo->volname);
|
|
|
d1681e |
- goto out;
|
|
|
d1681e |
+ if (volinfo->tier.op != GD_OP_DETACH_TIER) {
|
|
|
d1681e |
+ ret = svc->manager (svc, volinfo,
|
|
|
d1681e |
+ PROC_START_NO_WAIT);
|
|
|
d1681e |
+ if (ret) {
|
|
|
d1681e |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
d1681e |
+ GD_MSG_TIERD_START_FAIL,
|
|
|
d1681e |
+ "Couldn't restart tierd for "
|
|
|
d1681e |
+ "vol: %s", volinfo->volname);
|
|
|
d1681e |
+ goto out;
|
|
|
d1681e |
+ }
|
|
|
d1681e |
}
|
|
|
d1681e |
}
|
|
|
d1681e |
}
|
|
|
d1681e |
@@ -418,7 +431,7 @@ glusterd_tierdsvc_reconfigure (void *data)
|
|
|
d1681e |
this = THIS;
|
|
|
d1681e |
GF_VALIDATE_OR_GOTO (THIS->name, this, out);
|
|
|
d1681e |
|
|
|
d1681e |
- if (glusterd_is_tierd_enabled (volinfo))
|
|
|
d1681e |
+ if (!glusterd_is_tierd_enabled (volinfo))
|
|
|
d1681e |
goto manager;
|
|
|
d1681e |
/*
|
|
|
d1681e |
* Check both OLD and NEW volfiles, if they are SAME by size
|
|
|
d1681e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
d1681e |
index 23fc6e9..504e5af 100644
|
|
|
d1681e |
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
d1681e |
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
d1681e |
@@ -11964,6 +11964,16 @@ glusterd_is_volume_inode_quota_enabled (glusterd_volinfo_t *volinfo)
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
int
|
|
|
d1681e |
+glusterd_is_tierd_supposed_to_be_enabled (glusterd_volinfo_t *volinfo)
|
|
|
d1681e |
+{
|
|
|
d1681e |
+ if ((volinfo->type != GF_CLUSTER_TYPE_TIER) ||
|
|
|
d1681e |
+ (volinfo->tier.op == GD_OP_DETACH_TIER))
|
|
|
d1681e |
+ return _gf_false;
|
|
|
d1681e |
+ else
|
|
|
d1681e |
+ return _gf_true;
|
|
|
d1681e |
+}
|
|
|
d1681e |
+
|
|
|
d1681e |
+int
|
|
|
d1681e |
glusterd_is_tierd_enabled (glusterd_volinfo_t *volinfo)
|
|
|
d1681e |
{
|
|
|
d1681e |
return volinfo->is_tier_enabled;
|
|
|
d1681e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
|
|
|
d1681e |
index b802f6c..abaec4b 100644
|
|
|
d1681e |
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
|
|
|
d1681e |
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
|
|
|
d1681e |
@@ -629,6 +629,9 @@ int
|
|
|
d1681e |
glusterd_is_tierd_enabled (glusterd_volinfo_t *volinfo);
|
|
|
d1681e |
|
|
|
d1681e |
int
|
|
|
d1681e |
+glusterd_is_tierd_supposed_to_be_enabled (glusterd_volinfo_t *volinfo);
|
|
|
d1681e |
+
|
|
|
d1681e |
+int
|
|
|
d1681e |
glusterd_is_volume_quota_enabled (glusterd_volinfo_t *volinfo);
|
|
|
d1681e |
|
|
|
d1681e |
int
|
|
|
d1681e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
|
|
|
d1681e |
index 222d5f4..de97e6a 100644
|
|
|
d1681e |
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
|
|
|
d1681e |
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
|
|
|
d1681e |
@@ -2757,6 +2757,16 @@ glusterd_stop_volume (glusterd_volinfo_t *volinfo)
|
|
|
d1681e |
}
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
+ /* call tier manager before the voluem status is set as stopped
|
|
|
d1681e |
+ * as tier uses that as a check in the manager
|
|
|
d1681e |
+ * */
|
|
|
d1681e |
+ if (volinfo->type == GF_CLUSTER_TYPE_TIER) {
|
|
|
d1681e |
+ svc = &(volinfo->tierd.svc);
|
|
|
d1681e |
+ ret = svc->manager (svc, volinfo, PROC_START_NO_WAIT);
|
|
|
d1681e |
+ if (ret)
|
|
|
d1681e |
+ goto out;
|
|
|
d1681e |
+ }
|
|
|
d1681e |
+
|
|
|
d1681e |
glusterd_set_volume_status (volinfo, GLUSTERD_STATUS_STOPPED);
|
|
|
d1681e |
|
|
|
d1681e |
ret = glusterd_store_volinfo (volinfo, GLUSTERD_VOLINFO_VER_AC_INCREMENT);
|
|
|
d1681e |
@@ -2774,13 +2784,6 @@ glusterd_stop_volume (glusterd_volinfo_t *volinfo)
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
- if (volinfo->type == GF_CLUSTER_TYPE_TIER) {
|
|
|
d1681e |
- svc = &(volinfo->tierd.svc);
|
|
|
d1681e |
- ret = svc->manager (svc, volinfo, PROC_START_NO_WAIT);
|
|
|
d1681e |
- if (ret)
|
|
|
d1681e |
- goto out;
|
|
|
d1681e |
- }
|
|
|
d1681e |
-
|
|
|
d1681e |
ret = glusterd_svcs_manager (volinfo);
|
|
|
d1681e |
if (ret) {
|
|
|
d1681e |
gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
d1681e |
--
|
|
|
d1681e |
1.8.3.1
|
|
|
d1681e |
|