summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd.c
diff options
context:
space:
mode:
authorGaurav Kumar Garg <garg.gaurav52@gmail.com>2016-03-02 17:42:07 +0530
committerAtin Mukherjee <amukherj@redhat.com>2017-08-11 07:36:41 +0000
commit220d406ad13d840e950eef001a2b36f87570058d (patch)
tree9740cb9546b441e555146f5bba5807b95e353703 /xlators/mgmt/glusterd/src/glusterd.c
parentcfdcdd1b1fea3f30d9131dd36afab6efeef2bee0 (diff)
glusterd: Gluster should keep PID file in correct location
Currently Gluster keeps process pid information of all the daemons and brick processes in Gluster configuration file directory (ie., /var/lib/glusterd/*). These pid files should be seperate from configuration files. Deletion of the configuration file directory might result into serious problems. Also, /var/run/gluster is the default placeholder directory for pid files. So, with this fix Gluster will keep all process pid information of all processes in /var/run/gluster/* directory. Change-Id: Idb09e3fccb6a7355fbac1df31082637c8d7ab5b4 BUG: 1258561 Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com> Signed-off-by: Saravanakumar Arumugam <sarumuga@redhat.com> Reviewed-on: https://review.gluster.org/13580 Tested-by: MOHIT AGRAWAL <moagrawa@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 68998f0a877..4887ff413bf 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -1390,6 +1390,7 @@ init (xlator_t *this)
struct stat buf = {0,};
char storedir[PATH_MAX] = {0,};
char workdir[PATH_MAX] = {0,};
+ char rundir[PATH_MAX] = {0,};
char cmd_log_filename[PATH_MAX] = {0,};
char *mountbroker_root = NULL;
int i = 0;
@@ -1423,6 +1424,17 @@ init (xlator_t *this)
}
#endif
+ dir_data = dict_get (this->options, "run-directory");
+
+ if (!dir_data) {
+ /* Use default working dir */
+ strncpy (rundir, DEFAULT_VAR_RUN_DIRECTORY, PATH_MAX);
+ } else {
+ strncpy (rundir, dir_data->data, PATH_MAX);
+ }
+
+ dir_data = NULL;
+
dir_data = dict_get (this->options, "working-directory");
if (!dir_data) {
@@ -1467,6 +1479,11 @@ init (xlator_t *this)
GD_MSG_CURR_WORK_DIR_INFO, "Using %s as working directory",
workdir);
+ setenv ("DEFAULT_VAR_RUN_DIRECTORY", rundir, 1);
+ gf_msg (this->name, GF_LOG_INFO, 0,
+ GD_MSG_CURR_WORK_DIR_INFO, "Using %s as pid file working "
+ "directory", rundir);
+
ret = glusterd_find_correct_var_run_dir (this, var_run_dir);
if (ret) {
gf_msg (this->name, GF_LOG_CRITICAL, 0,
@@ -1477,6 +1494,7 @@ init (xlator_t *this)
ret = glusterd_init_var_run_dirs (this, var_run_dir,
GLUSTERD_DEFAULT_SNAPS_BRICK_DIR);
+
if (ret) {
gf_msg (this->name, GF_LOG_CRITICAL, 0,
GD_MSG_CREATE_DIR_FAILED, "Unable to create "
@@ -1496,6 +1514,51 @@ init (xlator_t *this)
exit (1);
}
+ ret = glusterd_init_var_run_dirs (this, rundir,
+ GLUSTERD_BITD_RUN_DIR);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_CRITICAL, 0,
+ GD_MSG_CREATE_DIR_FAILED, "Unable to create "
+ "bitd running directory");
+ exit (1);
+ }
+
+ ret = glusterd_init_var_run_dirs (this, rundir,
+ GLUSTERD_SCRUB_RUN_DIR);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_CRITICAL, 0,
+ GD_MSG_CREATE_DIR_FAILED, "Unable to create "
+ "scrub running directory");
+ exit (1);
+ }
+
+ ret = glusterd_init_var_run_dirs (this, rundir,
+ GLUSTERD_GLUSTERSHD_RUN_DIR);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_CRITICAL, 0,
+ GD_MSG_CREATE_DIR_FAILED, "Unable to create "
+ "glustershd running directory");
+ exit (1);
+ }
+
+ ret = glusterd_init_var_run_dirs (this, rundir,
+ GLUSTERD_NFS_RUN_DIR);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_CRITICAL, 0,
+ GD_MSG_CREATE_DIR_FAILED, "Unable to create "
+ "nfs running directory");
+ exit (1);
+ }
+
+ ret = glusterd_init_var_run_dirs (this, rundir,
+ GLUSTERD_QUOTAD_RUN_DIR);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_CRITICAL, 0,
+ GD_MSG_CREATE_DIR_FAILED, "Unable to create "
+ "quota running directory");
+ exit (1);
+ }
+
snprintf (cmd_log_filename, PATH_MAX, "%s/cmd_history.log",
DEFAULT_LOG_FILE_DIRECTORY);
ret = gf_cmd_log_init (cmd_log_filename);
@@ -1519,6 +1582,19 @@ init (xlator_t *this)
exit (1);
}
+ /*keeping individual volume pid file information in /var/run/gluster* */
+ snprintf (storedir, PATH_MAX, "%s/vols", rundir);
+
+ ret = sys_mkdir (storedir, 0777);
+
+ if ((-1 == ret) && (errno != EEXIST)) {
+ gf_msg (this->name, GF_LOG_CRITICAL, errno,
+ GD_MSG_CREATE_DIR_FAILED,
+ "Unable to create volume directory %s"
+ " ,errno = %d", storedir, errno);
+ exit (1);
+ }
+
snprintf (storedir, PATH_MAX, "%s/snaps", workdir);
ret = sys_mkdir (storedir, 0777);
@@ -1731,6 +1807,7 @@ init (xlator_t *this)
conf->uds_rpc = uds_rpc;
conf->gfs_mgmt = &gd_brick_prog;
strncpy (conf->workdir, workdir, PATH_MAX);
+ strncpy (conf->rundir, rundir, PATH_MAX);
synclock_init (&conf->big_lock, SYNC_LOCK_RECURSIVE);
pthread_mutex_init (&conf->xprt_lock, NULL);