summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2013-10-23 14:07:29 +0530
committershishir gowda <sgowda@redhat.com>2013-11-15 12:38:59 +0530
commit8b5a3ef2f5363abd4e4d8d49c067cba8e4df8fdd (patch)
tree4595bdfc3acb0940bca4aa0a324138ad28c47b9c
parentda3a265c36b1326405dafce98b29d7c72001a7e9 (diff)
mgmt/glusterd: changes to start the brick process of the snap volume
Change-Id: I54db2fa67ebb6b57629f9536c296fbae07a1d159 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handshake.c49
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c7
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c8
3 files changed, 54 insertions, 10 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c
index e7d6d84..714695b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c
@@ -51,6 +51,10 @@ build_volfile_path (const char *volname, char *path,
char *tmp = NULL;
glusterd_volinfo_t *volinfo = NULL;
char *server = NULL;
+ gf_boolean_t snap_volume = _gf_false;
+ char *str = NULL;
+ char *tmp_volname = NULL;
+ char *input_vol = NULL;
priv = THIS->private;
@@ -60,6 +64,17 @@ build_volfile_path (const char *volname, char *path,
path, path_len);
ret = 1;
goto out;
+ } else if (strstr (volname, "/snaps/")) {
+ input_vol = gf_strdup (volname);
+ snap_volume = _gf_true;
+ str = strrchr (volname, '/');
+ if (str)
+ str++;
+ dup_volname = gf_strdup (str);
+ str = NULL;
+ tmp_volname = strtok_r (input_vol, "/", &str);
+ if (!tmp_volname)
+ goto out;
} else if (volname[0] != '/') {
/* Normal behavior */
dup_volname = gf_strdup (volname);
@@ -86,28 +101,48 @@ build_volfile_path (const char *volname, char *path,
if (!glusterd_auth_get_username (volinfo))
trusted_str = NULL;
- ret = snprintf (path, path_len, "%s/vols/%s/%s.vol",
- priv->workdir, volinfo->volname, volname);
+ if (!snap_volume)
+ ret = snprintf (path, path_len, "%s/vols/%s/%s.vol",
+ priv->workdir, volinfo->volname, volname);
+ else
+ ret = snprintf (path, path_len, "%s/vols/%s/snaps/%s/%s.vol",
+ priv->workdir, tmp_volname, volinfo->volname,
+ volname);
if (ret == -1)
goto out;
ret = stat (path, &stbuf);
if ((ret == -1) && (errno == ENOENT)) {
- snprintf (path, path_len, "%s/vols/%s/%s%s-fuse.vol",
- priv->workdir, volinfo->volname,
- (trusted_str ? trusted_str : ""), dup_volname);
+ if (!snap_volume)
+ snprintf (path, path_len, "%s/vols/%s/%s%s-fuse.vol",
+ priv->workdir, volinfo->volname,
+ (trusted_str ? trusted_str : ""),
+ dup_volname);
+ else
+ snprintf (path, path_len,
+ "%s/vols/%s/snaps/%s/%s%s-fuse.vol",
+ priv->workdir, tmp_volname, volinfo->volname,
+ (trusted_str ? trusted_str:""), dup_volname);
+
ret = stat (path, &stbuf);
}
if ((ret == -1) && (errno == ENOENT)) {
- snprintf (path, path_len, "%s/vols/%s/%s-tcp.vol",
- priv->workdir, volinfo->volname, volname);
+ if (!snap_volume)
+ snprintf (path, path_len, "%s/vols/%s/%s-tcp.vol",
+ priv->workdir, volinfo->volname, volname);
+ else
+ snprintf (path, path_len,
+ "%s/vols/%s/snaps/%s/%s-tcp.vol",
+ priv->workdir, tmp_volname, volinfo->volname,
+ volname);
}
ret = 1;
out:
GF_FREE (free_ptr);
+ GF_FREE (input_vol);
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 39392c6..ad2f899 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -1925,6 +1925,9 @@ glusterd_do_snap (glusterd_volinfo_t *volinfo, char *name, dict_t *dict,
goto out;
}
+ //check whether this is needed or not
+ list_add_tail (&snap_volume->vol_list, &priv->volumes);
+
list_for_each_entry (brickinfo, &snap_volume->bricks, brick_list) {
ret = glusterd_snap_brick_start (volinfo, snap_volume, brickinfo,
_gf_true);
@@ -1938,6 +1941,8 @@ glusterd_do_snap (glusterd_volinfo_t *volinfo, char *name, dict_t *dict,
}
out:
+ if (ret)
+ glusterd_volinfo_delete (snap_volume);
return ret;
}
@@ -1978,7 +1983,7 @@ glusterd_do_snap_remove (glusterd_volinfo_t *volinfo, char *name, dict_t *dict)
if (snap) {
ret = glusterd_brick_snapshot_remove (snap->snap_volume,
- volinfo, name);
+ volinfo, name);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "removing the bricks"
" snapshots for the snap %s (volume: %s) "
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 9b6d7f2..fd8f5e7 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -494,6 +494,9 @@ glusterd_volinfo_dup (glusterd_volinfo_t *volinfo,
new_volinfo->nfs_transport_type = volinfo->nfs_transport_type;
new_volinfo->brick_count = volinfo->brick_count;
+ dict_copy (volinfo->dict, new_volinfo->dict);
+ gd_update_volume_op_versions (new_volinfo);
+
/* For now, actual volume's username and password itself is used
for authentication of trusted clients. If its not working,
generate new username and passowd (uuid-generate) and use.
@@ -1508,8 +1511,9 @@ glusterd_snap_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
runner_argprintf (&runner, "--log-file=%s", valgrind_logfile);
}
- snprintf (volfile, PATH_MAX, "%s.%s.%s", snap_volinfo->volname,
- brickinfo->hostname, exp_path);
+ snprintf (volfile, PATH_MAX, "%s/snaps/%s/%s.%s.%s",
+ volinfo->volname, snap_volinfo->volname,
+ snap_volinfo->volname, brickinfo->hostname, exp_path);
if (volinfo->logdir) {
snprintf (logfile, PATH_MAX, "%s/%s.log",