diff options
author | Kotresh HR <khiremat@redhat.com> | 2015-06-15 17:20:46 +0530 |
---|---|---|
committer | Krishnan Parthasarathi <kparthas@redhat.com> | 2015-06-18 23:37:31 -0700 |
commit | 84479bfa28f91c993b4e4a1f0f259a3ae1576791 (patch) | |
tree | 8887c08a9039140c337ddab37c8c4bdd7d533e43 /xlators/mgmt | |
parent | c4d4d2247b3aeb96e37a05aeb0f73cec54360094 (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.
BUG: 1233056
Change-Id: Ic666e43a1c4ac2f3f0fb957caa77770e1eee4129
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: http://review.gluster.org/11233
Reviewed-on: http://review.gluster.org/11310
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c index 294758b9a7f..0b061d0806d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c @@ -3245,8 +3245,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; @@ -3287,6 +3290,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) { @@ -3301,8 +3305,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; @@ -3320,6 +3332,9 @@ out: if (ip) GF_FREE (ip); + if (ip_temp) + GF_FREE (ip_temp); + if (slave_temp) GF_FREE (slave_temp); |