]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Add CephContext
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 23 May 2011 17:11:15 +0000 (10:11 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Tue, 24 May 2011 00:28:27 +0000 (17:28 -0700)
A CephContext represents the context held by a single library user.
There can be multiple CephContexts in the same process.

For daemons and utility programs, there will be only one CephContext.
The CephContext contains the configuration, the dout object, and
anything else that you might want to pass to libcommon with every
function call.

Move some non-config things out of md_config_t and into CephContext.

Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
43 files changed:
src/Makefile.am
src/cauthtool.cc
src/cconf.cc
src/cfuse.cc
src/cmds.cc
src/cmon.cc
src/common/ceph_context.cc [new file with mode: 0644]
src/common/ceph_context.h [new file with mode: 0644]
src/common/common_init.cc
src/common/common_init.h
src/common/config.cc
src/common/config.h
src/common/debug.cc
src/common/debug.h
src/common/signal.cc
src/cosd.cc
src/csyn.cc
src/dumpjournal.cc
src/dupstore.cc
src/include/ceph/libceph.h
src/include/rados/librgw.h
src/libceph.cc
src/librados-config.cc
src/librados.cc
src/mds/MDS.cc
src/mon/Monitor.cc
src/monmaptool.cc
src/osd/OSD.cc
src/osdmaptool.cc
src/rados.cc
src/rbd.cc
src/rgw/librgw.cc
src/rgw/rgw_admin.cc
src/rgw/rgw_main.cc
src/streamtest.cc
src/test/TestDoutStreambuf.cc
src/test/TestSignalHandlers.cc
src/test/TestTimers.cc
src/test/test_mutate.cc
src/test_trans.cc
src/testmsgr.cc
src/tools/ceph.cc
src/tools/gceph.cc

index de22d44566987bf09868af9dce5af31df008b864..376eebd8e8ec15c1f44d487868f0e0c763ac9fbe 100644 (file)
@@ -638,6 +638,7 @@ libcommon_files = \
        mds/MDSMap.cc \
        common/common_init.cc \
        common/ceph_argparse.cc \
+       common/ceph_context.cc \
        common/buffer.cc \
        common/code_environment.cc \
        common/signal.cc \
@@ -785,6 +786,7 @@ noinst_HEADERS = \
        common/LogEntry.h\
        common/WorkQueue.h\
        common/ceph_argparse.h\
+       common/ceph_context.h\
        common/debug.h\
        common/version.h\
        common/hex.h\
index 33718a280eaa816c4dced896c89482a210b89c28..b9bdec1ec0911cb5c8157c3de93488f4e55b4cb0 100644 (file)
@@ -55,7 +55,7 @@ int main(int argc, const char **argv)
 
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
              CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
   EntityName ename(g_conf.name);
 
   const char *me = argv[0];
index 424ea14602855f97d7194a22f3c19cdc56af4c95..806ffcce44aff27394debd981dadf26dfdcf87af 100644 (file)
@@ -122,7 +122,7 @@ int main(int argc, const char **argv)
   argv_to_vec(argc, argv, args);
   env_to_vec(args);
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   std::string val;
   for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
index 30e7c3b19ebd40eda2d00635f574230d737e223e..5d063c652bb6f6261ece7c523df06c10235816f5 100644 (file)
@@ -111,7 +111,7 @@ int main(int argc, const char **argv, const char *envp[]) {
     childpid = fork();
   }
 
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   if (childpid == 0) {
     //cout << "child, mounting" << std::endl;
index e683753d9fd330572353863f399e02bf1ca56713..76e869dc181088edb2897bd79073b6157ece1b95 100644 (file)
@@ -162,10 +162,9 @@ int main(int argc, const char **argv)
     messenger->set_policy(entity_name_t::TYPE_CLIENT,
                           SimpleMessenger::Policy::stateful_server(supported, 0));
 
-    if (shadow == MDSMap::STATE_ONESHOT_REPLAY)
-      g_conf.daemonize = false;
-    common_init_daemonize(&g_conf, 0);
-    common_init_finish(&g_conf);
+    if (shadow != MDSMap::STATE_ONESHOT_REPLAY)
+      common_init_daemonize(&g_ceph_context, 0);
+    common_init_finish(&g_ceph_context);
     messenger->start();
 
     // start mds
index 74608c433268c12d85af6df3fd1ffe59978e6596..4b616da750d3fc69d871d55b20e27175b2f8c951 100644 (file)
@@ -82,8 +82,7 @@ int main(int argc, const char **argv)
 
   // -- mkfs --
   if (mkfs) {
-    g_conf.daemonize = false;
-    common_init_finish(&g_conf);
+    common_init_finish(&g_ceph_context);
     if (g_conf.monmap.empty() || !osdmapfn)
       usage();
 
@@ -260,8 +259,8 @@ int main(int argc, const char **argv)
   messenger->set_default_send_priority(CEPH_MSG_PRIO_HIGH);
   Monitor *mon = new Monitor(g_conf.name.get_id(), &store, messenger, &monmap);
 
-  common_init_daemonize(&g_conf, 0);
-  common_init_finish(&g_conf);
+  common_init_daemonize(&g_ceph_context, 0);
+  common_init_finish(&g_ceph_context);
   messenger->start();
 
   uint64_t supported =
diff --git a/src/common/ceph_context.cc b/src/common/ceph_context.cc
new file mode 100644 (file)
index 0000000..80aec2c
--- /dev/null
@@ -0,0 +1,58 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2011 New Dream Network
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#include "common/DoutStreambuf.h"
+#include "common/ProfLogger.h"
+#include "common/ceph_context.h"
+#include "common/config.h"
+
+#include <iostream>
+
+// FIXME
+// These variables are here temporarily to make the transition easier.
+CephContext g_ceph_context __attribute__((init_priority(103)));
+md_config_t &g_conf(*g_ceph_context._conf);
+std::ostream *_dout(&g_ceph_context._dout);
+DoutStreambuf <char, std::basic_string<char>::traits_type> *_doss(g_ceph_context._doss);
+
+/*
+ * The dout lock protects calls to dout()
+ * TODO: needs to become part of CephContext
+ */
+pthread_mutex_t _dout_lock = PTHREAD_MUTEX_INITIALIZER;
+
+CephContext::
+CephContext()
+  : _doss(new DoutStreambuf <char, std::basic_string<char>::traits_type>()),
+    _dout(_doss),
+    _prof_logger_conf_obs(new ProfLoggerConfObs())
+{
+  _conf = new md_config_t();
+  _conf->add_observer(_doss);
+  _conf->add_observer(_prof_logger_conf_obs);
+}
+
+CephContext::
+~CephContext()
+{
+  _conf->remove_observer(_prof_logger_conf_obs);
+  _conf->remove_observer(_doss);
+
+  delete _doss;
+  _doss = NULL;
+  delete _prof_logger_conf_obs;
+  _prof_logger_conf_obs = NULL;
+
+  delete _conf;
+}
diff --git a/src/common/ceph_context.h b/src/common/ceph_context.h
new file mode 100644 (file)
index 0000000..35aa7e5
--- /dev/null
@@ -0,0 +1,53 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2011 New Dream Network
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#ifndef CEPH_CEPHCONTEXT_H
+#define CEPH_CEPHCONTEXT_H
+
+#include <iostream>
+
+/* Forward declarations */ 
+template <typename T, typename U>
+class DoutStreambuf;
+
+class md_config_t;
+class md_config_obs_t;
+
+/* A CephContext represents the context held by a single library user.
+ * There can be multiple CephContexts in the same process.
+ *
+ * For daemons and utility programs, there will be only one CephContext.  The
+ * CephContext contains the configuration, the dout object, and anything else
+ * that you might want to pass to libcommon with every function call.
+ */
+class CephContext {
+public:
+  CephContext();
+  ~CephContext();
+  md_config_t *_conf;
+  DoutStreambuf <char, std::basic_string<char>::traits_type> *_doss;
+  std::ostream _dout;
+
+private:
+  md_config_obs_t *_prof_logger_conf_obs;
+};
+
+/* Globals (FIXME: remove) */ 
+extern CephContext g_ceph_context;
+extern md_config_t &g_conf;
+extern std::ostream *_dout;
+extern DoutStreambuf <char, std::basic_string<char>::traits_type> *_doss;
+
+
+#endif
index 52b2efeb718c6de7f9b9487014613e3fdda5004b..e335e1efd3a754f911fc613a366b4aa3ff69460b 100644 (file)
 #define _STR(x) #x
 #define STRINGIFY(x) _STR(x)
 
-int keyring_init(md_config_t *conf)
+int keyring_init(CephContext *cct)
 {
+  md_config_t *conf = cct->_conf;
+
   if (!is_supported_auth(CEPH_AUTH_CEPHX))
     return 0;
 
@@ -88,7 +90,7 @@ int keyring_init(md_config_t *conf)
   return ret;
 }
 
-md_config_t *common_preinit(const CephInitParameters &iparams,
+CephContext *common_preinit(const CephInitParameters &iparams,
                          enum code_environment_t code_env, int flags)
 {
   // set code environment
@@ -96,7 +98,8 @@ md_config_t *common_preinit(const CephInitParameters &iparams,
 
   // Create a configuration object
   // TODO: de-globalize
-  md_config_t *conf = &g_conf; //new md_config_t();
+  CephContext *cct = &g_ceph_context; //new CephContext();
+  md_config_t *conf = cct->_conf;
   // add config observers here
 
   // Set up our entity name.
@@ -115,7 +118,7 @@ md_config_t *common_preinit(const CephInitParameters &iparams,
       conf->set_val_or_die("daemonize", "false");
       break;
   }
-  return conf;
+  return cct;
 }
 
 void complain_about_parse_errors(std::deque<std::string> *parse_errors)
@@ -143,7 +146,8 @@ void common_init(std::vector < const char* >& args,
 {
   CephInitParameters iparams =
     ceph_argparse_early_args(args, module_type, flags);
-  md_config_t *conf = common_preinit(iparams, code_env, flags);
+  CephContext *cct = common_preinit(iparams, code_env, flags);
+  md_config_t *conf = cct->_conf;
 
   std::deque<std::string> parse_errors;
   int ret = conf->parse_config_files(iparams.get_conf_files(), &parse_errors);
@@ -202,7 +206,7 @@ static void pidfile_remove_void(void)
  * behavior that the file descriptor that gets assigned is the lowest
  * available one.
  */
-int common_init_shutdown_stderr(const md_config_t *conf)
+int common_init_shutdown_stderr(void)
 {
   TEMP_FAILURE_RETRY(close(STDERR_FILENO));
   if (open("/dev/null", O_RDONLY) < 0) {
@@ -211,14 +215,15 @@ int common_init_shutdown_stderr(const md_config_t *conf)
         << err << dendl;
     return 1;
   }
-  conf->_doss->handle_stderr_shutdown();
+  g_ceph_context._doss->handle_stderr_shutdown();
   return 0;
 }
 
-void common_init_daemonize(const md_config_t *conf, int flags)
+void common_init_daemonize(const CephContext *cct, int flags)
 {
   if (g_code_env != CODE_ENVIRONMENT_DAEMON)
     return;
+  const md_config_t *conf = cct->_conf;
   if (!conf->daemonize)
     return;
   int num_threads = Thread::get_num_threads();
@@ -272,7 +277,7 @@ void common_init_daemonize(const md_config_t *conf, int flags)
     exit(1);
   }
   if (!(flags & CINIT_FLAG_NO_DEFAULT_CONFIG_FILE)) {
-    ret = common_init_shutdown_stderr(conf);
+    ret = common_init_shutdown_stderr();
     if (ret) {
       derr << "common_init_daemonize: common_init_shutdown_stderr failed with "
           << "error code " << ret << dendl;
@@ -280,7 +285,7 @@ void common_init_daemonize(const md_config_t *conf, int flags)
     }
   }
   pidfile_write(&g_conf);
-  ret = conf->_doss->handle_pid_change(&g_conf);
+  ret = g_ceph_context._doss->handle_pid_change(&g_conf);
   if (ret) {
     derr << "common_init_daemonize: _doss->handle_pid_change failed with "
         << "error code " << ret << dendl;
@@ -289,8 +294,8 @@ void common_init_daemonize(const md_config_t *conf, int flags)
   dout(1) << "finished common_init_daemonize" << dendl;
 }
 
-void common_init_finish(const md_config_t *conf)
+void common_init_finish(CephContext *cct)
 {
   ceph::crypto::init();
-  keyring_init(&g_conf);
+  keyring_init(cct);
 }
index 07e24e96dbbe09a553e0df064eef0cf8a4ab1270..5be95b4ec22d099aa0d48cfa64aae0c11cbae65b 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "common/code_environment.h"
 
-class md_config_t;
+class CephContext;
 class CephInitParameters;
 
 enum common_init_flags_t {
@@ -22,15 +22,16 @@ enum common_init_flags_t {
   CINIT_FLAG_NO_CLOSE_STDERR = 0x4,
 };
 
-int keyring_init(md_config_t *conf);
-md_config_t *common_preinit(const CephInitParameters &iparams,
+int keyring_init(CephContext *cct);
+CephContext *common_preinit(const CephInitParameters &iparams,
                            enum code_environment_t code_env, int flags);
 void complain_about_parse_errors(std::deque<std::string> *parse_errors);
 void common_init(std::vector < const char* >& args,
               uint32_t module_type, code_environment_t code_env, int flags);
 void output_ceph_version();
-int common_init_shutdown_stderr(const md_config_t *conf);
-void common_init_daemonize(const md_config_t *conf, int flags);
-void common_init_finish(const md_config_t *conf);
+int common_init_shutdown_stderr();
+void common_init_daemonize(const CephContext *cct, int flags);
+int common_init_shutdown_stderr(void);
+void common_init_finish(CephContext *cct);
 
 #endif
index ef3a44425a6b97a11c28938c64c1c2b37dbf6303..5d36ab55579e54f7c3eea71f333d2d03a1de0990 100644 (file)
@@ -58,9 +58,6 @@ using std::string;
 
 const char *CEPH_CONF_FILE_DEFAULT = "/etc/ceph/ceph.conf, ~/.ceph/config, ceph.conf";
 
-/* The Ceph configuration. */
-md_config_t g_conf __attribute__((init_priority(103)));
-
 // file layouts
 struct ceph_file_layout g_default_file_layout = {
  fl_stripe_unit: init_le32(1<<22),
@@ -444,9 +441,6 @@ bool ceph_resolve_file_search(const std::string& filename_list,
 
 md_config_t::
 md_config_t()
-  : _doss(new DoutStreambuf <char, std::basic_string<char>::traits_type>()),
-    _dout(_doss),
-    _prof_logger_conf_obs(new ProfLoggerConfObs())
 {
   //
   // Note: because our md_config_t structure is a global, the memory used to
@@ -461,20 +455,11 @@ md_config_t()
     set_val_from_default(opt);
   }
 
-  add_observer(_doss);
-  add_observer(_prof_logger_conf_obs);
 }
 
 md_config_t::
 ~md_config_t()
 {
-  remove_observer(_prof_logger_conf_obs);
-  remove_observer(_doss);
-
-  delete _doss;
-  _doss = NULL;
-  delete _prof_logger_conf_obs;
-  _prof_logger_conf_obs = NULL;
 }
 
 void md_config_t::
index f25789f2218dad865816cb39b7309a240fdfbe03..56fc2cd5bba3f82d3c45806341fd01fefe2ae7a6 100644 (file)
@@ -40,10 +40,7 @@ extern const char *CEPH_CONF_FILE_DEFAULT;
 #define LOG_TO_STDERR_SOME 1
 #define LOG_TO_STDERR_ALL 2
 
-template <typename T, typename U>
-class DoutStreambuf;
-
-struct md_config_t {
+class md_config_t {
 public:
   /* Maps configuration options to the observer listening for them. */
   typedef std::multimap <std::string, md_config_obs_t*> obs_map_t;
@@ -505,14 +502,8 @@ public:
   int   bdev_fake_mb;
   int   bdev_fake_max_mb;
   int   rgw_log;
-
-  DoutStreambuf <char, std::basic_string<char>::traits_type> *_doss;
-  std::ostream _dout;
-  md_config_obs_t *_prof_logger_conf_obs;
 };
 
-extern md_config_t g_conf;
-
 typedef enum {
        OPT_INT, OPT_LONGLONG, OPT_STR, OPT_DOUBLE, OPT_FLOAT, OPT_BOOL,
        OPT_ADDR, OPT_U32, OPT_U64
index b66c80fc9faedb617ff9d424e872e08c506c3ef2..1a273dcd734f110088428b3ba6138bb4db21cedd 100644 (file)
@@ -7,16 +7,6 @@
 #include <iostream>
 #include <sstream>
 
-// Originally, dout was global. Now, there is one for each md_config_t structure.
-// These variables are here temporarily to make the transition easier.
-std::ostream *_dout = &g_conf._dout;
-DoutStreambuf <char> *_doss = g_conf._doss;
-
-/*
- * The dout lock protects calls to dout()
- */
-pthread_mutex_t _dout_lock = PTHREAD_MUTEX_INITIALIZER;
-
 void output_ceph_version()
 {
   char buf[1024];
index 255f63cc62dc3dc98b76ee1d14595d833ec516ff..d9c241eff4c73703443a2a9fd52084dc3fb14c9b 100644 (file)
@@ -16,6 +16,7 @@
 #ifndef CEPH_DEBUG_H
 #define CEPH_DEBUG_H
 
+#include "common/ceph_context.h"
 #include "common/likely.h"
 #include "common/config.h"                 // need for g_conf
 #include "include/assert.h"
@@ -25,9 +26,6 @@
 #include <streambuf>
 
 
-extern std::ostream *_dout;
-extern DoutStreambuf <char, std::basic_string<char>::traits_type> *_doss;
-class md_config_t;
 extern pthread_mutex_t _dout_lock;
 
 extern void dout_emergency(const char * const str);
index e8d8323674dcd72b13e0b40e738145caea58860c..07e3ade70b91f48a2477f1b78418f3a10002d9bc 100644 (file)
@@ -52,7 +52,7 @@ void install_sighandler(int signum, signal_handler_t handler, int flags)
 
 void sighup_handler(int signum)
 {
-  g_conf._doss->request_log_reopen();
+  g_ceph_context._doss->request_log_reopen();
 }
 
 static void reraise_fatal(int signum)
index 3183d6f72d7470b33a5107c0371786e063a01611..f8fb37d56be135a406d8233e3484fb6f2e314ab5 100644 (file)
@@ -84,7 +84,7 @@ int main(int argc, const char **argv)
   }
 
   if (dump_pg_log) {
-    common_init_finish(&g_conf);
+    common_init_finish(&g_ceph_context);
     bufferlist bl;
     int r = bl.read_file(dump_pg_log);
     if (r >= 0) {
@@ -122,7 +122,7 @@ int main(int argc, const char **argv)
   }
 
   if (mkfs) {
-    common_init_finish(&g_conf);
+    common_init_finish(&g_ceph_context);
     RotatingKeyRing rkeys(CEPH_ENTITY_TYPE_OSD, &g_keyring);
     MonClient mc(&rkeys);
     if (mc.build_initial_monmap() < 0)
@@ -142,7 +142,7 @@ int main(int argc, const char **argv)
     *_dout << " for osd" << whoami << " fsid " << mc.monmap.fsid << dendl;
   }
   if (mkkey) {
-    common_init_finish(&g_conf);
+    common_init_finish(&g_ceph_context);
     EntityName ename(g_conf.name);
     EntityAuth eauth;
     eauth.key.create(CEPH_CRYPTO_AES);
@@ -159,7 +159,7 @@ int main(int argc, const char **argv)
   if (mkfs || mkkey)
     exit(0);
   if (mkjournal) {
-    common_init_finish(&g_conf);
+    common_init_finish(&g_ceph_context);
     int err = OSD::mkjournal(g_conf.osd_data, g_conf.osd_journal);
     if (err < 0) {
       derr << TEXT_RED << " ** ERROR: error creating fresh journal " << g_conf.osd_journal
@@ -172,7 +172,7 @@ int main(int argc, const char **argv)
     exit(0);
   }
   if (flushjournal) {
-    common_init_finish(&g_conf);
+    common_init_finish(&g_ceph_context);
     int err = OSD::flushjournal(g_conf.osd_data, g_conf.osd_journal);
     if (err < 0) {
       derr << TEXT_RED << " ** ERROR: error flushing journal " << g_conf.osd_journal
@@ -272,8 +272,8 @@ int main(int argc, const char **argv)
 
   // Set up crypto, daemonize, etc.
   // Leave stderr open in case we need to report errors.
-  common_init_daemonize(&g_conf, CINIT_FLAG_NO_CLOSE_STDERR);
-  common_init_finish(&g_conf);
+  common_init_daemonize(&g_ceph_context, CINIT_FLAG_NO_CLOSE_STDERR);
+  common_init_finish(&g_ceph_context);
   RotatingKeyRing rkeys(CEPH_ENTITY_TYPE_OSD, &g_keyring);
   MonClient mc(&rkeys);
   if (mc.build_initial_monmap() < 0)
@@ -289,7 +289,7 @@ int main(int argc, const char **argv)
   }
 
   // Now close the standard file descriptors
-  common_init_shutdown_stderr(&g_conf);
+  common_init_shutdown_stderr();
 
   client_messenger->start();
   messenger_hb->start();
index 8940b46d88adccb441fcae47c2caf12de3027389..1b7c29bf0c6e9cd5e94ac35f741d0ab202a2476f 100644 (file)
@@ -47,7 +47,7 @@ int main(int argc, const char **argv, char *envp[])
   argv_to_vec(argc, argv, args);
 
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   parse_syn_options(args);   // for SyntheticClient
 
index b01389615cde3853025c20f35f5417fb5099e883..9bc3b5ba92a64e8892d2f8e1c97704580421b14b 100644 (file)
@@ -82,7 +82,7 @@ int main(int argc, const char **argv, const char *envp[])
   env_to_vec(args);
 
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   vec_to_argv(args, argc, argv);
 
index 72efc895bd4084e5eaa6ea7dee0c9089e64ee7a5..3116932cf9e1468090210fae16364c455a925807 100644 (file)
@@ -88,7 +88,7 @@ int main(int argc, const char **argv)
   env_to_vec(args);
 
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   // args
   if (args.size() != 4) 
index bf28402fee483bc7ff290e0118e0afea283e5788..c90465dd25431e36ad6240c74f3d76547212ae80 100644 (file)
@@ -29,6 +29,7 @@ extern "C" {
 
 struct ceph_mount_info;
 struct ceph_dir_result;
+struct CephContext;
 
 const char *ceph_version(int *major, int *minor, int *patch);
 
@@ -36,7 +37,7 @@ const char *ceph_version(int *major, int *minor, int *patch);
 int ceph_create(struct ceph_mount_info **cmount, const char * const id);
 
 /* initialization with an existing configuration */
-int ceph_create_with_config(struct ceph_mount_info **cmount, struct md_config_t *conf);
+int ceph_create_with_context(struct ceph_mount_info **cmount, struct CephContext *conf);
 
 /* Activate the mount */
 int ceph_mount(struct ceph_mount_info *cmount, const char *root);
index a14cabf5f518b60b5afdd1a5fea7e543d6aec572..cc2d6bdfd32c5ba17f6fe857dae0e4ea35ae58d1 100644 (file)
@@ -19,8 +19,8 @@
 extern "C" {
 #endif
 
-struct md_config_t;
-typedef struct md_config_t* librgw_t;
+class CephContext;
+typedef CephContext* librgw_t;
 int librgw_create(librgw_t *rgw, const char * const id);
 int librgw_acl_bin2xml(librgw_t rgw, const char *bin, int bin_len, char **xml);
 void librgw_free_xml(librgw_t rgw, char *xml);
index 54993ac124df4872b5aef0dd479e3c9d35599893..c184158fdacccf93973771643400754d420d6a5d 100644 (file)
@@ -35,13 +35,13 @@ static int nonce_seed = 0;
 class ceph_mount_info
 {
 public:
-  ceph_mount_info(uint64_t msgr_nonce_, md_config_t *conf)
+  ceph_mount_info(uint64_t msgr_nonce_, CephContext *cct_)
     : msgr_nonce(msgr_nonce_),
       mounted(false),
       client(NULL),
       monclient(NULL),
       messenger(NULL),
-      conf(conf)
+      cct(cct_)
   {
   }
 
@@ -140,12 +140,12 @@ public:
     std::list<std::string> conf_files;
     get_str_list(path, conf_files);
     std::deque<std::string> parse_errors;
-    int ret = conf->parse_config_files(conf_files, &parse_errors);
+    int ret = cct->_conf->parse_config_files(conf_files, &parse_errors);
     if (ret)
       return ret;
-    conf->parse_env(); // environment variables override
+    cct->_conf->parse_env(); // environment variables override
 
-    conf->apply_changes();
+    cct->_conf->apply_changes();
     complain_about_parse_errors(&parse_errors);
     return 0;
   }
@@ -154,23 +154,23 @@ public:
   {
     vector<const char*> args;
     argv_to_vec(argc, argv, args);
-    conf->parse_argv(args);
-    conf->apply_changes();
+    cct->_conf->parse_argv(args);
+    cct->_conf->apply_changes();
   }
 
   int conf_set(const char *option, const char *value)
   {
-    int ret = conf->set_val(option, value);
+    int ret = cct->_conf->set_val(option, value);
     if (ret)
       return ret;
-    conf->apply_changes();
+    cct->_conf->apply_changes();
     return 0;
   }
 
   int conf_get(const char *option, char *buf, size_t len)
   {
     char *tmp = buf;
-    return conf->get_val(option, &tmp, len);
+    return cct->_conf->get_val(option, &tmp, len);
   }
 
   Client *get_client()
@@ -190,7 +190,7 @@ private:
   Client *client;
   MonClient *monclient;
   SimpleMessenger *messenger;
-  md_config_t *conf;
+  CephContext *cct;
   std::string cwd;
 };
 
@@ -209,12 +209,12 @@ extern "C" const char *ceph_version(int *pmajor, int *pminor, int *ppatch)
   return VERSION;
 }
 
-static int ceph_create_with_config_impl(struct ceph_mount_info **cmount, md_config_t *conf)
+static int ceph_create_with_context_impl(struct ceph_mount_info **cmount, CephContext *cct)
 {
   // should hold libceph_init_mutex here
   libceph_initialized = true;
   uint64_t nonce = (uint64_t)++nonce_seed * 1000000ull + (uint64_t)getpid();
-  *cmount = new struct ceph_mount_info(nonce, conf);
+  *cmount = new struct ceph_mount_info(nonce, cct);
   return 0;
 }
 
@@ -222,7 +222,7 @@ extern "C" int ceph_create(struct ceph_mount_info **cmount, const char * const i
 {
   int ret;
   libceph_init_mutex.Lock();
-  md_config_t *conf = &g_conf;
+  CephContext *cct = &g_ceph_context;
   if (!libceph_initialized) {
     CephInitParameters iparams(CEPH_ENTITY_TYPE_CLIENT, CEPH_CONF_FILE_DEFAULT);
     iparams.conf_file = "";
@@ -230,20 +230,20 @@ extern "C" int ceph_create(struct ceph_mount_info **cmount, const char * const i
       iparams.name.set(CEPH_ENTITY_TYPE_CLIENT, id);
     }
 
-    conf = common_preinit(iparams, CODE_ENVIRONMENT_LIBRARY, 0);
-    conf->parse_env(); // environment variables override
-    conf->apply_changes();
+    cct = common_preinit(iparams, CODE_ENVIRONMENT_LIBRARY, 0);
+    cct->_conf->parse_env(); // environment variables coverride
+    cct->_conf->apply_changes();
   }
-  ret = ceph_create_with_config_impl(cmount, conf);
+  ret = ceph_create_with_context_impl(cmount, cct);
   libceph_init_mutex.Unlock();
   return ret;
 }
 
-extern "C" int ceph_create_with_config(struct ceph_mount_info **cmount, md_config_t *conf)
+extern "C" int ceph_create_with_context(struct ceph_mount_info **cmount, CephContext *cct)
 {
   int ret;
   libceph_init_mutex.Lock();
-  ret = ceph_create_with_config_impl(cmount, conf);
+  ret = ceph_create_with_context_impl(cmount, cct);
   libceph_init_mutex.Unlock();
   return ret;
 }
@@ -280,7 +280,7 @@ extern "C" int ceph_mount(struct ceph_mount_info *cmount, const char *root)
 {
   std::string mount_root;
 
-  keyring_init(&g_conf);
+  keyring_init(&g_ceph_context);
 
   if (root)
     mount_root = root;
index 0c38ac2c962fb40aad6ce1a761a878d7525ea86a..1623cde7412b8959ccfff00dc08c73409ba9efd6 100644 (file)
@@ -58,7 +58,7 @@ int main(int argc, const char **argv)
   }
 
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   FOR_EACH_ARG(args) {
     usage_exit();
index 8348900ee5e61bf25faa06043de569c37c4bd7a7..697d279779d5c1d47e1912e026caa8e4ed9780c9 100644 (file)
@@ -2638,7 +2638,7 @@ init_with_config(md_config_t *conf)
 int librados::Rados::
 connect()
 {
-  int ret = keyring_init(&g_conf);
+  int ret = keyring_init(&g_ceph_context);
   if (ret)
     return ret;
   return client->connect();
@@ -2808,9 +2808,9 @@ extern "C" int rados_create(rados_t *pcluster, const char * const id)
 
     // TODO: store this conf pointer in the RadosClient and use it as our
     // configuration
-    md_config_t *conf = common_preinit(iparams, CODE_ENVIRONMENT_LIBRARY, 0);
-    conf->parse_env(); // environment variables override
-    conf->apply_changes();
+    CephContext *cct = common_preinit(iparams, CODE_ENVIRONMENT_LIBRARY, 0);
+    cct->_conf->parse_env(); // environment variables override
+    cct->_conf->apply_changes();
 
     ++rados_initialized;
   }
@@ -2841,7 +2841,7 @@ extern "C" int rados_create_with_config(rados_t *pcluster, md_config_t *conf)
 
 extern "C" int rados_connect(rados_t cluster)
 {
-  int ret = keyring_init(&g_conf);
+  int ret = keyring_init(&g_ceph_context);
   if (ret)
     return ret;
   librados::RadosClient *radosp = (librados::RadosClient *)cluster;
index f3761bcd90be148e873611d695bd1bb4d1ffa2a9..d1ae8354255fef32e326b1e27d73e946deabd4e4 100644 (file)
@@ -587,7 +587,7 @@ void MDS::tick()
       snapserver->check_osd_map(false);
   }
 
-  g_conf._doss->handle_log_reopen_requests(&g_conf);
+  g_ceph_context._doss->handle_log_reopen_requests(&g_conf);
 }
 
 
index 127f13574dfda8c1a30a83b2e576919d406a2f8c..49d8e488ab7d6960dfc4acc13bb130f5414e4e79 100644 (file)
@@ -965,7 +965,7 @@ void Monitor::tick()
     }
   }
 
-  g_conf._doss->handle_log_reopen_requests(&g_conf);
+  g_ceph_context._doss->handle_log_reopen_requests(&g_conf);
 
   new_tick();
 }
index 3204dd4711edd83fd506b0489642672ba52a9d1d..38e7a22d19a73b11c82d8039100fd9d49edb3fce 100644 (file)
@@ -51,7 +51,7 @@ int main(int argc, const char **argv)
 
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
              CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
   FOR_EACH_ARG(args) {
     if (CEPH_ARGPARSE_EQ("print", '\0')) {
       CEPH_ARGPARSE_SET_ARG_VAL(&print, OPT_BOOL);
index 27317585c78e2f38a2397603a21077a6930887cd..aa9b6039fb571abe3b8f59f420ac6fe88f741e51 100644 (file)
@@ -1793,7 +1793,7 @@ void OSD::tick()
     dispatch_cond.Signal();
   }
 
-  g_conf._doss->handle_log_reopen_requests(&g_conf);
+  g_ceph_context._doss->handle_log_reopen_requests(&g_conf);
 }
 
 // =========================================
index 211fde396842c8f6da80b0519b34cc9fbd88c268..bf77ab593bed546d7c93b19894c973913a56815a 100644 (file)
@@ -51,7 +51,7 @@ int main(int argc, const char **argv)
 
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
              CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   const char *me = argv[0];
 
index 1915173edcbdce25e75f0fbd1f6015cc5854382d..caf51485bc1edf5699ed3fd1a810808abb11eef5 100644 (file)
@@ -659,7 +659,7 @@ int main(int argc, const char **argv)
   env_to_vec(args);
 
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   std::map < std::string, std::string > opts;
   std::vector<const char*>::iterator i;
index 1c05527cbf5b14a4255548caea31c5138dd9820c..595bea77a4b707125cc329a701713d5f846cd183 100644 (file)
@@ -825,7 +825,7 @@ int main(int argc, const char **argv)
 
   int opt_cmd = OPT_NO_CMD;
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   const char *poolname = NULL;
   uint64_t size = 0;
index 3838ce031a2b1ba40a87c3a3ba9447c974bd919c..58fecdbfd39f8de2afe40873900e3c258f1a4ec2 100644 (file)
@@ -38,15 +38,15 @@ int librgw_create(librgw_t *rgw, const char * const id)
     if (id) {
       iparams.name.set(CEPH_ENTITY_TYPE_CLIENT, id);
     }
-    md_config_t *conf = common_preinit(iparams, CODE_ENVIRONMENT_LIBRARY, 0);
-    conf->log_to_stderr = 1; // quiet by default
-    conf->parse_env(); // environment variables override
-    conf->apply_changes();
+    CephContext *cct = common_preinit(iparams, CODE_ENVIRONMENT_LIBRARY, 0);
+    cct->_conf->log_to_stderr = 1; // quiet by default
+    cct->_conf->parse_env(); // environment variables override
+    cct->_conf->apply_changes();
 
     ++librgw_initialized;
   }
   librgw_init_mutex.Unlock();
-  *rgw = &g_conf;
+  *rgw = &g_ceph_context;
   return 0;
 }
 
index 655a41621084f8c4249ff5eb19bbb640a86d8a5b..c7476205c34eb71789284e2206649574237a790f 100644 (file)
@@ -176,7 +176,7 @@ int main(int argc, char **argv)
   env_to_vec(args);
 
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   const char *user_id = 0;
   const char *access_key = 0;
index 1246df892c9496e34f8094c91e7f5d1bb2606e02..944e19f133bfd36c0ff622f37ccf205688b7c98d 100644 (file)
@@ -75,7 +75,7 @@ int main(int argc, const char **argv)
   argv_to_vec(argc, argv, args);
   env_to_vec(args);
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   if (!RGWAccess::init_storage_provider("rados", &g_conf)) {
     derr << "Couldn't init storage provider (RADOS)" << dendl;
index 99371b3015f318ebc977e2be5f3ce54fddda2969..0af3cc66c1c40ced8826aedea74afb80762d1a89 100644 (file)
@@ -97,7 +97,7 @@ int main(int argc, const char **argv)
   env_to_vec(args);
 
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   // args
   if (args.size() < 3) return -1;
index 184cc94eab3673272b3c4c6b9cfd5c1105ac53cc..2b8608e35885b48efd12a62dd928d45e61811d91 100644 (file)
@@ -38,7 +38,7 @@ int main(int argc, const char **argv)
   env_to_vec(args);
 
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   DoutStreambuf<char> *dos = new DoutStreambuf<char>();
 
index 4e4ccce05dc8a497a3c65947af693e820eab63b4..7e82b2d4efbe458738739fd078a897aae972c474 100644 (file)
@@ -95,7 +95,7 @@ int main(int argc, const char **argv)
   env_to_vec(args);
 
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   DEFINE_CONF_VARS(usage);
   FOR_EACH_ARG(args) {
index e804a4a02258715ab8e09fccf54848237696d55d..a32311325dd16af18b0bf8a089cf328c759f05bc 100644 (file)
@@ -256,7 +256,7 @@ int main(int argc, const char **argv)
   env_to_vec(args);
 
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   int ret;
   Mutex safe_timer_lock("safe_timer_lock");
index 26fb1e6b87185fe910cf0daf06652a53686362be..5d555292e04b9ba400470f56d3b1e11c61fec4a1 100644 (file)
@@ -44,7 +44,7 @@ int main(int argc, const char **argv)
   argv_to_vec(argc, argv, args);
   env_to_vec(args);
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   string val;
   string oid("test_object");
index 601aedf2862d1d13415de2e316ca64f8e719ff74..7ab2ac506f027150d5b51ccf806ac27ae3d8df4f 100644 (file)
@@ -36,7 +36,7 @@ int main(int argc, const char **argv)
   env_to_vec(args);
 
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   // args
   if (args.size() < 2) return -1;
index 9906c5bed0103bdfaf3c1eac53b35616ab8e483f..4d1efce9fc10f98cd4fc93ff397d4b8b51d3d899 100644 (file)
@@ -71,7 +71,7 @@ int main(int argc, const char **argv, const char *envp[]) {
   env_to_vec(args);
 
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   vec_to_argv(args, argc, argv);
 
index 947c8ce95313f2f4e840a22758e415ceaf97a758..5b760f3f094eec097e728f24ff7f55ad38946105 100644 (file)
@@ -116,7 +116,7 @@ int main(int argc, const char **argv)
   env_to_vec(args);
 
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   vec_to_argv(args, argc, argv);
 
index c4df25a5d7815a1f0a8c16d891faa5be24f7cbe2..ec7397d57f1c4b0dbbac6f74a06aa4a7f765d8da 100644 (file)
@@ -76,7 +76,7 @@ int main(int argc, const char **argv)
   env_to_vec(args);
 
   common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(&g_conf);
+  common_init_finish(&g_ceph_context);
 
   vec_to_argv(args, argc, argv);