diff options
| author | Krishnan Parthasarathi <kp@gluster.com> | 2011-10-19 15:17:13 +0530 | 
|---|---|---|
| committer | Vijay Bellur <vijay@gluster.com> | 2011-10-24 06:17:34 -0700 | 
| commit | ffb3e103e2ead4a1b207a57e75eee683e8de5ad9 (patch) | |
| tree | 9879a291157491e506aee7b3bea92f6ffea571a9 | |
| parent | 333bd9b59c4298a7cb7796f3bd4ee444376c68c6 (diff) | |
glusterd: Fail volume 'modify' operations when rb is ongoing.
add-brick, stop-volume, remove-brick are the operations that are explicitly
'failed' when attempted while replace-brick is in progress.
Change-Id: Ia8034177e03a9ab10f9e8d5c8bc417427a1218e3
BUG: 3738
Reviewed-on: http://review.gluster.com/631
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amar@gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 154 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.h | 3 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 39 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.h | 4 | 
4 files changed, 62 insertions, 138 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index de64e8be8..4dab7a653 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -532,6 +532,18 @@ glusterd_op_stage_stop_volume (dict_t *dict, char **op_errstr)                          ret = -1;                          goto out;                  } + +                if (glusterd_is_rb_ongoing (volinfo)) { +                        snprintf (msg, sizeof (msg), "Replace brick is in " +                                  "progress on volume %s. Please try after " +                                  "replace-brick operation is committed " +                                  "or aborted.", volname); +                        gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); +                        *op_errstr = gf_strdup (msg); +                        ret = -1; +                        goto out; +                } +                  ret = glusterd_check_gsync_running (volinfo, &is_run);                  if (ret && (is_run == _gf_false))                          gf_log ("", GF_LOG_WARNING, "Unable to get the status" @@ -648,6 +660,17 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr)                  goto out;          } +        if (glusterd_is_rb_ongoing (volinfo)) { +                snprintf (msg, sizeof (msg), "Replace brick is in " +                          "progress on volume %s. Please try after " +                          "replace-brick operation is committed " +                          "or aborted.", volname); +                gf_log (THIS->name, GF_LOG_ERROR, "%s", msg); +                *op_errstr = gf_strdup (msg); +                ret = -1; +                goto out; +        } +          if (glusterd_is_defrag_on(volinfo)) {                  snprintf (msg, sizeof(msg), "Volume name %s rebalance is in "                            "progress. Please retry after completion", volname); @@ -674,17 +697,6 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr)                  free_ptr = brick_list;          } -        /* Check whether any of the bricks given is the destination brick of the -           replace brick running */ - -        str_ret = glusterd_check_brick_rb_part (all_bricks, count, volinfo); -        if (str_ret) { -                gf_log ("glusterd", GF_LOG_ERROR, -                        "%s", str_ret); -                *op_errstr = gf_strdup (str_ret); -                ret = -1; -                goto out; -        }          if (count)                  brick = strtok_r (brick_list+1, " \n", &saveptr); @@ -746,64 +758,6 @@ out:          return ret;  } -char * -glusterd_check_brick_rb_part (char *bricks, int count, glusterd_volinfo_t *volinfo) -{ -        char                                    *saveptr = NULL; -        char                                    *brick = NULL; -        char                                    *brick_list = NULL; -        int                                     ret = 0; -        glusterd_brickinfo_t                    *brickinfo = NULL; -        uint32_t                                i = 0; -        char                                    *str = NULL; -        char                                    msg[2048] = {0,}; - -        brick_list = gf_strdup (bricks); -        if (!brick_list) { -                gf_log ("glusterd", GF_LOG_ERROR, -                        "Out of memory"); -                ret = -1; -                goto out; -        } - -        if (count) -                brick = strtok_r (brick_list+1, " \n", &saveptr); - - -        while ( i < count) { -                ret = glusterd_brickinfo_from_brick (brick, &brickinfo); -                if (ret) { -                        snprintf (msg, sizeof(msg), "Unable to" -                                  " get brickinfo"); -                        gf_log ("", GF_LOG_ERROR, "%s", msg); -                        ret = -1; -                        goto out; -                } - -                if (glusterd_is_replace_running (volinfo, brickinfo)) { -                        snprintf (msg, sizeof(msg), "Volume %s: replace brick is running" -                          " and the brick %s:%s you are trying to add is the destination brick" -                          " for replace brick", volinfo->volname, brickinfo->hostname, brickinfo->path); -                        ret = -1; -                        goto out; -                } - -                glusterd_brickinfo_delete (brickinfo); -                brickinfo = NULL; -                brick = strtok_r (NULL, " \n", &saveptr); -                i++; -        } - -out: -        if (brick_list) -                GF_FREE(brick_list); -        if (brickinfo) -                glusterd_brickinfo_delete (brickinfo); -        if (ret) -                str = gf_strdup (msg); -        return str; -} -  static int  glusterd_get_rb_dst_brickinfo (glusterd_volinfo_t *volinfo,                                 glusterd_brickinfo_t **brickinfo) @@ -1613,22 +1567,18 @@ glusterd_op_stage_remove_brick (dict_t *dict)                  goto out;          } +        if (glusterd_is_rb_ongoing (volinfo)) { +                ret = gf_asprintf (&errstr, "Replace brick is in progress on " +                                   "volume %s. Please try after replace-brick " +                                   "operation is committed or aborted.", +                                   volname); +                ret = -1; +                goto out; +        } +          if (glusterd_is_defrag_on(volinfo)) { -                ctx = glusterd_op_get_ctx (GD_OP_REMOVE_BRICK);                  errstr = gf_strdup("Rebalance is in progress. Please retry"                                      " after completion"); -                if (!errstr) { -                        ret = -1; -                        goto out; -                } -                gf_log ("glusterd", GF_LOG_ERROR, "%s", errstr); -                ret = dict_set_dynstr (ctx, "errstr", errstr); -                if (ret) { -                        GF_FREE (errstr); -                        gf_log ("", GF_LOG_DEBUG, -                                "failed to set errstr ctx"); -                        goto out; -                }                  ret = -1;                  goto out; @@ -1641,34 +1591,34 @@ glusterd_op_stage_remove_brick (dict_t *dict)          }          if (volinfo->brick_count == brick_count) { -                ctx = glusterd_op_get_ctx (GD_OP_REMOVE_BRICK); -                if (!ctx) { -                        gf_log ("", GF_LOG_ERROR, -                                "Operation Context is not present"); -                        ret = -1; -                        goto out; -                }                  errstr = gf_strdup ("Deleting all the bricks of the "                                      "volume is not allowed"); -                if (!errstr) { -                        gf_log ("", GF_LOG_ERROR, "Out of memory"); -                        ret = -1; -                        goto out; -                } - -                ret = dict_set_dynstr (ctx, "errstr", errstr); -                if (ret) { -                        GF_FREE (errstr); -                        gf_log ("", GF_LOG_DEBUG, -                                "failed to set pump status in ctx"); -                        goto out; -                }                  ret = -1;                  goto out;          }  out: +        if (!errstr) +                goto ret; + +        gf_log (THIS->name, GF_LOG_ERROR, "%s", errstr); +        ctx = glusterd_op_get_ctx (GD_OP_REMOVE_BRICK); +        if (!ctx) { +                gf_log ("", GF_LOG_ERROR, +                        "Operation Context is not present"); +                ret = -1; +                goto ret; +        } +        if (dict_set_dynstr (ctx, "errstr", errstr)) { +                GF_FREE (errstr); +                gf_log ("", GF_LOG_DEBUG, +                        "failed to set errstr ctx"); +                ret = -1; +                goto ret; +        } + +ret:          gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);          return ret; diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h index 5dc1a5637..0830f9a16 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h @@ -256,9 +256,6 @@ glusterd_check_option_exists(char *optstring, char **completion);  int  set_xlator_option (dict_t *dict, char *key, char *value); -char * -glusterd_check_brick_rb_part (char *bricks, int count, glusterd_volinfo_t *volinfo); -  void  glusterd_do_replace_brick (void *data);  int diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index e2ab6d38b..c7edefc03 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -2843,41 +2843,18 @@ glusterd_is_defrag_on (glusterd_volinfo_t *volinfo)          return (volinfo->defrag != NULL);  } -int -glusterd_is_replace_running (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *brickinfo) +gf_boolean_t +glusterd_is_rb_ongoing (glusterd_volinfo_t *volinfo)  { -        int ret = 0; -        char *src_hostname = NULL; -        char *brick_hostname = NULL; - -        if (volinfo->src_brick) { -                src_hostname = gf_strdup (volinfo->src_brick->hostname); -                if (!src_hostname) { -                        ret = -1; -                        goto out; -                } -        } else { -                gf_log ("glusterd", GF_LOG_DEBUG, -                        "replace brick is not running"); -                goto out; -        } +        GF_ASSERT (volinfo); +        gf_boolean_t    ongoing = _gf_false; -        brick_hostname = gf_strdup (brickinfo->hostname); -        if (!brick_hostname) { -                ret = -1; -                goto out; -        } -        if (!glusterd_is_local_addr (src_hostname) && !glusterd_is_local_addr (brick_hostname)) { -                if (glusterd_is_rb_started (volinfo) || glusterd_is_rb_paused (volinfo)) -                        ret = -1; +        if (glusterd_is_rb_started (volinfo) +            || glusterd_is_rb_paused (volinfo)) { +                ongoing = _gf_true;          } -out: -        if (src_hostname) -                GF_FREE (src_hostname); -        if (brick_hostname) -                GF_FREE (brick_hostname); -        return ret; +        return ongoing;  }  int diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index ae140363a..6632a313c 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -225,8 +225,8 @@ glusterd_is_rb_paused (glusterd_volinfo_t *volinfo);  int  glusterd_set_rb_status (glusterd_volinfo_t *volinfo, gf_rb_status_t status); -int -glusterd_is_replace_running (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *brickinfo); +gf_boolean_t +glusterd_is_rb_ongoing (glusterd_volinfo_t *volinfo);  int  glusterd_rb_check_bricks (glusterd_volinfo_t *volinfo,  | 
