|
|
21ab4e |
From b872be92b66d608b2fdeb788cdd5eb0a323307a9 Mon Sep 17 00:00:00 2001
|
|
|
21ab4e |
From: Avra Sengupta <asengupt@redhat.com>
|
|
|
21ab4e |
Date: Thu, 20 Oct 2016 12:58:16 +0530
|
|
|
21ab4e |
Subject: [PATCH 345/361] snapshot: Fix the failure to recreate clones with
|
|
|
21ab4e |
same name
|
|
|
21ab4e |
|
|
|
21ab4e |
The brick path of snapshot clones contained the clonename,
|
|
|
21ab4e |
thereby failing to create newer clones with the same name
|
|
|
21ab4e |
after the original clone had been deleted.
|
|
|
21ab4e |
|
|
|
21ab4e |
This fix creates the brick path with the clone's vol id
|
|
|
21ab4e |
instead of the clones name. Hence future clones with the
|
|
|
21ab4e |
same name will not have the namespace clash.
|
|
|
21ab4e |
|
|
|
21ab4e |
mainline:
|
|
|
21ab4e |
> BUG: 1387160
|
|
|
21ab4e |
> Reviewed-on: http://review.gluster.org/15683
|
|
|
21ab4e |
> Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
|
|
|
21ab4e |
(cherry picked from commit 88c8720f3b200bce9b008e8200adbd11431d3fe7)
|
|
|
21ab4e |
|
|
|
21ab4e |
BUG: 1309209
|
|
|
21ab4e |
Change-Id: I262712adc576122f051b5d1ce171d020efaefd1a
|
|
|
21ab4e |
Signed-off-by: Avra Sengupta <asengupt@redhat.com>
|
|
|
21ab4e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/101285
|
|
|
21ab4e |
Tested-by: Milind Changire <mchangir@redhat.com>
|
|
|
21ab4e |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
---
|
|
|
21ab4e |
tests/basic/volume-snapshot-clone.t | 13 ++++++
|
|
|
21ab4e |
xlators/mgmt/glusterd/src/glusterd-handshake.c | 2 +-
|
|
|
21ab4e |
.../mgmt/glusterd/src/glusterd-snapshot-utils.h | 2 +-
|
|
|
21ab4e |
xlators/mgmt/glusterd/src/glusterd-snapshot.c | 54 ++++++++++++++++------
|
|
|
21ab4e |
xlators/mgmt/glusterd/src/glusterd.h | 3 +-
|
|
|
21ab4e |
5 files changed, 57 insertions(+), 17 deletions(-)
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/tests/basic/volume-snapshot-clone.t b/tests/basic/volume-snapshot-clone.t
|
|
|
21ab4e |
index cf68911..e6da9d7 100755
|
|
|
21ab4e |
--- a/tests/basic/volume-snapshot-clone.t
|
|
|
21ab4e |
+++ b/tests/basic/volume-snapshot-clone.t
|
|
|
21ab4e |
@@ -98,6 +98,19 @@ EXPECT_WITHIN $PROBE_TIMEOUT 2 peer_count;
|
|
|
21ab4e |
|
|
|
21ab4e |
EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Started' volinfo_field ${V0}_clone 'Status';
|
|
|
21ab4e |
EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Started' volinfo_field ${V1}_clone 'Status';
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+TEST $CLI_1 volume stop ${V0}_clone
|
|
|
21ab4e |
+TEST $CLI_1 volume stop ${V1}_clone
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+TEST $CLI_1 volume delete ${V0}_clone
|
|
|
21ab4e |
+TEST $CLI_1 volume delete ${V1}_clone
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+TEST $CLI_1 snapshot clone ${V0}_clone ${V0}_snap
|
|
|
21ab4e |
+TEST $CLI_1 snapshot clone ${V1}_clone ${V1}_snap
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+EXPECT 'Created' volinfo_field ${V0}_clone 'Status';
|
|
|
21ab4e |
+EXPECT 'Created' volinfo_field ${V1}_clone 'Status';
|
|
|
21ab4e |
+
|
|
|
21ab4e |
#Clean up
|
|
|
21ab4e |
stop_force_volumes 2
|
|
|
21ab4e |
EXPECT_WITHIN $CONFIG_UPDATE_TIMEOUT 'Stopped' volinfo_field $V0 'Status';
|
|
|
21ab4e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c
|
|
|
21ab4e |
index 4e5dd01..0cd1a29 100644
|
|
|
21ab4e |
--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c
|
|
|
21ab4e |
+++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c
|
|
|
21ab4e |
@@ -615,7 +615,7 @@ glusterd_create_missed_snap (glusterd_missed_snap_info *missed_snapinfo,
|
|
|
21ab4e |
|
|
|
21ab4e |
/* Create and mount the snap brick */
|
|
|
21ab4e |
ret = glusterd_snap_brick_create (snap_vol, brickinfo,
|
|
|
21ab4e |
- snap_opinfo->brick_num - 1);
|
|
|
21ab4e |
+ snap_opinfo->brick_num - 1, 0);
|
|
|
21ab4e |
if (ret) {
|
|
|
21ab4e |
gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
21ab4e |
GD_MSG_BRICK_CREATION_FAIL, "Failed to "
|
|
|
21ab4e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h
|
|
|
21ab4e |
index b964a43..e050166 100644
|
|
|
21ab4e |
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h
|
|
|
21ab4e |
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.h
|
|
|
21ab4e |
@@ -137,7 +137,7 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume,
|
|
|
21ab4e |
int32_t
|
|
|
21ab4e |
glusterd_snap_brick_create (glusterd_volinfo_t *snap_volinfo,
|
|
|
21ab4e |
glusterd_brickinfo_t *brickinfo,
|
|
|
21ab4e |
- int32_t brick_count);
|
|
|
21ab4e |
+ int32_t brick_count, int32_t clone);
|
|
|
21ab4e |
|
|
|
21ab4e |
int
|
|
|
21ab4e |
glusterd_snapshot_restore_cleanup (dict_t *rsp_dict,
|
|
|
21ab4e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
|
|
|
21ab4e |
index 2c0a192..d3e9b99 100644
|
|
|
21ab4e |
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
|
|
|
21ab4e |
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
|
|
|
21ab4e |
@@ -2378,6 +2378,7 @@ glusterd_snapshot_clone_prevalidate (dict_t *dict, char **op_errstr,
|
|
|
21ab4e |
{
|
|
|
21ab4e |
char *clonename = NULL;
|
|
|
21ab4e |
char *snapname = NULL;
|
|
|
21ab4e |
+ char device_name[64] = "";
|
|
|
21ab4e |
char key[PATH_MAX] = "";
|
|
|
21ab4e |
glusterd_snap_t *snap = NULL;
|
|
|
21ab4e |
char err_str[PATH_MAX] = "";
|
|
|
21ab4e |
@@ -2443,10 +2444,12 @@ glusterd_snapshot_clone_prevalidate (dict_t *dict, char **op_errstr,
|
|
|
21ab4e |
goto out;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
+ GLUSTERD_GET_UUID_NOHYPHEN (device_name, *snap_volid);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
/* Adding snap bricks mount paths to the dict */
|
|
|
21ab4e |
ret = glusterd_snap_create_clone_common_prevalidate (rsp_dict, 0,
|
|
|
21ab4e |
snapname, err_str,
|
|
|
21ab4e |
- clonename, 1,
|
|
|
21ab4e |
+ device_name, 1,
|
|
|
21ab4e |
snap_vol,
|
|
|
21ab4e |
&loglevel,
|
|
|
21ab4e |
1, op_errno);
|
|
|
21ab4e |
@@ -4812,12 +4815,13 @@ out:
|
|
|
21ab4e |
int32_t
|
|
|
21ab4e |
glusterd_snap_brick_create (glusterd_volinfo_t *snap_volinfo,
|
|
|
21ab4e |
glusterd_brickinfo_t *brickinfo,
|
|
|
21ab4e |
- int32_t brick_count)
|
|
|
21ab4e |
+ int32_t brick_count, int32_t clone)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
int32_t ret = -1;
|
|
|
21ab4e |
xlator_t *this = NULL;
|
|
|
21ab4e |
glusterd_conf_t *priv = NULL;
|
|
|
21ab4e |
char snap_brick_mount_path[PATH_MAX] = "";
|
|
|
21ab4e |
+ char clone_uuid[64] = "";
|
|
|
21ab4e |
struct stat statbuf = {0, };
|
|
|
21ab4e |
|
|
|
21ab4e |
this = THIS;
|
|
|
21ab4e |
@@ -4826,9 +4830,16 @@ glusterd_snap_brick_create (glusterd_volinfo_t *snap_volinfo,
|
|
|
21ab4e |
GF_ASSERT (snap_volinfo);
|
|
|
21ab4e |
GF_ASSERT (brickinfo);
|
|
|
21ab4e |
|
|
|
21ab4e |
- snprintf (snap_brick_mount_path, sizeof (snap_brick_mount_path),
|
|
|
21ab4e |
- "%s/%s/brick%d", snap_mount_dir, snap_volinfo->volname,
|
|
|
21ab4e |
- brick_count + 1);
|
|
|
21ab4e |
+ if (clone) {
|
|
|
21ab4e |
+ GLUSTERD_GET_UUID_NOHYPHEN(clone_uuid, snap_volinfo->volume_id);
|
|
|
21ab4e |
+ snprintf (snap_brick_mount_path, sizeof (snap_brick_mount_path),
|
|
|
21ab4e |
+ "%s/%s/brick%d", snap_mount_dir,
|
|
|
21ab4e |
+ clone_uuid, brick_count + 1);
|
|
|
21ab4e |
+ } else {
|
|
|
21ab4e |
+ snprintf (snap_brick_mount_path, sizeof (snap_brick_mount_path),
|
|
|
21ab4e |
+ "%s/%s/brick%d", snap_mount_dir,
|
|
|
21ab4e |
+ snap_volinfo->volname, brick_count + 1);
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
|
|
|
21ab4e |
ret = mkdir_p (snap_brick_mount_path, 0777, _gf_true);
|
|
|
21ab4e |
if (ret) {
|
|
|
21ab4e |
@@ -4903,6 +4914,7 @@ glusterd_add_brick_to_snap_volume (dict_t *dict, dict_t *rsp_dict,
|
|
|
21ab4e |
char *value = NULL;
|
|
|
21ab4e |
char *snap_brick_dir = NULL;
|
|
|
21ab4e |
char snap_brick_path[PATH_MAX] = "";
|
|
|
21ab4e |
+ char clone_uuid[64] = "";
|
|
|
21ab4e |
char *snap_device = NULL;
|
|
|
21ab4e |
glusterd_brickinfo_t *snap_brickinfo = NULL;
|
|
|
21ab4e |
gf_boolean_t add_missed_snap = _gf_false;
|
|
|
21ab4e |
@@ -5018,10 +5030,18 @@ glusterd_add_brick_to_snap_volume (dict_t *dict, dict_t *rsp_dict,
|
|
|
21ab4e |
/* Create brick-path in the format /var/run/gluster/snaps/ *
|
|
|
21ab4e |
* <snap-uuid>/<original-brick#>/snap-brick-dir *
|
|
|
21ab4e |
*/
|
|
|
21ab4e |
- snprintf (snap_brick_path, sizeof(snap_brick_path),
|
|
|
21ab4e |
- "%s/%s/brick%d%s", snap_mount_dir,
|
|
|
21ab4e |
- snap_vol->volname, brick_count+1,
|
|
|
21ab4e |
- snap_brick_dir);
|
|
|
21ab4e |
+ if (clone) {
|
|
|
21ab4e |
+ GLUSTERD_GET_UUID_NOHYPHEN(clone_uuid, snap_vol->volume_id);
|
|
|
21ab4e |
+ snprintf (snap_brick_path, sizeof(snap_brick_path),
|
|
|
21ab4e |
+ "%s/%s/brick%d%s", snap_mount_dir,
|
|
|
21ab4e |
+ clone_uuid, brick_count+1,
|
|
|
21ab4e |
+ snap_brick_dir);
|
|
|
21ab4e |
+ } else {
|
|
|
21ab4e |
+ snprintf (snap_brick_path, sizeof(snap_brick_path),
|
|
|
21ab4e |
+ "%s/%s/brick%d%s", snap_mount_dir,
|
|
|
21ab4e |
+ snap_vol->volname, brick_count+1,
|
|
|
21ab4e |
+ snap_brick_dir);
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
|
|
|
21ab4e |
snprintf (key, sizeof(key), "vol%"PRId64".brick_snapdevice%d",
|
|
|
21ab4e |
volcount, brick_count);
|
|
|
21ab4e |
@@ -5163,7 +5183,8 @@ out:
|
|
|
21ab4e |
static int32_t
|
|
|
21ab4e |
glusterd_take_brick_snapshot (dict_t *dict, glusterd_volinfo_t *snap_vol,
|
|
|
21ab4e |
glusterd_brickinfo_t *brickinfo,
|
|
|
21ab4e |
- int32_t volcount, int32_t brick_count)
|
|
|
21ab4e |
+ int32_t volcount, int32_t brick_count,
|
|
|
21ab4e |
+ int32_t clone)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
char *origin_brick_path = NULL;
|
|
|
21ab4e |
char key[PATH_MAX] = "";
|
|
|
21ab4e |
@@ -5219,7 +5240,8 @@ glusterd_take_brick_snapshot (dict_t *dict, glusterd_volinfo_t *snap_vol,
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
/* create the complete brick here */
|
|
|
21ab4e |
- ret = glusterd_snap_brick_create (snap_vol, brickinfo, brick_count);
|
|
|
21ab4e |
+ ret = glusterd_snap_brick_create (snap_vol, brickinfo,
|
|
|
21ab4e |
+ brick_count, clone);
|
|
|
21ab4e |
if (ret) {
|
|
|
21ab4e |
gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
21ab4e |
GD_MSG_BRICK_CREATION_FAIL, "not able to"
|
|
|
21ab4e |
@@ -6515,7 +6537,8 @@ out:
|
|
|
21ab4e |
int
|
|
|
21ab4e |
glusterd_take_brick_snapshot_task (void *opaque)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
- int ret = 0;
|
|
|
21ab4e |
+ int ret = 0;
|
|
|
21ab4e |
+ int32_t clone = 0;
|
|
|
21ab4e |
snap_create_args_t *snap_args = NULL;
|
|
|
21ab4e |
char *clonename = NULL;
|
|
|
21ab4e |
char key[PATH_MAX] = "";
|
|
|
21ab4e |
@@ -6531,15 +6554,18 @@ glusterd_take_brick_snapshot_task (void *opaque)
|
|
|
21ab4e |
if (ret) {
|
|
|
21ab4e |
snprintf (key, sizeof (key), "snap-vol%d.brick%d.status",
|
|
|
21ab4e |
snap_args->volcount, snap_args->brickorder);
|
|
|
21ab4e |
- } else
|
|
|
21ab4e |
+ } else {
|
|
|
21ab4e |
snprintf (key, sizeof (key), "clone%d.brick%d.status",
|
|
|
21ab4e |
snap_args->volcount, snap_args->brickorder);
|
|
|
21ab4e |
+ clone = 1;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
|
|
|
21ab4e |
ret = glusterd_take_brick_snapshot (snap_args->dict,
|
|
|
21ab4e |
snap_args->snap_vol,
|
|
|
21ab4e |
snap_args->brickinfo,
|
|
|
21ab4e |
snap_args->volcount,
|
|
|
21ab4e |
- snap_args->brickorder);
|
|
|
21ab4e |
+ snap_args->brickorder,
|
|
|
21ab4e |
+ clone);
|
|
|
21ab4e |
|
|
|
21ab4e |
if (ret) {
|
|
|
21ab4e |
gf_msg (THIS->name, GF_LOG_ERROR, 0,
|
|
|
21ab4e |
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
|
|
|
21ab4e |
index 857c455..d80ad20 100644
|
|
|
21ab4e |
--- a/xlators/mgmt/glusterd/src/glusterd.h
|
|
|
21ab4e |
+++ b/xlators/mgmt/glusterd/src/glusterd.h
|
|
|
21ab4e |
@@ -696,7 +696,8 @@ typedef ssize_t (*gd_serialize_t) (struct iovec outmsg, void *args);
|
|
|
21ab4e |
|
|
|
21ab4e |
#define GLUSTERD_GET_UUID_NOHYPHEN(ret_string, uuid) do { \
|
|
|
21ab4e |
char *snap_volname_ptr = ret_string; \
|
|
|
21ab4e |
- char *snap_volid_ptr = uuid_utoa(uuid); \
|
|
|
21ab4e |
+ char tmp_uuid[64]; \
|
|
|
21ab4e |
+ char *snap_volid_ptr = uuid_utoa_r(uuid, tmp_uuid); \
|
|
|
21ab4e |
while (*snap_volid_ptr) { \
|
|
|
21ab4e |
if (*snap_volid_ptr == '-') { \
|
|
|
21ab4e |
snap_volid_ptr++; \
|
|
|
21ab4e |
--
|
|
|
21ab4e |
1.8.3.1
|
|
|
21ab4e |
|