summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-snapshot.c
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2013-12-04 09:48:10 +0530
committerRaghavendra Bhat <raghavendra@redhat.com>2013-12-12 14:58:01 +0530
commit112691a0d5a539b71c642228e197764248174f5d (patch)
treedfeaa7260a3bc437295043f7817ed5ba4a2ee92c /xlators/mgmt/glusterd/src/glusterd-snapshot.c
parentdbd515195e5177fe34a12102ba2290cfe2bdc388 (diff)
mgmt/glusterd: snapshot related cleanup
Change-Id: I277a70f732666d047ba5dff7a7e6925e0679741b Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-snapshot.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c57
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) {