diff options
author | Kaushal M <kaushal@redhat.com> | 2013-12-30 09:59:18 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2014-01-10 02:08:37 -0800 |
commit | 2edf1ec797e6f56515d0208be152d18ca6e71456 (patch) | |
tree | de1685ab7fa37e6e09d6668db9ca22a44d3d818a /xlators | |
parent | a2f772de44cc09d595005f4d3316fbd0f37c46b8 (diff) |
glusterd: Relocate rebalance sockfile
The defrag sockfile was moved from priv->workdir to
DEFAULT_VAR_RUN_DIRECTORY. The format for the new path of the defrag
sockfile is 'DEFAULT_VAR_RUN_DIRECTORY/gluster-rebalance-<vol-id>.sock'.
This was needed because the earlier location didn't have a fixed length
and could exceed UNIX_PATH_MAX characters. This could lead to the
rebalance process failing to start as the socket file could not be
created.
Also, for keeping backward compatiblity, glusterd_rebalance_rpc_create
will try both the new and old sockfile locations when attempting
reconnection.
Change-Id: I6740ea665de84ebce1ef7199c412f426de54e3d0
BUG: 1049726
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.org/6616
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-rebalance.c | 41 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 2 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.h | 11 |
3 files changed, 46 insertions, 8 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c index daa8ddd1def..b2805613517 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c +++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c @@ -237,7 +237,7 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr, goto out; } - GLUSTERD_GET_DEFRAG_SOCK_FILE (sockfile, volinfo, priv); + GLUSTERD_GET_DEFRAG_SOCK_FILE (sockfile, volinfo); GLUSTERD_GET_DEFRAG_PID_FILE (pidfile, volinfo, priv); snprintf (logfile, PATH_MAX, "%s/%s-rebalance.log", DEFAULT_LOG_FILE_DIRECTORY, volinfo->volname); @@ -288,7 +288,7 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr, sleep (5); - ret = glusterd_rebalance_rpc_create (volinfo); + ret = glusterd_rebalance_rpc_create (volinfo, _gf_false); //FIXME: this cbk is passed as NULL in all occurrences. May be //we never needed it. @@ -302,13 +302,21 @@ out: int -glusterd_rebalance_rpc_create (glusterd_volinfo_t *volinfo) +glusterd_rebalance_rpc_create (glusterd_volinfo_t *volinfo, + gf_boolean_t reconnect) { dict_t *options = NULL; char sockfile[PATH_MAX] = {0,}; int ret = -1; glusterd_defrag_info_t *defrag = volinfo->rebal.defrag; - glusterd_conf_t *priv = THIS->private; + glusterd_conf_t *priv = NULL; + xlator_t *this = NULL; + struct stat buf = {0,}; + + this = THIS; + GF_ASSERT (this); + priv = this->private; + GF_ASSERT (priv); //rebalance process is not started if (!defrag) @@ -319,7 +327,30 @@ glusterd_rebalance_rpc_create (glusterd_volinfo_t *volinfo) ret = 0; goto out; } - GLUSTERD_GET_DEFRAG_SOCK_FILE (sockfile, volinfo, priv); + GLUSTERD_GET_DEFRAG_SOCK_FILE (sockfile, volinfo); + /* If reconnecting check if defrag sockfile exists in the new location + * in /var/run/ , if it does not try the old location + */ + if (reconnect) { + ret = sys_stat (sockfile, &buf); + /* TODO: Remove this once we don't need backward compatability + * with the older path + */ + if (ret && (errno == ENOENT)) { + gf_log (this->name, GF_LOG_WARNING, "Rebalance sockfile " + "%s does not exist. Trying old path.", + sockfile); + GLUSTERD_GET_DEFRAG_SOCK_FILE_OLD (sockfile, volinfo, + priv); + ret =sys_stat (sockfile, &buf); + if (ret && (ENOENT == errno)) { + gf_log (this->name, GF_LOG_ERROR, "Rebalance " + "sockfile %s does not exist.", + sockfile); + goto out; + } + } + } /* Setting frame-timeout to 10mins (600seconds). * Unix domain sockets ensures that the connection is reliable. The diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index a0c9691249a..4a88b5b3523 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -6949,7 +6949,7 @@ glusterd_volume_defrag_restart (glusterd_volinfo_t *volinfo, char *op_errstr, case GF_DEFRAG_STATUS_STARTED: GLUSTERD_GET_DEFRAG_PID_FILE(pidfile, volinfo, priv); if (gf_is_service_running (pidfile, &pid)) { - glusterd_rebalance_rpc_create (volinfo); + glusterd_rebalance_rpc_create (volinfo, _gf_true); break; } case GF_DEFRAG_STATUS_NOT_STARTED: diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index ab383ac1c9a..9b6e2fb3343 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -439,13 +439,19 @@ typedef ssize_t (*gd_serialize_t) (struct iovec outmsg, void *args); snprintf (path, PATH_MAX, "%s/rebalance",vol_path); \ } while (0) -#define GLUSTERD_GET_DEFRAG_SOCK_FILE(path, volinfo, priv) do { \ +#define GLUSTERD_GET_DEFRAG_SOCK_FILE_OLD(path, volinfo, priv) do { \ char defrag_path[PATH_MAX]; \ GLUSTERD_GET_DEFRAG_DIR(defrag_path, volinfo, priv); \ snprintf (path, PATH_MAX, "%s/%s.sock", defrag_path, \ uuid_utoa(MY_UUID)); \ } while (0) +#define GLUSTERD_GET_DEFRAG_SOCK_FILE(path, volinfo) do { \ + snprintf (path, UNIX_PATH_MAX, DEFAULT_VAR_RUN_DIRECTORY \ + "/gluster-rebalance-%s.sock", \ + uuid_utoa(volinfo->volume_id)); \ + } while (0) + #define GLUSTERD_GET_DEFRAG_PID_FILE(path, volinfo, priv) do { \ char defrag_path[PATH_MAX]; \ GLUSTERD_GET_DEFRAG_DIR(defrag_path, volinfo, priv); \ @@ -727,7 +733,8 @@ int glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr, size_t len, int cmd, defrag_cbk_fn_t cbk, glusterd_op_t op); int -glusterd_rebalance_rpc_create (glusterd_volinfo_t *volinfo); +glusterd_rebalance_rpc_create (glusterd_volinfo_t *volinfo, + gf_boolean_t reconnect); int glusterd_handle_cli_heal_volume (rpcsvc_request_t *req); |