summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli-rpc-ops.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c34
2 files changed, 30 insertions, 8 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 1a90e192c..31fd616ff 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -7671,7 +7671,7 @@ list_snap_of_volume (dict_t *dict_n, char *prefix_str) {
continue;
}
ret = snprintf (buffer, sizeof(buffer),
- "%s.snap-%ld.cgname", prefix_str, i);
+ "%s.snap-%ld.cg-name", prefix_str, i);
if (ret < 0) { /* Negative value is an error */
goto out;
}
@@ -7744,7 +7744,7 @@ list_snap_of_cg (dict_t *dict) {
goto out;
}
- ret = dict_get_str (dict, "snaplist.cg-0.cgname", &get_buffer);
+ ret = dict_get_str (dict, "snaplist.cg-0.cg-name", &get_buffer);
if (ret) {
/* if cg_name is not present then exit, it is not necessary
* to check other details if cg_name is not present
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 4ff485ca3..d21377924 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -1942,7 +1942,7 @@ glusterd_snapshot_cg_get_snaplist_lk (dict_t *dict, glusterd_snap_cg_t *cg,
goto out;
}
- ret = snprintf (key, sizeof (key), "%s.cgname", keyprefix);
+ ret = snprintf (key, sizeof (key), "%s.cg-name", keyprefix);
if (ret < 0) { /* Only negative value is error */
goto out;
}
@@ -2690,7 +2690,8 @@ out:
int32_t
glusterd_snap_create (glusterd_volinfo_t *volinfo,
glusterd_volinfo_t *snap_volinfo,
- char *description, uuid_t *cg_id)
+ char *description, uuid_t *cg_id,
+ char *cg_name)
{
glusterd_snap_t *snap = NULL;
xlator_t *this = NULL;
@@ -2700,6 +2701,10 @@ glusterd_snap_create (glusterd_volinfo_t *volinfo,
this = THIS;
priv = this->private;
+ GF_ASSERT (snap_volinfo);
+ if (cg_id)
+ GF_ASSERT (cg_name);
+
if (!volinfo) {
gf_log (this->name, GF_LOG_ERROR, "volinfo is NULL");
goto out;
@@ -2719,8 +2724,11 @@ glusterd_snap_create (glusterd_volinfo_t *volinfo,
snap->description = gf_strdup (description);
snap->time_stamp = time (NULL);
uuid_copy (snap->snap_id, snap_volinfo->volume_id);
- if (cg_id)
+ if (cg_id){
uuid_copy (snap->cg_id, *cg_id);
+ strncpy (snap->cg_name, cg_name,
+ sizeof (snap->cg_name) - 1);
+ }
snap->snap_volume = snap_volinfo;
strcpy (snap->snap_name, snap_volinfo->volname);
//TODO: replace strcpy with strncpy
@@ -3035,7 +3043,8 @@ out:
*/
int32_t
glusterd_do_snap (glusterd_volinfo_t *volinfo, char *snapname, dict_t *dict,
- gf_boolean_t cg, uuid_t *cg_id, int volcount, uuid_t snap_volid)
+ gf_boolean_t cg, uuid_t *cg_id, int volcount,
+ uuid_t snap_volid, char *cg_name)
{
char *snap_brick_mount_path = "";
char snapmntname[PATH_MAX] = "";
@@ -3057,6 +3066,11 @@ glusterd_do_snap (glusterd_volinfo_t *volinfo, char *snapname, dict_t *dict,
priv = this->private;
GF_ASSERT (priv);
+ GF_ASSERT (volinfo);
+ GF_ASSERT (snapname);
+ GF_ASSERT (dict);
+ if (cg_id)
+ GF_ASSERT (cg_name);
ret = glusterd_volinfo_dup (volinfo, &snap_volume);
strncpy (snap_volume->volname, snapname,
@@ -3172,7 +3186,8 @@ glusterd_do_snap (glusterd_volinfo_t *volinfo, char *snapname, dict_t *dict,
ret = dict_get_str (dict, "snap-description", &description);
// for now continue the snap, if getting description fails.
- ret = glusterd_snap_create (volinfo, snap_volume, description, cg_id);
+ ret = glusterd_snap_create (volinfo, snap_volume, description, cg_id,
+ cg_name);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "creating the"
"snap object failed for the volume %s",
@@ -4059,7 +4074,14 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
added parallely by worker threads so that
the snap creating happens parallely.
*/
- ret = glusterd_do_snap (volinfo, tmp, dict, is_cg, cg_id, i, *snap_volid);
+ if (is_cg) {
+ ret = glusterd_do_snap (volinfo, tmp, dict,
+ is_cg, cg_id, i, *snap_volid, name);
+ }
+ else {
+ ret = glusterd_do_snap (volinfo, tmp, dict,
+ is_cg, cg_id, i, *snap_volid, NULL);
+ }
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "taking the "
"snapshot of the volume %s failed", volname);