summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2018-10-01 17:30:19 -0400
committerShyamsundar Ranganathan <srangana@redhat.com>2018-10-05 14:24:35 +0000
commit5254a4b0c15ff75502806cc61a9eb9d21b55d411 (patch)
treec3d5978153d696e530f34c63bf9c0e5f6fb22f18
parent307c5aff55605d480d0d5889d6d010eee457377b (diff)
mgmt/glusterd: use proper path to the volfile
Till now, glusterd was generating the volfile path for the snapshot volume's bricks like this. /snaps/<snap name>/<brick volfile> But in reality, the path to the brick volfile for a snapshot volume is /snaps/<snap name>/<snap volume name>/<brick volfile> The above workaround was used to distinguish between a mount command used to mount the snapshot volume, and a brick of the snapshot volume, so that based on what is actually happening, glusterd can return the proper volfile (client volfile for the former and the brick volfile for the latter). But, this was causing problems for snapshot restore when brick multiplexing is enabled. Because, with brick multiplexing, it tries to find the volfile and sends GETSPEC rpc call to glusterd using the 2nd style of path i.e. /snaps/<snap name>/<snap volume name>/<brick volfile> So, when the snapshot brick (which is multiplexed) sends a GETSPEC rpc request to glusterd for obtaining the brick volume file, glusterd was returning the client volume file of the snapshot volume instead of the brick volume file. Change-Id: I28b2dfa5d9b379fe943db92c2fdfea879a6a594e fixes: bz#1636162 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com> (cherry picked from commit 83a89296a3d12a3fc2a643c0630be5ce659204ea)
-rw-r--r--xlators/features/snapview-server/src/snapview-server-helpers.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handshake.c20
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c8
3 files changed, 23 insertions, 9 deletions
diff --git a/xlators/features/snapview-server/src/snapview-server-helpers.c b/xlators/features/snapview-server/src/snapview-server-helpers.c
index 3f8a76946fb..2559c4e089b 100644
--- a/xlators/features/snapview-server/src/snapview-server-helpers.c
+++ b/xlators/features/snapview-server/src/snapview-server-helpers.c
@@ -497,8 +497,8 @@ __svs_initialise_snapshot_volume(xlator_t *this, const char *name,
goto out;
}
- snprintf(volname, sizeof(volname), "/snaps/%s/%s", dirent->name,
- dirent->snap_volname);
+ snprintf(volname, sizeof(volname), "/snaps/%s/%s/%s", dirent->name,
+ dirent->snap_volname, dirent->snap_volname);
fs = glfs_new(volname);
if (!fs) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c
index 809d462dec7..d341b4918d2 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c
@@ -53,6 +53,7 @@ get_snap_volname_and_volinfo(const char *volpath, char **volname,
glusterd_snap_t *snap = NULL;
xlator_t *this = NULL;
char *tmp_str_token = NULL;
+ char *volfile_token = NULL;
this = THIS;
GF_ASSERT(this);
@@ -103,21 +104,34 @@ get_snap_volname_and_volinfo(const char *volpath, char **volname,
*/
ret = glusterd_volinfo_find(volname_token, volinfo);
if (ret) {
- *volname = gf_strdup(volname_token);
+ gf_msg(this->name, GF_LOG_WARNING, 0, GD_MSG_VOLINFO_GET_FAIL,
+ "failed to get the volinfo for the volume %s", volname_token);
+
+ /* Get the actual volfile name. */
+ volfile_token = strtok_r(NULL, "/", &save_ptr);
+ *volname = gf_strdup(volfile_token);
if (NULL == *volname) {
ret = -1;
goto out;
}
+ /*
+ * Ideally, this should succeed as volname_token now contains
+ * the name of the snap volume (i.e. name of the volume that
+ * represents the snapshot). But, if for some reason, volinfo
+ * for the snap volume is not found, then try to get from the
+ * name of the volfile. Name of the volfile is like this.
+ * <snap volume name>.<hostname>.<brick path>.vol
+ */
ret = glusterd_snap_volinfo_find(volname_token, snap, volinfo);
if (ret) {
/* Split the volume name */
- vol = strtok_r(volname_token, ".", &save_ptr);
+ vol = strtok_r(volfile_token, ".", &save_ptr);
if (!vol) {
gf_msg(this->name, GF_LOG_ERROR, EINVAL, GD_MSG_INVALID_ENTRY,
"Invalid "
"volname (%s)",
- volname_token);
+ volfile_token);
goto out;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 1214b6cbb19..40109ccb954 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -2131,10 +2131,10 @@ retry:
}
if (volinfo->is_snap_volume) {
- len = snprintf(volfile, PATH_MAX, "/%s/%s/%s.%s.%s",
+ len = snprintf(volfile, PATH_MAX, "/%s/%s/%s/%s.%s.%s",
GLUSTERD_VOL_SNAP_DIR_PREFIX,
volinfo->snapshot->snapname, volinfo->volname,
- brickinfo->hostname, exp_path);
+ volinfo->volname, brickinfo->hostname, exp_path);
} else {
len = snprintf(volfile, PATH_MAX, "%s.%s.%s", volinfo->volname,
brickinfo->hostname, exp_path);
@@ -5663,10 +5663,10 @@ attach_brick(xlator_t *this, glusterd_brickinfo_t *brickinfo,
GLUSTERD_GET_BRICK_PIDFILE(pidfile2, volinfo, brickinfo, conf);
if (volinfo->is_snap_volume) {
- len = snprintf(full_id, sizeof(full_id), "/%s/%s/%s.%s.%s",
+ len = snprintf(full_id, sizeof(full_id), "/%s/%s/%s/%s.%s.%s",
GLUSTERD_VOL_SNAP_DIR_PREFIX,
volinfo->snapshot->snapname, volinfo->volname,
- brickinfo->hostname, unslashed);
+ volinfo->volname, brickinfo->hostname, unslashed);
} else {
len = snprintf(full_id, sizeof(full_id), "%s.%s.%s", volinfo->volname,
brickinfo->hostname, unslashed);