|
|
887953 |
From fd9e0103cd5c3f2962e063dbc3083c451b7e592b Mon Sep 17 00:00:00 2001
|
|
|
887953 |
From: Raghavendra Bhat <raghavendra@redhat.com>
|
|
|
887953 |
Date: Thu, 4 Oct 2018 14:27:45 -0400
|
|
|
887953 |
Subject: [PATCH 433/444] mgmt/glusterd: use proper path to the volfile
|
|
|
887953 |
|
|
|
887953 |
> Upstream: https://review.gluster.org/#/c/glusterfs/+/21314/
|
|
|
887953 |
> BUG: 1635050
|
|
|
887953 |
> Change-Id: I28b2dfa5d9b379fe943db92c2fdfea879a6a594e
|
|
|
887953 |
|
|
|
887953 |
NOTE: This patch is actually directly applied from the patch that
|
|
|
887953 |
was sent to the release-4.1 branch. The master branch patch
|
|
|
887953 |
will have merge conflicts due to the clang format changes done
|
|
|
887953 |
there. This is the patch which this commit is a backport of.
|
|
|
887953 |
|
|
|
887953 |
upstream(4.1): https://review.gluster.org/#/c/glusterfs/+/21348/
|
|
|
887953 |
Chane-ID: I28b2dfa5d9b379fe943db92c2fdfea879a6a594e
|
|
|
887953 |
|
|
|
887953 |
Till now, glusterd was generating the volfile path for the snapshot
|
|
|
887953 |
volume's bricks like this.
|
|
|
887953 |
|
|
|
887953 |
/snaps/<snap name>/<brick volfile>
|
|
|
887953 |
|
|
|
887953 |
But in reality, the path to the brick volfile for a snapshot volume is
|
|
|
887953 |
|
|
|
887953 |
/snaps/<snap name>/<snap volume name>/<brick volfile>
|
|
|
887953 |
|
|
|
887953 |
The above workaround was used to distinguish between a mount command used
|
|
|
887953 |
to mount the snapshot volume, and a brick of the snapshot volume, so that
|
|
|
887953 |
based on what is actually happening, glusterd can return the proper volfile
|
|
|
887953 |
(client volfile for the former and the brick volfile for the latter). But,
|
|
|
887953 |
this was causing problems for snapshot restore when brick multiplexing is
|
|
|
887953 |
enabled. Because, with brick multiplexing, it tries to find the volfile
|
|
|
887953 |
and sends GETSPEC rpc call to glusterd using the 2nd style of path i.e.
|
|
|
887953 |
|
|
|
887953 |
/snaps/<snap name>/<snap volume name>/<brick volfile>
|
|
|
887953 |
|
|
|
887953 |
So, when the snapshot brick (which is multiplexed) sends a GETSPEC rpc
|
|
|
887953 |
request to glusterd for obtaining the brick volume file, glusterd was
|
|
|
887953 |
returning the client volume file of the snapshot volume instead of the
|
|
|
887953 |
brick volume file.
|
|
|
887953 |
|
|
|
887953 |
Change-Id: I28b2dfa5d9b379fe943db92c2fdfea879a6a594e
|
|
|
887953 |
BUG: 1636291
|
|
|
887953 |
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
|
|
|
887953 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/155129
|
|
|
887953 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
887953 |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
887953 |
---
|
|
|
887953 |
.../snapview-server/src/snapview-server-helpers.c | 5 +++--
|
|
|
887953 |
xlators/mgmt/glusterd/src/glusterd-handshake.c | 20 ++++++++++++++++++--
|
|
|
887953 |
xlators/mgmt/glusterd/src/glusterd-utils.c | 9 +++++----
|
|
|
887953 |
3 files changed, 26 insertions(+), 8 deletions(-)
|
|
|
887953 |
|
|
|
887953 |
diff --git a/xlators/features/snapview-server/src/snapview-server-helpers.c b/xlators/features/snapview-server/src/snapview-server-helpers.c
|
|
|
887953 |
index 2ad74ef..4c2edc6 100644
|
|
|
887953 |
--- a/xlators/features/snapview-server/src/snapview-server-helpers.c
|
|
|
887953 |
+++ b/xlators/features/snapview-server/src/snapview-server-helpers.c
|
|
|
887953 |
@@ -481,8 +481,9 @@ __svs_initialise_snapshot_volume (xlator_t *this, const char *name,
|
|
|
887953 |
goto out;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
- snprintf (volname, sizeof (volname), "/snaps/%s/%s",
|
|
|
887953 |
- dirent->name, dirent->snap_volname);
|
|
|
887953 |
+ snprintf (volname, sizeof (volname), "/snaps/%s/%s/%s",
|
|
|
887953 |
+ dirent->name, dirent->snap_volname,
|
|
|
887953 |
+ dirent->snap_volname);
|
|
|
887953 |
|
|
|
887953 |
|
|
|
887953 |
fs = glfs_new (volname);
|
|
|
887953 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c
|
|
|
887953 |
index d5594d0..b2a9b20 100644
|
|
|
887953 |
--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c
|
|
|
887953 |
+++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c
|
|
|
887953 |
@@ -52,6 +52,7 @@ get_snap_volname_and_volinfo (const char *volpath, char **volname,
|
|
|
887953 |
char *vol = NULL;
|
|
|
887953 |
glusterd_snap_t *snap = NULL;
|
|
|
887953 |
xlator_t *this = NULL;
|
|
|
887953 |
+ char *volfile_token = NULL;
|
|
|
887953 |
|
|
|
887953 |
this = THIS;
|
|
|
887953 |
GF_ASSERT (this);
|
|
|
887953 |
@@ -101,12 +102,27 @@ get_snap_volname_and_volinfo (const char *volpath, char **volname,
|
|
|
887953 |
*/
|
|
|
887953 |
ret = glusterd_volinfo_find (volname_token, volinfo);
|
|
|
887953 |
if (ret) {
|
|
|
887953 |
- *volname = gf_strdup (volname_token);
|
|
|
887953 |
+ gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_VOLINFO_GET_FAIL,
|
|
|
887953 |
+ "failed to get the volinfo for the volume %s",
|
|
|
887953 |
+ volname_token);
|
|
|
887953 |
+
|
|
|
887953 |
+ /* Get the actual volfile name */
|
|
|
887953 |
+ volfile_token = strtok_r (NULL, "/", &save_ptr);
|
|
|
887953 |
+ *volname = gf_strdup (volfile_token);
|
|
|
887953 |
if (NULL == *volname) {
|
|
|
887953 |
ret = -1;
|
|
|
887953 |
goto out;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
+ /*
|
|
|
887953 |
+ * Ideally, this should succeed as volname_token now
|
|
|
887953 |
+ * contains the name of the snap volume (i.e. name of
|
|
|
887953 |
+ * the volume that represents the snapshot).
|
|
|
887953 |
+ * But, if for some reason, volinfo for the snap volume
|
|
|
887953 |
+ * is not found, then try to get from the name of the
|
|
|
887953 |
+ * volfile. Name of the volfile is like this.
|
|
|
887953 |
+ * <snap volume name>.<hostname>.<brick path>.vol
|
|
|
887953 |
+ */
|
|
|
887953 |
ret = glusterd_snap_volinfo_find (volname_token, snap,
|
|
|
887953 |
volinfo);
|
|
|
887953 |
if (ret) {
|
|
|
887953 |
@@ -115,7 +131,7 @@ get_snap_volname_and_volinfo (const char *volpath, char **volname,
|
|
|
887953 |
if (!vol) {
|
|
|
887953 |
gf_msg (this->name, GF_LOG_ERROR, EINVAL,
|
|
|
887953 |
GD_MSG_INVALID_ENTRY, "Invalid "
|
|
|
887953 |
- "volname (%s)", volname_token);
|
|
|
887953 |
+ "volname (%s)", volfile_token);
|
|
|
887953 |
goto out;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
887953 |
index 04fae63..7179a68 100644
|
|
|
887953 |
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
887953 |
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
887953 |
@@ -2068,10 +2068,10 @@ retry:
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
if (volinfo->is_snap_volume) {
|
|
|
887953 |
- snprintf (volfile, PATH_MAX,"/%s/%s/%s.%s.%s",
|
|
|
887953 |
+ snprintf (volfile, PATH_MAX, "/%s/%s/%s/%s.%s.%s",
|
|
|
887953 |
GLUSTERD_VOL_SNAP_DIR_PREFIX,
|
|
|
887953 |
volinfo->snapshot->snapname, volinfo->volname,
|
|
|
887953 |
- brickinfo->hostname, exp_path);
|
|
|
887953 |
+ volinfo->volname, brickinfo->hostname, exp_path);
|
|
|
887953 |
} else {
|
|
|
887953 |
snprintf (volfile, PATH_MAX, "%s.%s.%s", volinfo->volname,
|
|
|
887953 |
brickinfo->hostname, exp_path);
|
|
|
887953 |
@@ -5676,10 +5676,11 @@ attach_brick (xlator_t *this,
|
|
|
887953 |
GLUSTERD_GET_BRICK_PIDFILE (pidfile2, volinfo, brickinfo, conf);
|
|
|
887953 |
|
|
|
887953 |
if (volinfo->is_snap_volume) {
|
|
|
887953 |
- snprintf (full_id, sizeof(full_id), "/%s/%s/%s.%s.%s",
|
|
|
887953 |
+ snprintf (full_id, sizeof(full_id), "/%s/%s/%s/%s.%s.%s",
|
|
|
887953 |
GLUSTERD_VOL_SNAP_DIR_PREFIX,
|
|
|
887953 |
volinfo->snapshot->snapname,
|
|
|
887953 |
- volinfo->volname, brickinfo->hostname, unslashed);
|
|
|
887953 |
+ volinfo->volname, volinfo->volname,
|
|
|
887953 |
+ brickinfo->hostname, unslashed);
|
|
|
887953 |
} else {
|
|
|
887953 |
snprintf (full_id, sizeof(full_id), "%s.%s.%s",
|
|
|
887953 |
volinfo->volname, brickinfo->hostname, unslashed);
|
|
|
887953 |
--
|
|
|
887953 |
1.8.3.1
|
|
|
887953 |
|