summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2013-12-04 02:10:10 +0000
committerAvra Sengupta <asengupt@redhat.com>2013-12-10 23:53:29 +0000
commitdb9476c6dd4af75c3f658bc4ee4ce82403eb5fdf (patch)
treeb3582b8707b52e03f6cc2fc9839750a719c4110a
parent79467d3a41689b7789a15b923ef97e4c1f19d20b (diff)
glusterd/snap: Fix for socket connect failures on brick start
Change-Id: I9f53bd4d83794c69c54e4a03f59425a1ca6a4ac3 Signed-off-by: Avra Sengupta <asengupt@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c65
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h2
2 files changed, 34 insertions, 33 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 557f04d..5592af5 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -1256,10 +1256,9 @@ glusterd_set_brick_socket_filepath (glusterd_volinfo_t *volinfo,
*/
int32_t
glusterd_brick_connect (glusterd_volinfo_t *volinfo,
- glusterd_brickinfo_t *brickinfo)
+ glusterd_brickinfo_t *brickinfo, char *socketpath)
{
int ret = 0;
- char socketpath[PATH_MAX] = {0};
char volume_id_str[64];
char *brickid = NULL;
dict_t *options = NULL;
@@ -1268,12 +1267,9 @@ glusterd_brick_connect (glusterd_volinfo_t *volinfo,
GF_ASSERT (volinfo);
GF_ASSERT (brickinfo);
+ GF_ASSERT (socketpath);
if (brickinfo->rpc == NULL) {
- glusterd_set_brick_socket_filepath (volinfo, brickinfo,
- socketpath,
- sizeof (socketpath));
-
/* Setting frame-timeout to 10mins (600seconds).
* Unix domain sockets ensures that the connection is reliable.
* The default timeout of 30mins used for unreliable network
@@ -1386,6 +1382,10 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
ret = _mk_rundir_p (volinfo);
if (ret)
goto out;
+
+ glusterd_set_brick_socket_filepath (volinfo, brickinfo, socketpath,
+ sizeof (socketpath));
+
GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo, priv);
if (glusterd_is_service_running (pidfile, NULL))
goto connect;
@@ -1436,9 +1436,6 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
if (!brickinfo->logfile)
brickinfo->logfile = gf_strdup (logfile);
- glusterd_set_brick_socket_filepath (volinfo, brickinfo, socketpath,
- sizeof (socketpath));
-
(void) snprintf (glusterd_uuid, 1024, "*-posix.glusterd-uuid=%s",
uuid_utoa (MY_UUID));
runner_add_args (&runner, SBIN_DIR"/glusterfsd",
@@ -1486,9 +1483,13 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
brickinfo->rdma_port = rdma_port;
connect:
- ret = glusterd_brick_connect (volinfo, brickinfo);
- if (ret)
+ ret = glusterd_brick_connect (volinfo, brickinfo, socketpath);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to connect to brick %s:%s on %s",
+ brickinfo->hostname, brickinfo->path, socketpath);
goto out;
+ }
out:
return ret;
}
@@ -1530,6 +1531,18 @@ glusterd_snap_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
ret = _mk_snap_rundir_p (volinfo, snap_volinfo);
if (ret)
goto out;
+
+ expected_file_len = strlen (GLUSTERD_SOCK_DIR) + strlen ("/") +
+ MD5_DIGEST_LENGTH*2 + strlen (".socket") + 1;
+ GF_ASSERT (sizeof (socketpath) >= expected_file_len);
+
+ GLUSTERD_GET_SNAP_DIR (snap_dir, volinfo, snap_volinfo->volname, priv);
+ GLUSTERD_REMOVE_SLASH_FROM_PATH (brickinfo->path, export_path);
+ snprintf (sock_filepath, PATH_MAX, "%s/run/%s-%s",
+ snap_dir, brickinfo->hostname, export_path);
+
+ glusterd_set_socket_filepath (sock_filepath, socketpath, sizeof (socketpath));
+
GLUSTERD_GET_SNAP_BRICK_PIDFILE (pidfile, volinfo,
snap_volinfo->volname,
brickinfo, priv);
@@ -1551,16 +1564,16 @@ glusterd_snap_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
if (priv->valgrind) {
/* Run bricks with valgrind */
- if (volinfo->logdir) {
+ if (snap_volinfo->logdir) {
snprintf (valgrind_logfile, PATH_MAX,
"%s/valgrind-%s-%s.log",
- volinfo->logdir,
- volinfo->volname, exp_path);
+ snap_volinfo->logdir,
+ snap_volinfo->volname, exp_path);
} else {
snprintf (valgrind_logfile, PATH_MAX,
"%s/bricks/valgrind-%s-%s.log",
DEFAULT_LOG_FILE_DIRECTORY,
- volinfo->volname, exp_path);
+ snap_volinfo->volname, exp_path);
}
runner_add_args (&runner, "valgrind", "--leak-check=full",
@@ -1573,9 +1586,9 @@ glusterd_snap_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
volinfo->volname, snap_volinfo->volname,
snap_volinfo->volname, brickinfo->hostname, exp_path);
- if (volinfo->logdir) {
+ if (snap_volinfo->logdir) {
snprintf (logfile, PATH_MAX, "%s/%s.log",
- volinfo->logdir, exp_path);
+ snap_volinfo->logdir, exp_path);
} else {
snprintf (logfile, PATH_MAX, "%s/bricks/%s.log",
DEFAULT_LOG_FILE_DIRECTORY, exp_path);
@@ -1583,18 +1596,6 @@ glusterd_snap_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
if (!brickinfo->logfile)
brickinfo->logfile = gf_strdup (logfile);
-
- expected_file_len = strlen (GLUSTERD_SOCK_DIR) + strlen ("/") +
- MD5_DIGEST_LENGTH*2 + strlen (".socket") + 1;
- GF_ASSERT (sizeof (socketpath) >= expected_file_len);
-
- GLUSTERD_GET_SNAP_DIR (snap_dir, volinfo, snap_volinfo->volname, priv);
- GLUSTERD_REMOVE_SLASH_FROM_PATH (brickinfo->path, export_path);
- snprintf (sock_filepath, PATH_MAX, "%s/run/%s-%s",
- snap_dir, brickinfo->hostname, export_path);
-
- glusterd_set_socket_filepath (sock_filepath, socketpath, sizeof (socketpath));
-
snprintf (snap_volfile, sizeof (snap_volfile), "%s/vols/%s/snaps/%s/%s",
priv->workdir, volinfo->volname, snap_volinfo->volname,
volfile);
@@ -1610,7 +1611,7 @@ glusterd_snap_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
NULL);
runner_add_arg (&runner, "--brick-port");
- if (volinfo->transport_type != GF_TRANSPORT_BOTH_TCP_RDMA) {
+ if (snap_volinfo->transport_type != GF_TRANSPORT_BOTH_TCP_RDMA) {
runner_argprintf (&runner, "%d", port);
} else {
rdma_port = brickinfo->rdma_port;
@@ -1626,7 +1627,7 @@ glusterd_snap_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
runner_argprintf (&runner, "%s-server.listen-port=%d",
snap_volinfo->volname, port);
- if (volinfo->memory_accounting)
+ if (snap_volinfo->memory_accounting)
runner_add_arg (&runner, "--mem-accounting");
runner_log (&runner, "", GF_LOG_DEBUG, "Starting GlusterFS");
@@ -1646,7 +1647,7 @@ glusterd_snap_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
brickinfo->rdma_port = rdma_port;
connect:
- ret = glusterd_brick_connect (volinfo, brickinfo);
+ ret = glusterd_brick_connect (snap_volinfo, brickinfo, socketpath);
if (ret)
goto out;
out:
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 1d5a93c..ca3c620 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -365,7 +365,7 @@ gf_boolean_t
glusterd_peerinfo_is_uuid_unknown (glusterd_peerinfo_t *peerinfo);
int32_t
glusterd_brick_connect (glusterd_volinfo_t *volinfo,
- glusterd_brickinfo_t *brickinfo);
+ glusterd_brickinfo_t *brickinfo, char *socketpath);
int32_t
glusterd_brick_disconnect (glusterd_brickinfo_t *brickinfo);
int32_t