diff options
| -rw-r--r-- | cli/src/cli-cmd-parser.c | 2 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 25 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-rebalance.c | 9 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-replace-brick.c | 8 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 65 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.h | 4 | 
6 files changed, 112 insertions, 1 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 2ca5948d552..d4c846acd0a 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -1698,7 +1698,7 @@ cli_cmd_volume_detach_tier_parse (const char **words, int wordcount,          } else if (!strcmp(word, "stop"))                  command = GF_OP_CMD_STOP_DETACH_TIER;          else if (!strcmp(word, "status")) -                command = GF_DEFRAG_CMD_STATUS; +                command = GF_OP_CMD_STATUS;          else                  goto out; diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c index 13d0753704c..f2e7d3a9d3e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c @@ -511,6 +511,14 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req)                  goto brick_val;          } +        ret = glusterd_disallow_op_for_tier (volinfo, GD_OP_ADD_BRICK, -1); +        if (ret) { +                snprintf (err_str, sizeof (err_str), "Add-brick operation is " +                          "not supported on a tiered volume %s", volname); +                gf_log (this->name, GF_LOG_ERROR, "%s", err_str); +                goto out; +        } +          if (!stripe_count && !replica_count) {                  if (volinfo->type == GF_CLUSTER_TYPE_NONE)                          goto brick_val; @@ -753,6 +761,7 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req)          int32_t                   replica_count    = 0;          char                     *volname          = 0;          xlator_t                 *this             = NULL; +        int                       cmd              = -1;          GF_ASSERT (req);          this = THIS; @@ -818,6 +827,22 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req)                  goto out;          } +        ret = dict_get_int32 (dict, "command", &cmd); +        if (ret) { +                snprintf (err_str, sizeof (err_str), "Unable to get cmd " +                          "ccommand"); +                gf_log (this->name, GF_LOG_ERROR, "%s", err_str); +                goto out; +        } + +        ret = glusterd_disallow_op_for_tier (volinfo, GD_OP_REMOVE_BRICK, cmd); +        if (ret) { +                snprintf (err_str, sizeof (err_str), +                          "Removing brick from a Tier volume is not allowed"); +                gf_log (this->name, GF_LOG_ERROR, "%s", err_str); +                goto out; +        } +          ret = dict_get_int32 (dict, "replica-count", &replica_count);          if (!ret) {                  gf_log (this->name, GF_LOG_INFO, diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c index cf8ee3a79f7..9111c07b8fc 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c +++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c @@ -424,6 +424,15 @@ glusterd_rebalance_cmd_validate (int cmd, char *volname,                  goto out;          } +        ret = glusterd_disallow_op_for_tier (*volinfo, GD_OP_REBALANCE, cmd); +        if (ret) { +                gf_log ("glusterd", GF_LOG_ERROR, "Received rebalance command " +                        "on Tier volume %s", volname); +                snprintf (op_errstr, len, "Rebalance operations are not " +                          "supported on a tiered volume"); +                goto out; +        } +          ret = 0;  out: diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c index 818b58a724f..cb9c67cc7dc 100644 --- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c +++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c @@ -243,6 +243,14 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr,                  goto out;          } +        ret = glusterd_disallow_op_for_tier (volinfo, GD_OP_REPLACE_BRICK, -1); +        if (ret) { +                snprintf (msg, sizeof (msg), "Replace brick commands are not " +                          "supported on tiered volume %s", volname); +                *op_errstr = gf_strdup (msg); +                goto out; +        } +          if (!glusterd_store_is_valid_brickpath (volname, dst_brick) ||                  !glusterd_is_valid_volfpath (volname, dst_brick)) {                  snprintf (msg, sizeof (msg), "brick path %s is too " diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 9445de77127..deb0123c435 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -9644,3 +9644,68 @@ glusterd_list_add_order (struct cds_list_head *new, struct cds_list_head *head,          cds_list_add_rcu (new, rcu_dereference (pos->prev));  } + + +int +glusterd_disallow_op_for_tier (glusterd_volinfo_t *volinfo, glusterd_op_t op, +                               int cmd) +{ + +        xlator_t          *this       = NULL; +        int                ret        = 0; + +        this = THIS; +        GF_VALIDATE_OR_GOTO (this->name, volinfo, out); + +        if (volinfo->type != GF_CLUSTER_TYPE_TIER) +                goto out; + +        switch (op) { +        case GD_OP_ADD_BRICK: +        case GD_OP_REPLACE_BRICK: +                ret = -1; +                gf_log (this->name, GF_LOG_DEBUG, "Operation not " +                        "permitted on tiered volume %s", +                        volinfo->volname); +                break; +        case GD_OP_REBALANCE: +                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_STATUS: +                        ret = 0; +                        break; +                default: +                        gf_log (this->name, GF_LOG_DEBUG, +                             "Rebalance Operation not permitted" +                             " on tiered volume %s", +                             volinfo->volname); +                        ret = -1; +                        break; +                } +                break; +        case GD_OP_REMOVE_BRICK: +                switch (cmd) { +                case GF_OP_CMD_DETACH_COMMIT_FORCE: +                case GF_OP_CMD_DETACH_COMMIT: +                case GF_OP_CMD_DETACH_START: +                case GF_DEFRAG_CMD_STOP_DETACH_TIER: +                        ret = 0; +                        break; +                default: +                        gf_log (this->name, GF_LOG_DEBUG, +                             "Remove brick operation not " +                             "permitted on tiered volume %s", +                             volinfo->volname); +                        ret = -1; +                        break; +                } +                break; +        default: +                break; +        } +out: +        return ret; +} diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index fcfddd5bffa..8975e53f91b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -650,4 +650,8 @@ void  glusterd_list_add_order (struct cds_list_head *new, struct cds_list_head *head,                          int (*compare)(struct cds_list_head *,                                         struct cds_list_head *)); +int +glusterd_disallow_op_for_tier (glusterd_volinfo_t *volinfo, glusterd_op_t op, +                               int cmd); +  #endif  | 
