diff options
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd.c')
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.c | 325 |
1 files changed, 194 insertions, 131 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c index b87b08e47dc..7a86c2997b1 100644 --- a/xlators/mgmt/glusterd/src/glusterd.c +++ b/xlators/mgmt/glusterd/src/glusterd.c @@ -37,7 +37,9 @@ #include "glusterd-locks.h" #include "glusterd-svc-mgmt.h" #include "glusterd-shd-svc.h" +#ifdef BUILD_GNFS #include "glusterd-nfs-svc.h" +#endif #include "glusterd-bitd-svc.h" #include "glusterd-scrub-svc.h" #include "glusterd-quotad-svc.h" @@ -65,7 +67,7 @@ extern struct rpcsvc_program gd_svc_cli_trusted_progs; extern struct rpc_clnt_program gd_brick_prog; extern struct rpcsvc_program glusterd_mgmt_hndsk_prog; -extern char snap_mount_dir[PATH_MAX]; +extern char snap_mount_dir[VALID_GLUSTERD_PATHMAX]; rpcsvc_cbk_program_t glusterd_cbk_prog = { .progname = "Gluster Callback", @@ -200,8 +202,10 @@ glusterd_options_init(xlator_t *this) priv = this->private; priv->opts = dict_new(); - if (!priv->opts) + if (!priv->opts) { + gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_CREATE_FAIL, NULL); goto out; + } ret = glusterd_store_retrieve_options(this); if (ret == 0) { @@ -245,6 +249,7 @@ glusterd_client_statedump_submit_req(char *volname, char *target_ip, char *pid) GF_ASSERT(conf); if (target_ip == NULL || pid == NULL) { + gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_INVALID_ARGUMENT, NULL); ret = -1; goto out; } @@ -445,14 +450,19 @@ glusterd_rpcsvc_options_build(dict_t *options) { int ret = 0; uint32_t backlog = 0; + xlator_t *this = THIS; + GF_ASSERT(this); ret = dict_get_uint32(options, "transport.listen-backlog", &backlog); if (ret) { backlog = GLUSTERFS_SOCKET_LISTEN_BACKLOG; ret = dict_set_uint32(options, "transport.listen-backlog", backlog); - if (ret) + if (ret) { + gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_SET_FAILED, + "Key=transport.listen-backlog", NULL); goto out; + } } gf_msg_debug("glusterd", 0, "listen-backlog value: %d", backlog); @@ -555,7 +565,9 @@ glusterd_crt_georep_folders(char *georepdir, glusterd_conf_t *conf) char *greplg_s = NULL; struct group *gr = NULL; int ret = 0; + int gr_ret = 0; int32_t len = 0; + char logdir[PATH_MAX] = {0}; GF_ASSERT(georepdir); GF_ASSERT(conf); @@ -570,87 +582,106 @@ glusterd_crt_georep_folders(char *georepdir, glusterd_conf_t *conf) len = snprintf(georepdir, PATH_MAX, "%s/" GEOREP, conf->workdir); if ((len < 0) || (len >= PATH_MAX)) { + gf_smsg("glusterd", GF_LOG_ERROR, errno, GD_MSG_COPY_FAIL, NULL); ret = -1; goto out; } - ret = mkdir_p(georepdir, 0777, _gf_true); + ret = mkdir_p(georepdir, 0755, _gf_true); if (-1 == ret) { gf_msg("glusterd", GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED, "Unable to create " GEOREP " directory %s", georepdir); goto out; } - if (SLEN(DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP) >= PATH_MAX) { + ret = dict_get_str(THIS->options, GEOREP "-log-group", &greplg_s); + if (ret) { + gf_smsg("glusterd", GF_LOG_ERROR, errno, GD_MSG_DICT_GET_FAILED, + "Key=log-group", NULL); + ret = 0; + } else { + gr = getgrnam(greplg_s); + if (!gr) { + gf_msg("glusterd", GF_LOG_CRITICAL, 0, GD_MSG_LOGGROUP_INVALID, + "group " GEOREP "-log-group %s does not exist", greplg_s); + gr_ret = -1; + } + } + if ((strlen(conf->logdir) + 2 + SLEN(GEOREP)) >= PATH_MAX) { ret = -1; gf_msg("glusterd", GF_LOG_CRITICAL, 0, GD_MSG_DIRPATH_TOO_LONG, - "directory path " DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP - " is longer than PATH_MAX"); + "directory path %s/" GEOREP " is longer than PATH_MAX", + conf->logdir); + goto out; + } + len = snprintf(logdir, PATH_MAX, "%s/" GEOREP, conf->logdir); + if ((len < 0) || (len >= PATH_MAX)) { + ret = -1; goto out; } - ret = mkdir_p(DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP, 0777, _gf_true); + ret = mkdir_p(logdir, 0755, _gf_true); if (-1 == ret) { gf_msg("glusterd", GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED, "Unable to create " GEOREP " log directory"); goto out; } + if (gr) { + gr_ret = group_write_allow(logdir, gr->gr_gid); + } - /* Slave log file directory */ - if (SLEN(DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP "-slaves") >= PATH_MAX) { + if ((strlen(conf->logdir) + 2 + SLEN(GEOREP "-slaves")) >= PATH_MAX) { ret = -1; gf_msg("glusterd", GF_LOG_CRITICAL, 0, GD_MSG_DIRPATH_TOO_LONG, - "directory path " DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP + "directory path %s/" GEOREP "-slaves" - " is longer than PATH_MAX"); + " is longer than PATH_MAX", + conf->logdir); goto out; } - ret = mkdir_p(DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP "-slaves", 0777, - _gf_true); + len = snprintf(logdir, PATH_MAX, "%s/" GEOREP "-slaves", conf->logdir); + if ((len < 0) || (len >= PATH_MAX)) { + gf_smsg("glusterd", GF_LOG_ERROR, errno, GD_MSG_COPY_FAIL, NULL); + ret = -1; + goto out; + } + ret = mkdir_p(logdir, 0755, _gf_true); if (-1 == ret) { gf_msg("glusterd", GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED, "Unable to create " GEOREP " slave log directory"); goto out; } + if (gr && !gr_ret) { + gr_ret = group_write_allow(logdir, gr->gr_gid); + } /* MountBroker log file directory */ - if (SLEN(DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP "-slaves/mbr") >= PATH_MAX) { + if ((strlen(conf->logdir) + 2 + SLEN(GEOREP "-slaves/mbr")) >= PATH_MAX) { ret = -1; gf_msg("glusterd", GF_LOG_CRITICAL, 0, GD_MSG_DIRPATH_TOO_LONG, - "directory path " DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP + "directory path %s/" GEOREP "-slaves/mbr" - " is longer than PATH_MAX"); + " is longer than PATH_MAX", + conf->logdir); + goto out; + } + + len = snprintf(logdir, PATH_MAX, "%s/" GEOREP "-slaves/mbr", conf->logdir); + if ((len < 0) || (len >= PATH_MAX)) { + gf_smsg("glusterd", GF_LOG_ERROR, errno, GD_MSG_COPY_FAIL, NULL); + ret = -1; goto out; } - ret = mkdir_p(DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP "-slaves/mbr", 0777, - _gf_true); + + ret = mkdir_p(logdir, 0755, _gf_true); if (-1 == ret) { gf_msg("glusterd", GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED, "Unable to create " GEOREP " mountbroker slave log directory"); goto out; } - - ret = dict_get_str(THIS->options, GEOREP "-log-group", &greplg_s); - if (ret) - ret = 0; - else { - gr = getgrnam(greplg_s); - if (!gr) { - gf_msg("glusterd", GF_LOG_CRITICAL, 0, GD_MSG_LOGGROUP_INVALID, - "group " GEOREP "-log-group %s does not exist", greplg_s); - ret = -1; - goto out; - } - - ret = group_write_allow(DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP, - gr->gr_gid); - if (ret == 0) - ret = group_write_allow( - DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP "-slaves", gr->gr_gid); - if (ret == 0) - ret = group_write_allow(DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP - "-slaves/mbr", - gr->gr_gid); + if (gr && !gr_ret) { + gr_ret = group_write_allow(logdir, gr->gr_gid); } - + if (gr_ret) + ret = gr_ret; out: gf_msg_debug("glusterd", 0, "Returning %d", ret); return ret; @@ -814,18 +845,19 @@ configure_syncdaemon(glusterd_conf_t *conf) /* log-file */ runinit_gsyncd_setrx(&runner, conf); - runner_add_args(&runner, "log-file", - DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP - "/${mastervol}/${eSlave}.log", - ".", ".", NULL); + runner_add_arg(&runner, "log-file"); + runner_argprintf(&runner, "%s/" GEOREP "/${mastervol}/${eSlave}.log", + conf->logdir); + runner_add_args(&runner, ".", ".", NULL); RUN_GSYNCD_CMD; /* gluster-log-file */ runinit_gsyncd_setrx(&runner, conf); - runner_add_args(&runner, "gluster-log-file", - DEFAULT_LOG_FILE_DIRECTORY - "/" GEOREP "/${mastervol}/${eSlave}${local_id}.gluster.log", - ".", ".", NULL); + runner_add_arg(&runner, "gluster-log-file"); + runner_argprintf( + &runner, "%s/" GEOREP "/${mastervol}/${eSlave}${local_id}.gluster.log", + conf->logdir); + runner_add_args(&runner, ".", ".", NULL); RUN_GSYNCD_CMD; /* ignore-deletes */ @@ -867,33 +899,36 @@ configure_syncdaemon(glusterd_conf_t *conf) /* log-file */ runinit_gsyncd_setrx(&runner, conf); - runner_add_args( - &runner, "log-file", - DEFAULT_LOG_FILE_DIRECTORY - "/" GEOREP + runner_add_arg(&runner, "log-file"); + runner_argprintf( + &runner, + "%s/" GEOREP "-slaves/${session_owner}:${local_node}${local_id}.${slavevol}.log", - ".", NULL); + conf->logdir); + runner_add_args(&runner, ".", ".", NULL); RUN_GSYNCD_CMD; /* MountBroker log-file */ runinit_gsyncd_setrx(&runner, conf); - runner_add_args( - &runner, "log-file-mbr", - DEFAULT_LOG_FILE_DIRECTORY - "/" GEOREP + runner_add_arg(&runner, "log-file-mbr"); + runner_argprintf( + &runner, + "%s/" GEOREP "-slaves/mbr/${session_owner}:${local_node}${local_id}.${slavevol}.log", - ".", NULL); + conf->logdir); + runner_add_args(&runner, ".", ".", NULL); RUN_GSYNCD_CMD; /* gluster-log-file */ runinit_gsyncd_setrx(&runner, conf); - runner_add_args( - &runner, "gluster-log-file", - DEFAULT_LOG_FILE_DIRECTORY - "/" GEOREP + runner_add_arg(&runner, "gluster-log-file"); + runner_argprintf( + &runner, + "%s/" GEOREP "-slaves/" "${session_owner}:${local_node}${local_id}.${slavevol}.gluster.log", - ".", NULL); + conf->logdir); + runner_add_args(&runner, ".", ".", NULL); RUN_GSYNCD_CMD; out: @@ -1018,37 +1053,34 @@ _install_mount_spec(dict_t *opts, char *key, data_t *value, void *data) glusterd_conf_t *priv = THIS->private; char *label = NULL; gf_boolean_t georep = _gf_false; - gf_boolean_t ghadoop = _gf_false; char *pdesc = value->data; char *volname = NULL; int rv = 0; gf_mount_spec_t *mspec = NULL; char *user = NULL; - char *volfile_server = NULL; + xlator_t *this = THIS; + GF_ASSERT(this); label = strtail(key, "mountbroker."); - /* check for presence of geo-rep/hadoop label */ + /* check for presence of geo-rep label */ if (!label) { label = strtail(key, "mountbroker-" GEOREP "."); if (label) georep = _gf_true; - else { - label = strtail(key, "mountbroker-" GHADOOP "."); - if (label) - ghadoop = _gf_true; - } } if (!label) return 0; mspec = GF_CALLOC(1, sizeof(*mspec), gf_gld_mt_mount_spec); - if (!mspec) + if (!mspec) { + gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_NO_MEMORY, NULL); goto err; + } mspec->label = label; - if (georep || ghadoop) { + if (georep) { volname = gf_strdup(pdesc); if (!volname) goto err; @@ -1059,18 +1091,7 @@ _install_mount_spec(dict_t *opts, char *key, data_t *value, void *data) } else user = label; - if (georep) - rv = make_georep_mountspec(mspec, volname, user); - - if (ghadoop) { - volfile_server = strchr(user, ':'); - if (volfile_server) - *volfile_server++ = '\0'; - else - volfile_server = "localhost"; - - rv = make_ghadoop_mountspec(mspec, volname, user, volfile_server); - } + rv = make_georep_mountspec(mspec, volname, user, priv->logdir); GF_FREE(volname); if (rv != 0) @@ -1085,7 +1106,7 @@ err: gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_MOUNT_SPEC_INSTALL_FAIL, "adding %smount spec failed: label: %s desc: %s", - georep ? GEOREP " " : "", label, pdesc); + georep ? GEOREP " " : "", label, pdesc ? pdesc : ""); if (mspec) { if (mspec->patterns) { @@ -1111,11 +1132,17 @@ glusterd_init_uds_listener(xlator_t *this) GF_ASSERT(this); + options = dict_new(); + if (!options) { + gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_CREATE_FAIL, NULL); + goto out; + } + sock_data = dict_get(this->options, "glusterd-sockfile"); (void)snprintf(sockfile, sizeof(sockfile), "%s", sock_data ? sock_data->data : DEFAULT_GLUSTERD_SOCKFILE); - ret = rpcsvc_transport_unix_options_build(&options, sockfile); + ret = rpcsvc_transport_unix_options_build(options, sockfile); if (ret) goto out; @@ -1300,7 +1327,7 @@ glusterd_init_var_run_dirs(xlator_t *this, char *var_run_dir, if ((-1 == ret) && (ENOENT == errno)) { /* Create missing dirs */ - ret = mkdir_p(abs_path, 0777, _gf_true); + ret = mkdir_p(abs_path, 0755, _gf_true); if (-1 == ret) { gf_msg(this->name, GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED, @@ -1387,13 +1414,16 @@ init(xlator_t *this) char rundir[PATH_MAX] = { 0, }; + char logdir[VALID_GLUSTERD_PATHMAX] = { + 0, + }; char cmd_log_filename[PATH_MAX] = { 0, }; char *mountbroker_root = NULL; int i = 0; int total_transport = 0; - gf_boolean_t valgrind = _gf_false; + gf_valgrind_tool vgtool; char *valgrind_str = NULL; char *transport_type = NULL; char var_run_dir[PATH_MAX] = { @@ -1406,6 +1436,14 @@ init(xlator_t *this) int32_t len = 0; int op_version = 0; +#if defined(RUN_WITH_MEMCHECK) + vgtool = _gf_memcheck; +#elif defined(RUN_WITH_DRD) + vgtool = _gf_drd; +#else + vgtool = _gf_none; +#endif + #ifndef GF_DARWIN_HOST_OS { struct rlimit lim; @@ -1413,9 +1451,8 @@ init(xlator_t *this) lim.rlim_max = 65536; if (setrlimit(RLIMIT_NOFILE, &lim) == -1) { - gf_msg(this->name, GF_LOG_ERROR, errno, GD_MSG_SETXATTR_FAIL, - "Failed to set 'ulimit -n " - " 65536'"); + gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_SET_XATTR_FAIL, + "Failed to set 'ulimit -n 65536'", NULL); } else { gf_msg(this->name, GF_LOG_INFO, 0, GD_MSG_FILE_DESC_LIMIT_SET, "Maximum allowed open file descriptors " @@ -1435,6 +1472,26 @@ init(xlator_t *this) if (len < 0 || len >= PATH_MAX) exit(2); + dir_data = dict_get(this->options, "cluster-test-mode"); + if (!dir_data) { + /* Use default working dir */ + len = snprintf(logdir, VALID_GLUSTERD_PATHMAX, "%s", + DEFAULT_LOG_FILE_DIRECTORY); + } else { + len = snprintf(logdir, VALID_GLUSTERD_PATHMAX, "%s", dir_data->data); + gf_msg(this->name, GF_LOG_INFO, 0, GD_MSG_CLUSTER_RC_ENABLE, + "cluster-test-mode is enabled logdir is %s", dir_data->data); + } + if (len < 0 || len >= PATH_MAX) + exit(2); + + ret = mkdir_p(logdir, 0777, _gf_true); + if ((ret == -1) && (EEXIST != errno)) { + gf_msg(THIS->name, GF_LOG_ERROR, errno, GD_MSG_CREATE_DIR_FAILED, + "Unable to create log dir %s", logdir); + exit(1); + } + dir_data = dict_get(this->options, "working-directory"); if (!dir_data) { @@ -1462,7 +1519,7 @@ init(xlator_t *this) } if ((-1 == ret) && (ENOENT == errno)) { - ret = mkdir_p(workdir, 0777, _gf_true); + ret = mkdir_p(workdir, 0755, _gf_true); if (-1 == ret) { gf_msg(this->name, GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED, @@ -1509,7 +1566,7 @@ init(xlator_t *this) exit(1); } - ret = mkdir_p(GLUSTER_SHARED_STORAGE_BRICK_DIR, 0777, _gf_true); + ret = mkdir_p(GLUSTER_SHARED_STORAGE_BRICK_DIR, 0755, _gf_true); if (ret) { gf_msg(this->name, GF_LOG_CRITICAL, 0, GD_MSG_DIR_OP_FAILED, "Unable to create " @@ -1533,14 +1590,7 @@ init(xlator_t *this) 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); - } - +#ifdef BUILD_GNFS 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, @@ -1548,6 +1598,7 @@ init(xlator_t *this) "nfs running directory"); exit(1); } +#endif ret = glusterd_init_var_run_dirs(this, rundir, GLUSTERD_QUOTAD_RUN_DIR); if (ret) { @@ -1557,8 +1608,7 @@ init(xlator_t *this) exit(1); } - snprintf(cmd_log_filename, PATH_MAX, "%s/cmd_history.log", - DEFAULT_LOG_FILE_DIRECTORY); + snprintf(cmd_log_filename, PATH_MAX, "%s/cmd_history.log", logdir); ret = gf_cmd_log_init(cmd_log_filename); if (ret == -1) { @@ -1572,7 +1622,7 @@ init(xlator_t *this) exit(1); } - ret = sys_mkdir(storedir, 0777); + ret = sys_mkdir(storedir, 0755); if ((-1 == ret) && (errno != EEXIST)) { gf_msg(this->name, GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED, @@ -1588,7 +1638,7 @@ init(xlator_t *this) exit(1); } - ret = sys_mkdir(storedir, 0777); + ret = sys_mkdir(storedir, 0755); if ((-1 == ret) && (errno != EEXIST)) { gf_msg(this->name, GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED, @@ -1603,7 +1653,7 @@ init(xlator_t *this) exit(1); } - ret = sys_mkdir(storedir, 0777); + ret = sys_mkdir(storedir, 0755); if ((-1 == ret) && (errno != EEXIST)) { gf_msg(this->name, GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED, @@ -1618,7 +1668,7 @@ init(xlator_t *this) exit(1); } - ret = sys_mkdir(storedir, 0777); + ret = sys_mkdir(storedir, 0755); if ((-1 == ret) && (errno != EEXIST)) { gf_msg(this->name, GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED, @@ -1628,13 +1678,12 @@ init(xlator_t *this) exit(1); } - len = snprintf(storedir, sizeof(storedir), "%s/bricks", - DEFAULT_LOG_FILE_DIRECTORY); + len = snprintf(storedir, sizeof(storedir), "%s/bricks", logdir); if ((len < 0) || (len >= sizeof(storedir))) { exit(1); } - ret = sys_mkdir(storedir, 0777); + ret = sys_mkdir(storedir, 0755); if ((-1 == ret) && (errno != EEXIST)) { gf_msg(this->name, GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED, "Unable to create logs directory %s" @@ -1643,11 +1692,12 @@ init(xlator_t *this) exit(1); } +#ifdef BUILD_GNFS len = snprintf(storedir, sizeof(storedir), "%s/nfs", workdir); if ((len < 0) || (len >= sizeof(storedir))) { exit(1); } - ret = sys_mkdir(storedir, 0777); + ret = sys_mkdir(storedir, 0755); if ((-1 == ret) && (errno != EEXIST)) { gf_msg(this->name, GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED, "Unable to create nfs directory %s" @@ -1655,12 +1705,12 @@ init(xlator_t *this) storedir, errno); exit(1); } - +#endif len = snprintf(storedir, sizeof(storedir), "%s/bitd", workdir); if ((len < 0) || (len >= sizeof(storedir))) { exit(1); } - ret = sys_mkdir(storedir, 0777); + ret = sys_mkdir(storedir, 0755); if ((-1 == ret) && (errno != EEXIST)) { gf_msg(this->name, GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED, "Unable to create bitrot directory %s", storedir); @@ -1671,7 +1721,7 @@ init(xlator_t *this) if ((len < 0) || (len >= sizeof(storedir))) { exit(1); } - ret = sys_mkdir(storedir, 0777); + ret = sys_mkdir(storedir, 0755); if ((-1 == ret) && (errno != EEXIST)) { gf_msg(this->name, GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED, "Unable to create scrub directory %s", storedir); @@ -1682,7 +1732,7 @@ init(xlator_t *this) if ((len < 0) || (len >= sizeof(storedir))) { exit(1); } - ret = sys_mkdir(storedir, 0777); + ret = sys_mkdir(storedir, 0755); if ((-1 == ret) && (errno != EEXIST)) { gf_msg(this->name, GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED, "Unable to create glustershd directory %s" @@ -1695,7 +1745,7 @@ init(xlator_t *this) if ((len < 0) || (len >= sizeof(storedir))) { exit(1); } - ret = sys_mkdir(storedir, 0777); + ret = sys_mkdir(storedir, 0755); if ((-1 == ret) && (errno != EEXIST)) { gf_msg(this->name, GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED, "Unable to create quotad directory %s" @@ -1708,7 +1758,7 @@ init(xlator_t *this) if ((len < 0) || (len >= sizeof(storedir))) { exit(1); } - ret = sys_mkdir(storedir, 0777); + ret = sys_mkdir(storedir, 0755); if ((-1 == ret) && (errno != EEXIST)) { gf_msg(this->name, GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED, "Unable to create glustershd directory %s" @@ -1815,11 +1865,15 @@ init(xlator_t *this) CDS_INIT_LIST_HEAD(&conf->snapshots); CDS_INIT_LIST_HEAD(&conf->missed_snaps_list); CDS_INIT_LIST_HEAD(&conf->brick_procs); + CDS_INIT_LIST_HEAD(&conf->shd_procs); + pthread_mutex_init(&conf->attach_lock, NULL); + pthread_mutex_init(&conf->volume_lock, NULL); pthread_mutex_init(&conf->mutex, NULL); conf->rpc = rpc; conf->uds_rpc = uds_rpc; conf->gfs_mgmt = &gd_brick_prog; + conf->restart_shd = _gf_false; this->private = conf; /* conf->workdir and conf->rundir are smaller than PATH_MAX; gcc's * snprintf checking will throw an error here if sprintf is used. @@ -1840,7 +1894,13 @@ init(xlator_t *this) /* coverity[BUFFER_SIZE_WARNING] */ (void)strncpy(conf->rundir, rundir, sizeof(conf->rundir)); + /* coverity[BUFFER_SIZE_WARNING] */ + (void)strncpy(conf->logdir, logdir, sizeof(conf->logdir)); + synclock_init(&conf->big_lock, SYNC_LOCK_RECURSIVE); + synccond_init(&conf->cond_restart_bricks); + synccond_init(&conf->cond_restart_shd); + synccond_init(&conf->cond_blockers); pthread_mutex_init(&conf->xprt_lock, NULL); INIT_LIST_HEAD(&conf->xprt_list); pthread_mutex_init(&conf->import_volumes, NULL); @@ -1873,18 +1933,24 @@ init(xlator_t *this) } /* Set option to run bricks on valgrind if enabled in glusterd.vol */ - this->ctx->cmd_args.valgrind = valgrind; + this->ctx->cmd_args.vgtool = vgtool; ret = dict_get_str(this->options, "run-with-valgrind", &valgrind_str); if (ret < 0) { gf_msg_debug(this->name, 0, "cannot get run-with-valgrind value"); } if (valgrind_str) { - if (gf_string2boolean(valgrind_str, &valgrind)) { + gf_boolean_t vg = _gf_false; + + if (!strcmp(valgrind_str, "memcheck")) + this->ctx->cmd_args.vgtool = _gf_memcheck; + else if (!strcmp(valgrind_str, "drd")) + this->ctx->cmd_args.vgtool = _gf_drd; + else if (!gf_string2boolean(valgrind_str, &vg)) + this->ctx->cmd_args.vgtool = (vg ? _gf_memcheck : _gf_none); + else gf_msg(this->name, GF_LOG_WARNING, EINVAL, GD_MSG_INVALID_ENTRY, - "run-with-valgrind value not a boolean string"); - } else { - this->ctx->cmd_args.valgrind = valgrind; - } + "run-with-valgrind is neither boolean" + " nor one of 'memcheck' or 'drd'"); } /* Store ping-timeout in conf */ @@ -1895,8 +1961,9 @@ init(xlator_t *this) glusterd_mgmt_v3_lock_timer_init(); glusterd_txn_opinfo_dict_init(); - glusterd_shdsvc_build(&conf->shd_svc); +#ifdef BUILD_GNFS glusterd_nfssvc_build(&conf->nfs_svc); +#endif glusterd_quotadsvc_build(&conf->quotad_svc); glusterd_bitdsvc_build(&conf->bitd_svc); glusterd_scrubsvc_build(&conf->scrub_svc); @@ -2158,10 +2225,6 @@ struct volume_options options[] = { .type = GF_OPTION_TYPE_ANY, }, { - .key = {"mountbroker-" GHADOOP ".*"}, - .type = GF_OPTION_TYPE_ANY, - }, - { .key = {GEOREP "-log-group"}, .type = GF_OPTION_TYPE_ANY, }, |
