]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/common/common_init.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / common / common_init.cc
index d3114026c40a8fcedc5f90f82963fe68c490f4d0..092804931be0b8d40a7021687c17ed6a3ccf0b88 100644 (file)
  *
  */
 
+#include "include/compat.h"
+#include "common/common_init.h"
 #include "common/admin_socket.h"
 #include "common/ceph_argparse.h"
-#include "common/common_init.h"
+#include "common/ceph_context.h"
+#include "common/config.h"
+#include "common/dout.h"
+#include "common/strtol.h"
 #include "common/valgrind.h"
 #include "common/zipkin_trace.h"
 
@@ -23,6 +28,7 @@
 #define _STR(x) #x
 #define STRINGIFY(x) _STR(x)
 
+#ifndef WITH_SEASTAR
 CephContext *common_preinit(const CephInitParameters &iparams,
                            enum code_environment_t code_env, int flags)
 {
@@ -33,7 +39,7 @@ CephContext *common_preinit(const CephInitParameters &iparams,
   // Create a configuration object
   CephContext *cct = new CephContext(iparams.module_type, code_env, flags);
 
-  md_config_t *conf = cct->_conf;
+  auto& conf = cct->_conf;
   // add config observers here
 
   // Set up our entity name.
@@ -43,24 +49,27 @@ CephContext *common_preinit(const CephInitParameters &iparams,
   // for backward compatibility.  moving forward, we want all keyrings
   // in these locations.  the mon already forces $mon_data/keyring.
   if (conf->name.is_mds()) {
-    conf->set_val("keyring", "$mds_data/keyring", false);
+    conf.set_val_default("keyring", "$mds_data/keyring");
   } else if (conf->name.is_osd()) {
-    conf->set_val("keyring", "$osd_data/keyring", false);
+    conf.set_val_default("keyring", "$osd_data/keyring");
+  }
+
+  if ((flags & CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS)) {
+    // make this unique despite multiple instances by the same name.
+    conf.set_val_default("admin_socket",
+                         "$run_dir/$cluster-$name.$pid.$cctid.asok");
   }
 
   if (code_env == CODE_ENVIRONMENT_LIBRARY ||
       code_env == CODE_ENVIRONMENT_UTILITY_NODOUT) {
-    conf->set_val_or_die("log_to_stderr", "false");
-    conf->set_val_or_die("err_to_stderr", "false");
-    conf->set_val_or_die("log_flush_on_exit", "false");
-  }
-  if (code_env != CODE_ENVIRONMENT_DAEMON) {
-    // NOTE: disable ms subsystem gathering in clients by default
-    conf->set_val_or_die("debug_ms", "0/0");
+    conf.set_val_default("log_to_stderr", "false");
+    conf.set_val_default("err_to_stderr", "false");
+    conf.set_val_default("log_flush_on_exit", "false");
   }
 
   return cct;
 }
+#endif // #ifndef WITH_SEASTAR
 
 void complain_about_parse_errors(CephContext *cct,
                                 std::deque<std::string> *parse_errors)
@@ -83,13 +92,24 @@ void complain_about_parse_errors(CephContext *cct,
   }
 }
 
+#ifndef WITH_SEASTAR
+
 /* Please be sure that this can safely be called multiple times by the
  * same application. */
 void common_init_finish(CephContext *cct)
 {
+  // only do this once per cct
+  if (cct->_finished) {
+    return;
+  }
+  cct->_finished = true;
   cct->init_crypto();
   ZTracer::ztrace_init();
 
+  if (!cct->_log->is_started()) {
+    cct->_log->start();
+  }
+
   int flags = cct->get_init_flags();
   if (!(flags & CINIT_FLAG_NO_DAEMON_ACTIONS))
     cct->start_service_thread();
@@ -99,7 +119,7 @@ void common_init_finish(CephContext *cct)
     cct->get_admin_socket()->chown(cct->get_set_uid(), cct->get_set_gid());
   }
 
-  md_config_t *conf = cct->_conf;
+  const auto& conf = cct->_conf;
 
   if (!conf->admin_socket.empty() && !conf->admin_socket_mode.empty()) {
     int ret = 0;
@@ -118,3 +138,5 @@ void common_init_finish(CephContext *cct)
     }
   }
 }
+
+#endif // #ifndef WITH_SEASTAR