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
committerShyamsundar Ranganathan <srangana@redhat.com>2017-10-25 14:03:54 +0000
commit411a401f7e4f81f6a77eea1438a3a43c73e06104 (patch)
treea89832e50aabb4b15c08a5674518e7addbfbdbd4 /xlators/mgmt/glusterd/src/glusterd.c
parentbe662aa3007898c22ad2e9d23db63f2e88a6d434 (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> > (Cherry pick from commit 220d406ad13d840e950eef001a2b36f87570058d) BUG: 1491059 Change-Id: Idb09e3fccb6a7355fbac1df31082637c8d7ab5b4 Signed-off-by: Mohit Agrawal <moagrawa@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 d4bf77c638b..a5738919c79 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -1420,6 +1420,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;
@@ -1451,6 +1452,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) {
@@ -1495,6 +1507,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,
@@ -1505,6 +1522,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 "
@@ -1524,6 +1542,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);
@@ -1547,6 +1610,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);
@@ -1758,6 +1834,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);