diff options
author | shishir gowda <shishirng@gluster.com> | 2010-09-30 03:41:04 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-09-30 06:57:59 -0700 |
commit | bf152d98cee31a2346f3aec32301ca4a4bbfcea1 (patch) | |
tree | 6ecc21800004d86b9e57d33bde1300ae82dc21fb /xlators | |
parent | d39ed89765a8d0a1f767b864fd6826d29de7ad1f (diff) |
Block add, remove and replace brick ops when rebalance is in progress
Also fixing msg, changing defrag to rebalance
Signed-off-by: shishir gowda <shishirng@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 971 (dynamic volume management)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 10 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 39 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 6 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.h | 3 |
4 files changed, 52 insertions, 6 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index f66a5b3d28c..439facef0b9 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -837,7 +837,7 @@ glusterd_defrag_start (void *data) volinfo->lookedup_files = defrag->num_files_lookedup; out: if (defrag) { - gf_log ("defrag", GF_LOG_NORMAL, "defrag on %s complete", + gf_log ("rebalance", GF_LOG_NORMAL, "rebalance on %s complete", defrag->mount); snprintf (cmd_str, 1024, "umount -l %s", defrag->mount); @@ -931,19 +931,19 @@ glusterd_handle_defrag_volume (rpcsvc_request_t *req) default: break; } - gf_log ("glusterd", GF_LOG_NORMAL, "Received defrag volume on %s", + gf_log ("glusterd", GF_LOG_NORMAL, "Received rebalance volume on %s", cli_req.volname); rsp.volname = cli_req.volname; rsp.op_ret = -1; if (glusterd_volinfo_find(cli_req.volname, &volinfo)) { - gf_log ("glusterd", GF_LOG_NORMAL, "Received defrag on invalid" + gf_log ("glusterd", GF_LOG_NORMAL, "Received rebalance on invalid" " volname %s", cli_req.volname); goto out; } if (volinfo->status != GLUSTERD_STATUS_STARTED) { - gf_log ("glusterd", GF_LOG_NORMAL, "Received defrag on stopped" + gf_log ("glusterd", GF_LOG_NORMAL, "Received rebalance on stopped" " volname %s", cli_req.volname); goto out; } @@ -953,7 +953,7 @@ glusterd_handle_defrag_volume (rpcsvc_request_t *req) { if (volinfo->defrag) { gf_log ("glusterd", GF_LOG_DEBUG, - "defrag on volume %s already started", + "rebalance on volume %s already started", cli_req.volname); goto out; } diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index e5cf57514db..e3a9777c6c3 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -681,6 +681,14 @@ glusterd_op_stage_add_brick (gd1_mgmt_stage_op_req *req, char **op_errstr) goto out; } + if (glusterd_is_defrag_on(volinfo)) { + snprintf (msg, sizeof(msg), "Volume name %s rebalance is in " + "progress. Please retry after completion", volname); + gf_log ("glusterd", GF_LOG_ERROR, "%s", msg); + *op_errstr = gf_strdup (msg); + ret = -1; + goto out; + } ret = dict_get_int32 (dict, "count", &count); if (ret) { gf_log ("", GF_LOG_ERROR, "Unable to get count"); @@ -844,6 +852,15 @@ glusterd_op_stage_replace_brick (gd1_mgmt_stage_op_req *req, char **op_errstr) goto out; } + if (glusterd_is_defrag_on(volinfo)) { + snprintf (msg, sizeof(msg), "Volume name %s rebalance is in " + "progress. Please retry after completion", volname); + gf_log ("glusterd", GF_LOG_ERROR, "%s", msg); + *op_errstr = gf_strdup (msg); + ret = -1; + goto out; + } + ret = glusterd_brickinfo_get (src_brick, volinfo, &src_brickinfo); if (ret) { @@ -1310,6 +1327,27 @@ glusterd_op_stage_remove_brick (gd1_mgmt_stage_op_req *req) 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; + } + if (volinfo->brick_count == 1) { ctx = glusterd_op_get_ctx (GD_OP_REMOVE_BRICK); if (!ctx) { @@ -2851,7 +2889,6 @@ glusterd_op_remove_brick (gd1_mgmt_stage_op_req *req) goto out; } - ret = dict_get_int32 (dict, "count", &count); if (ret) { gf_log ("", GF_LOG_ERROR, "Unable to get count"); diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 7072ce1b982..5b5d98750d0 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -2118,3 +2118,9 @@ out: gf_log ("", GF_LOG_DEBUG, "returning %d ", ret); return ret; } + +int +glusterd_is_defrag_on (glusterd_volinfo_t *volinfo) +{ + return (volinfo->defrag_status == GF_DEFRAG_STATUS_STARTED); +} diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index 4660a26874a..e2736bf1631 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -193,4 +193,7 @@ glusterd_brick_start (glusterd_volinfo_t *volinfo, int glusterd_brick_stop (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *brickinfo); + +int +glusterd_is_defrag_on (glusterd_volinfo_t *volinfo); #endif |