From: Sage Weil Date: Sun, 3 Nov 2013 01:56:53 +0000 (-0700) Subject: osd: use ObjectStore::create() helper to create ObjectStore impl X-Git-Tag: v0.74~43^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=41056e5297df37b95245368c2b7d8980d842dcd7;p=ceph.git osd: use ObjectStore::create() helper to create ObjectStore impl No more knowledge of FileStore! Signed-off-by: Sage Weil --- diff --git a/src/ceph_osd.cc b/src/ceph_osd.cc index 2388762f1dfa..3298fedf42f4 100644 --- a/src/ceph_osd.cc +++ b/src/ceph_osd.cc @@ -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; diff --git a/src/common/config_opts.h b/src/common/config_opts.h index abdb84ab90a7..4534e27821d3 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -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) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index c1ca689d6ec9..075c505d4cd8 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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 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 store( - new FileStore(dev, jdev, "filestore", - true)); + boost::scoped_ptr 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; diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 11ad2b89399b..ff9c66679e7e 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -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,