summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2013-12-03 04:35:52 +0000
committerAvra Sengupta <asengupt@redhat.com>2013-12-03 04:39:50 +0000
commitd50377f7296bf3bd83d0e116ccf6f5b9465666a7 (patch)
tree118730a89b6c3e971a2651c16e4d54f1e02acc97
parent64a5178026e452b4ca5552db7de34573267411ed (diff)
glusterd/snapshot: Fixes for cg name space collisions
Change-Id: I6137ecb0dbbd37af81433c415568dfede1d740a6 Signed-off-by: Avra Sengupta <asengupt@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index fd9ba99..198f64c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -3015,11 +3015,9 @@ out:
cli contains '-', it confuses lvm. Handle it.
*/
int32_t
-glusterd_do_snap (glusterd_volinfo_t *volinfo, char *name, dict_t *dict,
+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)
{
- char snapname[PATH_MAX] = "";
- char tmp[2046] = "";
char *snap_brick_mount_path = "";
char snapmntname[PATH_MAX] = "";
char *device = NULL;
@@ -3038,13 +3036,6 @@ glusterd_do_snap (glusterd_volinfo_t *volinfo, char *name, dict_t *dict,
priv = this->private;
GF_ASSERT (priv);
- if (cg) {
- snprintf (tmp, sizeof (tmp), "%s_snap", volinfo->volname);
- snprintf (snapname, sizeof (snapname), "%s_%s", name, tmp);
- } else {
- snprintf (snapname, sizeof (snapname), "%s", name);
- }
-
ret = glusterd_volinfo_dup (volinfo, &snap_volume);
strcpy (snap_volume->volname, snapname);
snap_volume->is_snap_volume = _gf_true;
@@ -3224,7 +3215,7 @@ generate_snapname (char *volname, char *name, gf_boolean_t volume_from_cg)
GF_ASSERT (volname);
if (volume_from_cg) {
snprintf (internal_snapname, sizeof (internal_snapname),
- "%s_%s", volname, name);
+ "%s_%s_snap", name, volname);
} else {
snprintf (internal_snapname, sizeof (internal_snapname),
"%s", name);
@@ -3313,6 +3304,15 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
gf_log (this->name, GF_LOG_DEBUG, "cg-id = %s", uuid_utoa(*cg_id));
}
+ if (volume_count > 1) {
+ cg = glusterd_new_snap_cg_object (volume_count);
+ if (!cg) {
+ gf_log (this->name, GF_LOG_ERROR, "cannot create the "
+ "consistency group %s", name);
+ goto out;
+ }
+ }
+
for (i = 1; i < volume_count + 1; i++) {
snprintf (volname_buf, sizeof (volname_buf),
"volname%d", i);
@@ -3378,13 +3378,6 @@ glusterd_snapshot_create_commit (dict_t *dict, char **op_errstr,
}
if (volume_count > 1) {
- cg = glusterd_new_snap_cg_object (volume_count);
- if (!cg) {
- gf_log (this->name, GF_LOG_ERROR, "cannot create the "
- "consistency group %s", name);
- goto out;
- }
-
uuid_copy (cg->cg_id, *cg_id);
strncpy (cg->cg_name, name, sizeof (cg->cg_name));
ret = glusterd_add_snap_cg (priv, cg);