]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
global: add data_dir_option for all daemons
authorSage Weil <sage@redhat.com>
Tue, 26 Jan 2016 14:18:37 +0000 (09:18 -0500)
committerSage Weil <sage@redhat.com>
Thu, 4 Feb 2016 22:06:02 +0000 (17:06 -0500)
This let's us use a generic $data_dir substitution that will map
to rgw_data, osd_data, etc.

Signed-off-by: Sage Weil <sage@redhat.com>
12 files changed:
src/ceph_mds.cc
src/ceph_mon.cc
src/ceph_osd.cc
src/common/common_init.cc
src/common/common_init.h
src/common/config.cc
src/common/config.h
src/global/global_init.cc
src/global/global_init.h
src/rgw/librgw.cc
src/rgw/rgw_main.cc
src/rgw/rgw_object_expirer.cc

index 0da51bffa8e535a07c6b8e147c441f6ba417014e..08eee5e03135aa0ff51ba26120626df394fc57c8 100644 (file)
@@ -93,7 +93,8 @@ int main(int argc, const char **argv)
   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
index f15474c5e5571a7f542570d1d1a92d876d11c930..79d9e372751bdad4d4e587b80d9698061576ec8e 100644 (file)
@@ -258,7 +258,7 @@ int main(int argc, const char **argv)
   }
 
   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;
index 6c5b7f1835f1634f41ae346354e7813ae0ed5bff..c648e2747c4e43fd3316abc76c038c89e5231bc8 100644 (file)
@@ -118,7 +118,8 @@ int main(int argc, const char **argv)
   // 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
index 3303a7a1f104ae2150e96ecc347a1cd1c21bbbf2..b1f716557564d274a7a7735cc5777d19b05cdaaf 100644 (file)
@@ -34,7 +34,8 @@
 #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");
@@ -49,6 +50,9 @@ CephContext *common_preinit(const CephInitParameters &iparams,
   // 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:
index f48b349bf0011b4218614fce3b239090b6bbdcb7..6d11ef3177f1a3d6442a2f4066ff493def9bf30c 100644 (file)
@@ -57,7 +57,8 @@ enum common_init_flags_t {
  * 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,
index 37758d4d2047a324e06dba77667dc1694ad2168f..27858a258a37cc87faf50e844c7205abd528807d 100644 (file)
@@ -987,8 +987,10 @@ int md_config_t::set_val_raw(const char *val, const config_option *opt)
   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]));
 
@@ -1102,7 +1104,20 @@ bool md_config_t::expand_meta(std::string &origval,
          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;
       }
index 262dc7153bae6a315f4972910168ec84742fa75d..79c443786cf845bd11607cb500c4d238d7cc12c4 100644 (file)
@@ -205,6 +205,7 @@ public:
   ceph::log::SubsystemMap subsys;
 
   EntityName name;
+  string data_dir_option;  ///< data_dir config option, if any
 
   /// cluster name
   string cluster;
index f65d6acc03f3628f923dbbb18e677215f2a9c8e5..27bdbc7954d216f9546beb51b6a8b887a426dc04 100644 (file)
@@ -62,7 +62,8 @@ static const char* c_str_or_null(const std::string &str)
 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);
@@ -70,7 +71,7 @@ void global_pre_init(std::vector < const char * > *alt_def_args,
   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;
@@ -115,9 +116,12 @@ void global_pre_init(std::vector < const char * > *alt_def_args,
 
 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 };
index 5e934a77acd11f491673f65ebcb4a1c91c9ee151..0e27d43d55f1aacbc78b75525487a8bee0606863 100644 (file)
@@ -32,14 +32,18 @@ class CephContext;
  */
 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
index 556f57f3ba0474927bedc9d42c4ac0362a638f92..f9b39aeba59e217b7286c66e465c542eb7770e86 100644 (file)
@@ -33,7 +33,8 @@ int librgw_create(librgw_t *rgw, const char * const id)
   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
index fa6b3cc70cbd435dbe2f52708e8b8bf52fdbd564..09b2e9960fa09e1bd4cb7ae972ef844853c7c37b 100644 (file)
@@ -1079,7 +1079,7 @@ int main(int argc, const char **argv)
   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)) {
index ae7424d35a5befc36c927560ff291f75361848ee..a53e1a770dc3962c7968c3d25927e8c2a2903259 100644 (file)
@@ -61,7 +61,7 @@ int main(const int argc, const char **argv)
   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)) {