diff options
Diffstat (limited to 'xlators/mgmt')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot.c | 34 |
1 files changed, 28 insertions, 6 deletions
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); |