argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_MDS, CODE_ENVIRONMENT_DAEMON, 0);
+ global_init(NULL, args, CEPH_ENTITY_TYPE_MDS, CODE_ENVIRONMENT_DAEMON,
+ 0, "mds_data");
ceph_heap_profiler_init();
// mds specific args
}
global_init(&def_args, args,
- CEPH_ENTITY_TYPE_MON, CODE_ENVIRONMENT_DAEMON, flags);
+ CEPH_ENTITY_TYPE_MON, CODE_ENVIRONMENT_DAEMON, flags, "mon_data");
ceph_heap_profiler_init();
uuid_d fsid;
// option, therefore we will pass it as a default argument to global_init().
def_args.push_back("--leveldb-log=");
- global_init(&def_args, args, CEPH_ENTITY_TYPE_OSD, CODE_ENVIRONMENT_DAEMON, 0);
+ global_init(&def_args, args, CEPH_ENTITY_TYPE_OSD, CODE_ENVIRONMENT_DAEMON,
+ 0, "osd_data");
ceph_heap_profiler_init();
// osd specific args
#define STRINGIFY(x) _STR(x)
CephContext *common_preinit(const CephInitParameters &iparams,
- enum code_environment_t code_env, int flags)
+ enum code_environment_t code_env, int flags,
+ const char *data_dir_option)
{
// set code environment
ANNOTATE_BENIGN_RACE_SIZED(&g_code_env, sizeof(g_code_env), "g_code_env");
// Set up our entity name.
conf->name = iparams.name;
+ if (data_dir_option)
+ conf->data_dir_option = data_dir_option;
+
// Set some defaults based on code type
switch (code_env) {
case CODE_ENVIRONMENT_DAEMON:
* Your library may also supply functions to read a configuration file.
*/
CephContext *common_preinit(const CephInitParameters &iparams,
- enum code_environment_t code_env, int flags);
+ enum code_environment_t code_env, int flags,
+ const char *data_dir_option = 0);
/* Print out some parse errors. */
void complain_about_parse_errors(CephContext *cct,
return -ENOSYS;
}
-static const char *CONF_METAVARIABLES[] =
- { "cluster", "type", "name", "host", "num", "id", "pid", "cctid" };
+static const char *CONF_METAVARIABLES[] = {
+ "data_dir", // put this first: it may contain some of the others
+ "cluster", "type", "name", "host", "num", "id", "pid", "cctid"
+};
static const int NUM_CONF_METAVARIABLES =
(sizeof(CONF_METAVARIABLES) / sizeof(CONF_METAVARIABLES[0]));
out += stringify(getpid());
else if (var == "cctid")
out += stringify((unsigned long long)this);
- else
+ else if (var == "data_dir") {
+ if (data_dir_option.length()) {
+ char *vv = NULL;
+ _get_val(data_dir_option.c_str(), &vv, -1);
+ string tmp = vv;
+ free(vv);
+ expand_meta(tmp, NULL, stack, oss);
+ out += tmp;
+ } else {
+ // this isn't really right, but it'll result in a mangled
+ // non-existent path that will fail any search list
+ out += "$data_dir";
+ }
+ } else
assert(0); // unreachable
expanded = true;
}
ceph::log::SubsystemMap subsys;
EntityName name;
+ string data_dir_option; ///< data_dir config option, if any
/// cluster name
string cluster;
void global_pre_init(std::vector < const char * > *alt_def_args,
std::vector < const char* >& args,
uint32_t module_type, code_environment_t code_env,
- int flags)
+ int flags,
+ const char *data_dir_option)
{
// You can only call global_init once.
assert(!g_ceph_context);
std::string cluster = "ceph";
CephInitParameters iparams = ceph_argparse_early_args(args, module_type, flags,
&cluster, &conf_file_list);
- CephContext *cct = common_preinit(iparams, code_env, flags);
+ CephContext *cct = common_preinit(iparams, code_env, flags, data_dir_option);
cct->_conf->cluster = cluster;
global_init_set_globals(cct);
md_config_t *conf = cct->_conf;
void global_init(std::vector < const char * > *alt_def_args,
std::vector < const char* >& args,
- uint32_t module_type, code_environment_t code_env, int flags)
+ uint32_t module_type, code_environment_t code_env,
+ int flags,
+ const char *data_dir_option)
{
- global_pre_init(alt_def_args, args, module_type, code_env, flags);
+ global_pre_init(alt_def_args, args, module_type, code_env, flags,
+ data_dir_option);
// signal stuff
int siglist[] = { SIGPIPE, 0 };
*/
void global_init(std::vector < const char * > *alt_def_args,
std::vector < const char* >& args,
- uint32_t module_type, code_environment_t code_env, int flags);
+ uint32_t module_type,
+ code_environment_t code_env,
+ int flags,
+ const char *data_dir_option = 0);
// just the first half; enough to get config parsed but doesn't start up the
// cct or log.
void global_pre_init(std::vector < const char * > *alt_def_args,
std::vector < const char* >& args,
uint32_t module_type, code_environment_t code_env,
- int flags);
+ int flags,
+ const char *data_dir_option = 0);
/*
* perform all of the steps that global_init_daemonize performs just prior
if (id) {
iparams.name.set(CEPH_ENTITY_TYPE_CLIENT, id);
}
- CephContext *cct = common_preinit(iparams, CODE_ENVIRONMENT_LIBRARY, 0);
+ CephContext *cct = common_preinit(iparams, CODE_ENVIRONMENT_LIBRARY, 0,
+ "rgw_data");
cct->_conf->set_val("log_to_stderr", "false"); // quiet by default
cct->_conf->set_val("err_to_stderr", "true"); // quiet by default
cct->_conf->parse_env(); // environment variables override
argv_to_vec(argc, argv, args);
env_to_vec(args);
global_init(&def_args, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_DAEMON,
- CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
+ CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS, "rgw_data");
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ++i) {
if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
env_to_vec(args);
global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_DAEMON,
- CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
+ CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS, "rgw_data");
for (std::vector<const char *>::iterator i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {