summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2019-06-25 10:51:33 -0400
committerRinku Kothiya <rkothiya@redhat.com>2019-07-18 13:11:04 +0000
commite5e9a9817cecbd8f2c823e79179d9523b1a04ee3 (patch)
tree2e08a357ac2eb42fddcc743f24e4e2c7e8a01bc9
parent4d84f0afee639c2a9e5e3c83d3ae9d5b8692997c (diff)
features/snapview-server: use the same volfile server for gfapi options
snapview server xlator makes use of "localhost" as the volfile server while initing the new glfs instance to talk to a snapshot. While localhost is fine, better use the same volfile server that was used to start the snapshot daemon containing the snapview-server xlator. Change-Id: I4485d39b0e3d066f481adc6958ace53ea33237f7 fixes: bz#1728391 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com> (cherry picked from commit 36f6e6df0ff15d0464b869803710adca2b65e8ba)
-rw-r--r--xlators/features/snapview-server/src/snapview-server-helpers.c44
-rw-r--r--xlators/features/snapview-server/src/snapview-server-messages.h2
2 files changed, 42 insertions, 4 deletions
diff --git a/xlators/features/snapview-server/src/snapview-server-helpers.c b/xlators/features/snapview-server/src/snapview-server-helpers.c
index 5514a54f0d6..62c1ddac49c 100644
--- a/xlators/features/snapview-server/src/snapview-server-helpers.c
+++ b/xlators/features/snapview-server/src/snapview-server-helpers.c
@@ -476,6 +476,7 @@ __svs_initialise_snapshot_volume(xlator_t *this, const char *name,
char logfile[PATH_MAX] = {
0,
};
+ char *volfile_server = NULL;
GF_VALIDATE_OR_GOTO("snapview-server", this, out);
GF_VALIDATE_OR_GOTO(this->name, this->private, out);
@@ -512,14 +513,50 @@ __svs_initialise_snapshot_volume(xlator_t *this, const char *name,
goto out;
}
- ret = glfs_set_volfile_server(fs, "tcp", "localhost", 24007);
+ /*
+ * Before, localhost was used as the volfile server. But, with that
+ * method, accessing snapshots started giving ENOENT error if a
+ * specific bind address is mentioned in the glusterd volume file.
+ * Check the bug https://bugzilla.redhat.com/show_bug.cgi?id=1725211.
+ * So, the new method is tried below, where, snapview-server first
+ * uses the volfile server used by the snapd (obtained from the
+ * command line arguments saved in the global context of the process).
+ * If the volfile server in global context is NULL, then localhost
+ * is tried (like before).
+ */
+ if (this->ctx->cmd_args.volfile_server) {
+ volfile_server = gf_strdup(this->ctx->cmd_args.volfile_server);
+ if (!volfile_server) {
+ gf_msg(this->name, GF_LOG_WARNING, ENOMEM,
+ SVS_MSG_VOLFILE_SERVER_GET_FAIL,
+ "failed to copy volfile server %s. ",
+ this->ctx->cmd_args.volfile_server);
+ ret = -1;
+ goto out;
+ }
+ } else {
+ gf_msg(this->name, GF_LOG_WARNING, ENOMEM,
+ SVS_MSG_VOLFILE_SERVER_GET_FAIL,
+ "volfile server is NULL in cmd args. "
+ "Trying with localhost");
+ volfile_server = gf_strdup("localhost");
+ if (!volfile_server) {
+ gf_msg(this->name, GF_LOG_WARNING, ENOMEM,
+ SVS_MSG_VOLFILE_SERVER_GET_FAIL,
+ "failed to copy volfile server localhost.");
+ ret = -1;
+ goto out;
+ }
+ }
+
+ ret = glfs_set_volfile_server(fs, "tcp", volfile_server, 24007);
if (ret) {
gf_msg(this->name, GF_LOG_ERROR, local_errno,
SVS_MSG_SET_VOLFILE_SERVR_FAILED,
"setting the "
- "volfile server for snap volume %s "
+ "volfile server %s for snap volume %s "
"failed",
- dirent->name);
+ volfile_server, dirent->name);
goto out;
}
@@ -561,6 +598,7 @@ out:
dirent->fs = fs;
}
+ GF_FREE(volfile_server);
return fs;
}
diff --git a/xlators/features/snapview-server/src/snapview-server-messages.h b/xlators/features/snapview-server/src/snapview-server-messages.h
index 8548015648a..f634ab5d2b0 100644
--- a/xlators/features/snapview-server/src/snapview-server-messages.h
+++ b/xlators/features/snapview-server/src/snapview-server-messages.h
@@ -49,6 +49,6 @@ GLFS_MSGID(SNAPVIEW_SERVER, SVS_MSG_NO_MEMORY, SVS_MSG_MEM_ACNT_FAILED,
SVS_MSG_CLOSEDIR_FAILED, SVS_MSG_CLOSE_FAILED,
SVS_MSG_GFID_GEN_FAILED, SVS_MSG_GLFS_NEW_FAILED,
SVS_MSG_SET_VOLFILE_SERVR_FAILED, SVS_MSG_SET_LOGGING_FAILED,
- SVS_MSG_GLFS_INIT_FAILED);
+ SVS_MSG_VOLFILE_SERVER_GET_FAIL, SVS_MSG_GLFS_INIT_FAILED);
#endif /* !_SNAPVIEW_CLIENT_MESSAGES_H_ */