summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
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
parentdbd515195e5177fe34a12102ba2290cfe2bdc388 (diff)
mgmt/glusterd: snapshot related cleanup
Change-Id: I277a70f732666d047ba5dff7a7e6925e0679741b Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c57
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c14
2 files changed, 47 insertions, 24 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) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 50d6232ef..9492baf3a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -4431,6 +4431,10 @@ glusterd_restart_bricks (glusterd_conf_t *conf)
int ret = 0;
glusterd_snap_t *snap = NULL;
glusterd_volinfo_t *snap_volume = NULL;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
list_for_each_entry (volinfo, &conf->volumes, vol_list) {
if (volinfo->status != GLUSTERD_STATUS_STARTED)
@@ -4438,7 +4442,7 @@ glusterd_restart_bricks (glusterd_conf_t *conf)
if (volinfo->is_snap_volume)
continue;
start_nodesvcs = _gf_true;
- gf_log (THIS->name, GF_LOG_DEBUG, "starting the volume %s",
+ gf_log (this->name, GF_LOG_DEBUG, "starting the volume %s",
volinfo->volname);
list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
glusterd_brick_start (volinfo, brickinfo, _gf_false);
@@ -4450,7 +4454,13 @@ glusterd_restart_bricks (glusterd_conf_t *conf)
continue;
list_for_each_entry (snap, &volinfo->snaps, snap_list) {
snap_volume = snap->snap_volume;
- GF_ASSERT (snap_volume);
+ //GF_ASSERT (snap_volume);
+ if (!snap_volume) {
+ gf_log (this->name, GF_LOG_WARNING, "volinfo "
+ "for the snap %s is NULL",
+ snap->snap_name);
+ continue;
+ }
list_for_each_entry (brickinfo, &snap_volume->bricks,
brick_list) {
glusterd_snap_brick_start (volinfo, snap_volume,