summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2015-06-15 17:20:46 +0530
committerKrishnan Parthasarathi <kparthas@redhat.com>2015-06-17 23:58:42 -0700
commitdaf22a3b59f42c897f345dab74c3852ddf9bddef (patch)
tree4a20356e095246048181e243b031d7f67f5463ea
parentba7d5d914b2c897aef0616f3d95beb4d17bc51a8 (diff)
glusterd: Fix snapshot of a volume with geo-rep
Problem: Snapshot fails for a volume configured with geo-rep if geo-rep is created with root user with the following syntax. gluster vol geo-rep <master_vol> root@<slave_host>::<slave_vol> It works fine if created with following syntax. gluster vol geo-rep <master_vol> <slave_host>::<slave_vol> Cause: Geo-rep maintains persistent dictionary of slave associated with master volume. The dictionary saves the slave info along with 'root@' as sent from cli. Snapshot while constructing the working dir path to copy configuration files, constructs using this dictionary. But the actual working dir is created with out considering 'root@'. Hence the issue. Fix: Fix is done at two layers. 1. Parse and negelect 'root@' in cli itself. 2. For existing geo-rep sessions and upgrade scenarios, parse and neglect 'root@' in snapshot code as well. Change-Id: If4e04f7f776ef71df4dd1e7e053ef75db98762b2 BUG: 1231789 Signed-off-by: Kotresh HR <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/11233 Reviewed-by: Avra Sengupta <asengupt@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
-rw-r--r--cli/src/cli-cmd-parser.c22
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c17
2 files changed, 36 insertions, 3 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index f0f428a795b..a243a3542e9 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -2422,6 +2422,9 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
"push-pem", "detail", "pause",
"resume", NULL };
char *w = NULL;
+ char *save_ptr = NULL;
+ char *slave_temp = NULL;
+ char *token = NULL;
GF_ASSERT (words);
GF_ASSERT (options);
@@ -2578,14 +2581,29 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
ret = dict_set_str (dict, "volname",
(char *)words[masteri]);
}
- if (!ret && slavei)
- ret = dict_set_str (dict, "slave", (char *)words[slavei]);
+ if (!ret && slavei) {
+ /* If geo-rep is created with root user using the syntax
+ * gluster vol geo-rep <mastervol> root@<slavehost> ...
+ * pass down only <slavehost> else pass as it is.
+ */
+ slave_temp = gf_strdup (words[slavei]);
+ token = strtok_r (slave_temp, "@", &save_ptr);
+ if (token && !strcmp (token, "root")) {
+ ret = dict_set_str (dict, "slave",
+ (char *)words[slavei]+5);
+ } else {
+ ret = dict_set_str (dict, "slave",
+ (char *)words[slavei]);
+ }
+ }
if (!ret)
ret = dict_set_int32 (dict, "type", type);
if (!ret && type == GF_GSYNC_OPTION_TYPE_CONFIG)
ret = config_parse (words, wordcount, dict, cmdi, glob);
out:
+ if (slave_temp)
+ GF_FREE (slave_temp);
if (ret) {
if (dict)
dict_destroy (dict);
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
index 6ab0403993a..ae2521c570b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
@@ -3242,8 +3242,11 @@ glusterd_get_geo_rep_session (char *slave_key, char *origin_volname,
{
int32_t ret = -1;
char *token = NULL;
+ char *tok = NULL;
char *temp = NULL;
char *ip = NULL;
+ char *ip_i = NULL;
+ char *ip_temp = NULL;
char *buffer = NULL;
xlator_t *this = NULL;
char *slave_temp = NULL;
@@ -3284,6 +3287,7 @@ glusterd_get_geo_rep_session (char *slave_key, char *origin_volname,
ret = -1;
goto out;
}
+ ip_i = ip;
token = strtok_r (NULL, "\0", &save_ptr);
if (!token) {
@@ -3298,8 +3302,16 @@ glusterd_get_geo_rep_session (char *slave_key, char *origin_volname,
goto out;
}
+ /* If 'ip' has 'root@slavehost', point to 'slavehost' as
+ * working directory for root users are created without
+ * 'root@' */
+ ip_temp = gf_strdup (ip);
+ tok = strtok_r (ip_temp, "@", &save_ptr);
+ if (tok && !strcmp (tok, "root"))
+ ip_i = ip + 5;
+
ret = snprintf (session, PATH_MAX, "%s_%s_%s",
- origin_volname, ip, slave_temp);
+ origin_volname, ip_i, slave_temp);
if (ret < 0) /* Negative value is an error */
goto out;
@@ -3317,6 +3329,9 @@ out:
if (ip)
GF_FREE (ip);
+ if (ip_temp)
+ GF_FREE (ip_temp);
+
if (slave_temp)
GF_FREE (slave_temp);