diff options
author | Pranith Kumar K <pranithk@gluster.com> | 2011-04-12 07:17:44 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-04-13 00:39:03 -0700 |
commit | bc16a1e999648ba58f863d26281c152fb477174a (patch) | |
tree | 339e72925c06d56355b338b01f72618892a1667a /xlators/mgmt/glusterd/src/glusterd-op-sm.c | |
parent | fb3e469e29578393a0d5f964991d26b5449bffb0 (diff) |
mgmt/glusterd: volume reset force implementation
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2729 (Implement force option for volume reset)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2729
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-op-sm.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 8d1cd639f3d..b9d63605ab9 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -3519,21 +3519,30 @@ out: void _delete_reconfig_opt (dict_t *this, char *key, data_t *value, void *data) { + int exists = 0; + int32_t is_force = 0; - int exists = 0; - + GF_ASSERT (data); + is_force = *((int32_t*)data); exists = glusterd_check_option_exists(key, NULL); - if (exists == 1) { - gf_log ("", GF_LOG_DEBUG, "deleting dict with key=%s,value=%s", - key, value->data); - dict_del (this, key); - } + if (exists != 1) + goto out; + + if ((!is_force) && + (_gf_true == glusterd_check_voloption_flags (key, + OPT_FLAG_FORCE))) + goto out; + gf_log ("", GF_LOG_DEBUG, "deleting dict with key=%s,value=%s", + key, value->data); + dict_del (this, key); +out: + return; } int -glusterd_options_reset (glusterd_volinfo_t *volinfo) +glusterd_options_reset (glusterd_volinfo_t *volinfo, int32_t is_force) { int ret = 0; @@ -3541,7 +3550,7 @@ glusterd_options_reset (glusterd_volinfo_t *volinfo) GF_ASSERT (volinfo->dict); - dict_foreach (volinfo->dict, _delete_reconfig_opt, volinfo->dict); + dict_foreach (volinfo->dict, _delete_reconfig_opt, &is_force); ret = glusterd_create_volfiles_and_notify_services (volinfo); @@ -3575,6 +3584,7 @@ glusterd_op_reset_volume (dict_t *dict) glusterd_volinfo_t *volinfo = NULL; int ret = -1; char *volname = NULL; + int32_t is_force = 0; ret = dict_get_str (dict, "volname", &volname); if (ret) { @@ -3582,13 +3592,17 @@ glusterd_op_reset_volume (dict_t *dict) goto out; } + ret = dict_get_int32 (dict, "force", &is_force); + if (ret) + is_force = 0; + ret = glusterd_volinfo_find (volname, &volinfo); if (ret) { gf_log ("", GF_LOG_ERROR, "Unable to allocate memory"); goto out; } - ret = glusterd_options_reset (volinfo); + ret = glusterd_options_reset (volinfo, is_force); out: gf_log ("", GF_LOG_DEBUG, "'volume reset' returning %d", ret); |