cb8e9e
From b9464c0b0efc95956b914a0ef25200a471b840c3 Mon Sep 17 00:00:00 2001
cb8e9e
From: Mohammed Rafi KC <rkavunga@redhat.com>
cb8e9e
Date: Thu, 4 Jun 2015 14:14:14 +0530
cb8e9e
Subject: [PATCH 120/129] glusterd/tier: glusterd crashed with detach-tier commit force
cb8e9e
cb8e9e
this patch has is a back port of fix 11081
cb8e9e
cb8e9e
glusterd crashed when doing "detach-tier commit force" on a
cb8e9e
non-tiered volume.
cb8e9e
cb8e9e
> Change-Id: I884771893bb80bec46ae8642c2cfd7e54ab116a6
cb8e9e
> BUG:  1229274
cb8e9e
> Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
cb8e9e
> Reviewed-on: http://review.gluster.org/11081
cb8e9e
> Tested-by: Gluster Build System <jenkins@build.gluster.com>
cb8e9e
> Tested-by: NetBSD Build System <jenkins@build.gluster.org>
cb8e9e
> Reviewed-by: Dan Lambright <dlambrig@redhat.com>
cb8e9e
> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
cb8e9e
> Signed-off-by: Joseph Fernandes <josferna@redhat.com>
cb8e9e
cb8e9e
Change-Id: I884771893bb80bec46ae8642c2cfd7e54ab116a6
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/50622
cb8e9e
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
cb8e9e
Tested-by: Dan Lambright <dlambrig@redhat.com>
cb8e9e
---
cb8e9e
 cli/src/cli-rpc-ops.c                          |    2 +-
cb8e9e
 xlators/mgmt/glusterd/src/glusterd-brick-ops.c |    7 +++++++
cb8e9e
 xlators/mgmt/glusterd/src/glusterd-rebalance.c |    9 ++++++++-
cb8e9e
 3 files changed, 16 insertions(+), 2 deletions(-)
cb8e9e
cb8e9e
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
cb8e9e
index 290028f..a834147 100644
cb8e9e
--- a/cli/src/cli-rpc-ops.c
cb8e9e
+++ b/cli/src/cli-rpc-ops.c
cb8e9e
@@ -1784,7 +1784,7 @@ gf_cli_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov,
cb8e9e
                                   rsp.op_errstr);
cb8e9e
                 }
cb8e9e
         }
cb8e9e
-        if (cmd == GF_DEFRAG_CMD_STATUS) {
cb8e9e
+        if (cmd == GF_DEFRAG_CMD_STATUS || cmd == GF_DEFRAG_CMD_STATUS_TIER) {
cb8e9e
                 if (rsp.op_ret == -1) {
cb8e9e
                         if (strcmp (rsp.op_errstr, ""))
cb8e9e
                                 snprintf (msg, sizeof (msg),
cb8e9e
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
cb8e9e
index a3fda98..7dc34c2 100644
cb8e9e
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
cb8e9e
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
cb8e9e
@@ -1888,6 +1888,13 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr)
cb8e9e
                 break;
cb8e9e
 
cb8e9e
         case GF_OP_CMD_DETACH_COMMIT_FORCE:
cb8e9e
+                if (volinfo->type != GF_CLUSTER_TYPE_TIER) {
cb8e9e
+                        snprintf (msg, sizeof(msg), "volume %s is not a tier "
cb8e9e
+                                  "volume", volinfo->volname);
cb8e9e
+                        errstr = gf_strdup (msg);
cb8e9e
+                        gf_log (this->name, GF_LOG_ERROR, "%s", errstr);
cb8e9e
+                        goto out;
cb8e9e
+                }
cb8e9e
         case GF_OP_CMD_COMMIT_FORCE:
cb8e9e
                 break;
cb8e9e
         }
cb8e9e
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
cb8e9e
index 4fd95c2..8449bb2 100644
cb8e9e
--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c
cb8e9e
+++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
cb8e9e
@@ -606,9 +606,15 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
         switch (cmd) {
cb8e9e
+        case GF_DEFRAG_CMD_START_TIER:
cb8e9e
+                if (volinfo->type != GF_CLUSTER_TYPE_TIER) {
cb8e9e
+                        gf_asprintf (op_errstr, "volume %s is not a tier "
cb8e9e
+                                     "volume.", volinfo->volname);
cb8e9e
+                        ret = -1;
cb8e9e
+                        goto out;
cb8e9e
+                }
cb8e9e
         case GF_DEFRAG_CMD_START:
cb8e9e
         case GF_DEFRAG_CMD_START_LAYOUT_FIX:
cb8e9e
-        case GF_DEFRAG_CMD_START_TIER:
cb8e9e
                 /* Check if the connected clients are all of version
cb8e9e
                  * RHS-2.1u5 and higher. This is needed to prevent some data
cb8e9e
                  * loss issues that could occur when older clients are connected
cb8e9e
@@ -668,6 +674,7 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
cb8e9e
                         goto out;
cb8e9e
                 }
cb8e9e
                 break;
cb8e9e
+        case GF_DEFRAG_CMD_STATUS_TIER:
cb8e9e
         case GF_DEFRAG_CMD_STATUS:
cb8e9e
         case GF_DEFRAG_CMD_STOP:
cb8e9e
         case GF_DEFRAG_CMD_STOP_DETACH_TIER:
cb8e9e
-- 
cb8e9e
1.7.1
cb8e9e