]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: use ObjectStore::create() helper to create ObjectStore impl
authorSage Weil <sage@inktank.com>
Sun, 3 Nov 2013 01:56:53 +0000 (18:56 -0700)
committerSage Weil <sage@inktank.com>
Sat, 30 Nov 2013 06:28:36 +0000 (22:28 -0800)
No more knowledge of FileStore!

Signed-off-by: Sage Weil <sage@inktank.com>
src/ceph_osd.cc
src/common/config_opts.h
src/osd/OSD.cc
src/osd/OSD.h

index 2388762f1dfa644d54406f33b74260b6a810b95d..3298fedf42f4eabf032fff8c1e638df45d37ea2b 100644 (file)
@@ -256,7 +256,7 @@ int main(int argc, const char **argv)
 
 
   if (convertfilestore) {
-    int err = OSD::convertfs(g_conf->osd_data, g_conf->osd_journal);
+    int err = OSD::convertfs(g_ceph_context);
     if (err < 0) {
       derr << TEXT_RED << " ** ERROR: error converting store " << g_conf->osd_data
           << ": " << cpp_strerror(-err) << TEXT_NORMAL << dendl;
@@ -424,7 +424,7 @@ int main(int argc, const char **argv)
   common_init_finish(g_ceph_context);
 
   if (g_conf->filestore_update_to >= (int)FileStore::target_version) {
-    int err = OSD::convertfs(g_conf->osd_data, g_conf->osd_journal);
+    int err = OSD::convertfs(g_ceph_context);
     if (err < 0) {
       derr << TEXT_RED << " ** ERROR: error converting store " << g_conf->osd_data
           << ": " << cpp_strerror(-err) << TEXT_NORMAL << dendl;
index abdb84ab90a7124c095c296c142f21180b85b34b..4534e27821d39921e707cf51ef53f8182334d3e9 100644 (file)
@@ -520,6 +520,8 @@ OPTION(osd_mon_shutdown_timeout, OPT_DOUBLE, 5)
 OPTION(osd_max_object_size, OPT_U64, 100*1024L*1024L*1024L) // OSD's maximum object size
 OPTION(osd_max_attr_size, OPT_U64, 0)
 
+OPTION(osd_objectstore, OPT_STR, "filestore")  // ObjectStore backend type
+
 /// filestore wb throttle limits
 OPTION(filestore_wbthrottle_enable, OPT_BOOL, true)
 OPTION(filestore_wbthrottle_btrfs_bytes_start_flusher, OPT_U64, 41943040)
index c1ca689d6ec9436a7716d8b532f89ad891908074..075c505d4cd88122b3a427bd0467c21b5fc2f5ee 100644 (file)
@@ -37,7 +37,8 @@
 
 #include "common/ceph_argparse.h"
 #include "common/version.h"
-#include "os/FileStore.h"
+
+#include "os/ObjectStore.h"
 #include "os/FileJournal.h"
 
 #include "ReplicatedPG.h"
@@ -439,21 +440,6 @@ void OSDService::init()
   watch_timer.init();
 }
 
-ObjectStore *OSD::create_object_store(CephContext *cct, const std::string &dev, const std::string &jdev)
-{
-  struct stat st;
-  if (::stat(dev.c_str(), &st) != 0)
-    return 0;
-
-  if (cct->_conf->filestore)
-    return new FileStore(dev, jdev);
-
-  if (S_ISDIR(st.st_mode))
-    return new FileStore(dev, jdev);
-  else
-    return 0;
-}
-
 #undef dout_prefix
 #define dout_prefix *_dout
 
@@ -526,7 +512,7 @@ int OSD::do_convertfs(ObjectStore *store)
   if (r == 1)
     return store->umount();
 
-  derr << "FileStore is old at version " << version << ".  Updating..."  << dendl;
+  derr << "ObjectStore is old at version " << version << ".  Updating..."  << dendl;
 
   derr << "Removing tmp pgs" << dendl;
   vector<coll_t> collections;
@@ -583,11 +569,11 @@ int OSD::do_convertfs(ObjectStore *store)
   return store->umount();
 }
 
-int OSD::convertfs(const std::string &dev, const std::string &jdev)
+int OSD::convertfs(CephContext *cct)
 {
-  boost::scoped_ptr<ObjectStore> store(
-    new FileStore(dev, jdev, "filestore", 
-                 true));
+  boost::scoped_ptr<ObjectStore> store(ObjectStore::create(cct->_conf->osd_objectstore,
+                                                          cct->_conf->osd_data,
+                                                          cct->_conf->osd_journal));
   int r = do_convertfs(store.get());
   return r;
 }
@@ -598,7 +584,7 @@ int OSD::mkfs(CephContext *cct, const std::string &dev, const std::string &jdev,
   ObjectStore *store = NULL;
 
   try {
-    store = create_object_store(cct, dev, jdev);
+    store = ObjectStore::create(cct->_conf->osd_objectstore, dev, jdev);
     if (!store) {
       ret = -ENOENT;
       goto out;
@@ -609,13 +595,13 @@ int OSD::mkfs(CephContext *cct, const std::string &dev, const std::string &jdev,
 
     ret = store->mkfs();
     if (ret) {
-      derr << "OSD::mkfs: FileStore::mkfs failed with error " << ret << dendl;
+      derr << "OSD::mkfs: ObjectStore::mkfs failed with error " << ret << dendl;
       goto free_store;
     }
 
     ret = store->mount();
     if (ret) {
-      derr << "OSD::mkfs: couldn't mount FileStore: error " << ret << dendl;
+      derr << "OSD::mkfs: couldn't mount ObjectStore: error " << ret << dendl;
       goto free_store;
     }
 
@@ -739,7 +725,7 @@ out:
 
 int OSD::mkjournal(CephContext *cct, const std::string &dev, const std::string &jdev)
 {
-  ObjectStore *store = create_object_store(cct, dev, jdev);
+  ObjectStore *store = ObjectStore::create(cct->_conf->osd_objectstore, dev, jdev);
   if (!store)
     return -ENOENT;
   return store->mkjournal();
@@ -747,7 +733,7 @@ int OSD::mkjournal(CephContext *cct, const std::string &dev, const std::string &
 
 int OSD::flushjournal(CephContext *cct, const std::string &dev, const std::string &jdev)
 {
-  ObjectStore *store = create_object_store(cct, dev, jdev);
+  ObjectStore *store = ObjectStore::create(cct->_conf->osd_objectstore, dev, jdev);
   if (!store)
     return -ENOENT;
   int err = store->mount();
@@ -761,7 +747,7 @@ int OSD::flushjournal(CephContext *cct, const std::string &dev, const std::strin
 
 int OSD::dump_journal(CephContext *cct, const std::string &dev, const std::string &jdev, ostream& out)
 {
-  ObjectStore *store = create_object_store(cct, dev, jdev);
+  ObjectStore *store = ObjectStore::create(cct->_conf->osd_objectstore, dev, jdev);
   if (!store)
     return -ENOENT;
   int err = store->dump_journal(out);
@@ -942,7 +928,7 @@ int OSD::pre_init()
     return 0;
   
   assert(!store);
-  store = create_object_store(cct, dev_path, journal_path);
+  store = ObjectStore::create(cct->_conf->osd_objectstore, dev_path, journal_path);
   if (!store) {
     derr << "OSD::pre_init: unable to create object store" << dendl;
     return -ENODEV;
index 11ad2b89399be1c7b5be2e060e24e6b0440b67b2..ff9c66679e7ed8ceb8bb07945d1dffd0278448a0 100644 (file)
@@ -1720,8 +1720,7 @@ protected:
 
   // static bits
   static int find_osd_dev(char *result, int whoami);
-  static ObjectStore *create_object_store(CephContext *cct, const std::string &dev, const std::string &jdev);
-  static int convertfs(const std::string &dev, const std::string &jdev);
+  static int convertfs(CephContext *cct);
   static int do_convertfs(ObjectStore *store);
   static int convert_collection(ObjectStore *store, coll_t cid);
   static int mkfs(CephContext *cct, const std::string &dev, const std::string &jdev,