diff options
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-snapshot.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot.c | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index 5ea36dde3..b5859faaf 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -750,25 +750,27 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr, volname); goto out; } - } - if (!is_cg) - snprintf (snapname, sizeof (snapname), "%s", name); + tmpstr = gf_strdup (name); + if (!tmpstr) { + gf_log (this->name, GF_LOG_ERROR, "Out Of Memory"); + ret = -1; + goto out; + } - tmpstr = gf_strdup (name); - if (!tmpstr) { - gf_log (this->name, GF_LOG_ERROR, "Out Of Memory"); - ret = -1; - goto out; - } - ret = dict_set_dynstr (dict, "snap-name", tmpstr); - if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to set snap-name"); - ret = -1; - goto out; + if (!is_cg) + ret = dict_set_dynstr (dict, "snap-name", tmpstr); + else + ret = dict_set_dynstr (dict, "cg-name", tmpstr); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Unable to set %s", + is_cg?"cg name":"snap name"); + ret = -1; + goto out; + } } - tmpstr = NULL; + snprintf (snapname, sizeof (snapname), "%s", name); for (i = 0; i < volume_count; i++) { snprintf (volname_buf, sizeof (volname_buf), @@ -946,6 +948,9 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr, ret = 0; out: + if (ret) + GF_FREE (tmpstr); + gf_log ("", GF_LOG_TRACE, "Returning %d", ret); return ret; } @@ -3293,18 +3298,26 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr, goto out; } - ret = dict_get_str (dict, "snap-name", &name); - if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to fetch snap-name"); - goto out; + if (volume_count == 1) { + ret = dict_get_str (dict, "snap-name", &name); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Unable to fetch snap-name"); + goto out; + } + } else { + ret = dict_get_str (dict, "cg-name", &name); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Unable to fetch cg-name"); + goto out; + } } ret = dict_get_bin (dict, "cg-id", (void **)&cg_id); if (ret) - gf_log (this->name, GF_LOG_DEBUG, "Not a cg."); + gf_log (this->name, GF_LOG_DEBUG, "Not a cg."); else { - is_cg = _gf_true; - gf_log (this->name, GF_LOG_DEBUG, "cg-id = %s", uuid_utoa(*cg_id)); + is_cg = _gf_true; + gf_log (this->name, GF_LOG_DEBUG, "cg-id = %s", uuid_utoa(*cg_id)); } if (volume_count > 1) { |