std::string journal_path = g_conf().get_val<std::string>("osd_journal");
uint32_t flags = g_conf().get_val<uint64_t>("osd_os_flags");
- ObjectStore *store = ObjectStore::create(g_ceph_context,
- store_type,
- data_path,
- journal_path,
- flags);
+ std::unique_ptr<ObjectStore> store = ObjectStore::create(g_ceph_context,
+ store_type,
+ data_path,
+ journal_path,
+ flags);
if (!store) {
derr << "unable to create object store" << dendl;
forker.exit(-ENODEV);
forker.exit(-EINVAL);
}
- int err = OSD::mkfs(g_ceph_context, store, g_conf().get_val<uuid_d>("fsid"),
+ int err = OSD::mkfs(g_ceph_context, store.release(), g_conf().get_val<uuid_d>("fsid"),
whoami, osdspec_affinity);
if (err < 0) {
derr << TEXT_RED << " ** ERROR: error creating empty object store in "
<< " for object store " << data_path
<< dendl;
flushjournal_out:
- delete store;
+ store.reset();
forker.exit(err < 0 ? 1 : 0);
}
if (dump_journal) {
uuid_d cluster_fsid, osd_fsid;
ceph_release_t require_osd_release = ceph_release_t::unknown;
int w;
- int r = OSD::peek_meta(store, &magic, &cluster_fsid, &osd_fsid, &w,
+ int r = OSD::peek_meta(store.get(), &magic, &cluster_fsid, &osd_fsid, &w,
&require_osd_release);
if (r < 0) {
derr << TEXT_RED << " ** ERROR: unable to open OSD superblock on "
}
osdptr = new OSD(g_ceph_context,
- store,
+ store.release(),
whoami,
ms_cluster,
ms_public,
using std::string;
-ObjectStore *ObjectStore::create(CephContext *cct,
- const string& type,
- const string& data,
- const string& journal,
- osflagbits_t flags)
+std::unique_ptr<ObjectStore> ObjectStore::create(
+ CephContext *cct,
+ const string& type,
+ const string& data,
+ const string& journal,
+ osflagbits_t flags)
{
#ifndef WITH_SEASTAR
if (type == "filestore") {
- return new FileStore(cct, data, journal, flags);
+ return std::make_unique<FileStore>(cct, data, journal, flags);
}
if (type == "memstore") {
- return new MemStore(cct, data);
+ return std::make_unique<MemStore>(cct, data);
}
#endif
#if defined(WITH_BLUESTORE)
if (type == "bluestore") {
- return new BlueStore(cct, data);
+ return std::make_unique<BlueStore>(cct, data);
}
#ifndef WITH_SEASTAR
if (type == "random") {
if (rand() % 2) {
- return new FileStore(cct, data, journal, flags);
+ return std::make_unique<FileStore>(cct, data, journal, flags);
} else {
- return new BlueStore(cct, data);
+ return std::make_unique<BlueStore>(cct, data);
}
}
#endif
#else
#ifndef WITH_SEASTAR
if (type == "random") {
- return new FileStore(cct, data, journal, flags);
+ return std::make_unique<FileStore>(cct, data, journal, flags);
}
#endif
#endif
#ifndef WITH_SEASTAR
if (type == "kstore" &&
cct->check_experimental_feature_enabled("kstore")) {
- return new KStore(cct, data);
+ return std::make_unique<KStore>(cct, data);
}
#endif
return NULL;
#include <errno.h>
#include <sys/stat.h>
-#include <vector>
#include <map>
+#include <memory>
+#include <vector>
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun) || defined(_WIN32)
#include <sys/statvfs.h>
* @param journal path (or other descriptor) for journal (optional)
* @param flags which filestores should check if applicable
*/
- static ObjectStore *create(CephContext *cct,
- const std::string& type,
- const std::string& data,
- const std::string& journal,
- osflagbits_t flags = 0);
+ static std::unique_ptr<ObjectStore> create(
+ CephContext *cct,
+ const std::string& type,
+ const std::string& data,
+ const std::string& journal,
+ osflagbits_t flags = 0);
/**
* probe a block device to learn the uuid of the owning OSD
TracepointProvider::initialize<bluestore_tracepoint_traits>(g_ceph_context);
// create the ObjectStore
- os.reset(ObjectStore::create(g_ceph_context,
- g_conf().get_val<std::string>("osd objectstore"),
- g_conf().get_val<std::string>("osd data"),
- g_conf().get_val<std::string>("osd journal")));
+ os = ObjectStore::create(g_ceph_context,
+ g_conf().get_val<std::string>("osd objectstore"),
+ g_conf().get_val<std::string>("osd data"),
+ g_conf().get_val<std::string>("osd journal"));
if (!os)
throw std::runtime_error("bad objectstore type " + g_conf()->osd_objectstore);
#include <stdio.h>
#include <string.h>
#include <iostream>
+#include <memory>
#include <time.h>
#include <sys/mount.h>
-#include <boost/scoped_ptr.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/binomial_distribution.hpp>
#endif
"kstore"));
-void doMany4KWritesTest(boost::scoped_ptr<ObjectStore>& store,
+void doMany4KWritesTest(ObjectStore* store,
unsigned max_objects,
unsigned max_ops,
unsigned max_object_size,
coll_t cid(spg_t(pg_t(0,555), shard_id_t::NO_SHARD));
store_statfs_t res_stat;
- SyntheticWorkloadState test_obj(store.get(),
+ SyntheticWorkloadState test_obj(store,
&gen,
&rng,
cid,
StartDeferred(0x10000);
const unsigned max_object = 4*1024*1024;
- doMany4KWritesTest(store, 1, 1000, max_object, 4*1024, 0);
+ doMany4KWritesTest(store.get(), 1, 1000, max_object, 4*1024, 0);
}
TEST_P(StoreTestSpecificAUSize, Many4KWritesNoCSumTest) {
g_ceph_context->_conf.apply_changes(nullptr);
const unsigned max_object = 4*1024*1024;
- doMany4KWritesTest(store, 1, 1000, max_object, 4*1024, 0 );
+ doMany4KWritesTest(store.get(), 1, 1000, max_object, 4*1024, 0 );
}
TEST_P(StoreTestSpecificAUSize, TooManyBlobsTest) {
return;
StartDeferred(0x10000);
const unsigned max_object = 4*1024*1024;
- doMany4KWritesTest(store, 1, 1000, max_object, 4*1024, 0);
+ doMany4KWritesTest(store.get(), 1, 1000, max_object, 4*1024, 0);
}
#if defined(WITH_BLUESTORE)
}
ASSERT_EQ(0, r);
- store.reset(ObjectStore::create(g_ceph_context,
- type,
- data_dir,
- string("store_test_temp_journal")));
+ store = ObjectStore::create(g_ceph_context,
+ type,
+ data_dir,
+ "store_test_temp_journal");
if (!store) {
cerr << __func__ << ": objectstore type " << type << " doesn't exist yet!" << std::endl;
}
EXPECT_EQ(0, r);
ch.reset(nullptr);
store.reset(nullptr);
- store.reset(ObjectStore::create(g_ceph_context,
- type,
- data_dir,
- string("store_test_temp_journal")));
+ store = ObjectStore::create(g_ceph_context,
+ type,
+ data_dir,
+ "store_test_temp_journal");
if (!store) {
cerr << __func__ << ": objectstore type " << type << " failed to reopen!" << std::endl;
}
#include <string>
#include <stack>
-#include <boost/scoped_ptr.hpp>
+#include <memory>
#include <gtest/gtest.h>
#include "common/config_fwd.h"
std::string orig_death_test_style;
public:
- boost::scoped_ptr<ObjectStore> store;
+ std::unique_ptr<ObjectStore> store;
ObjectStore::CollectionHandle ch;
explicit StoreTestFixture(const std::string& type)
dout(0) << "repeats " << cfg.repeats << dendl;
dout(0) << "threads " << cfg.threads << dendl;
- auto os = std::unique_ptr<ObjectStore>(
+ auto os =
ObjectStore::create(g_ceph_context,
g_conf()->osd_objectstore,
g_conf()->osd_data,
- g_conf()->osd_journal));
+ g_conf()->osd_journal);
//Checking data folder: create if needed or error if it's not empty
DIR *dir = ::opendir(g_conf()->osd_data.c_str());
TEST(TestOSDScrub, scrub_time_permit) {
ceph::async::io_context_pool icp(1);
- ObjectStore *store = ObjectStore::create(g_ceph_context,
+ std::unique_ptr<ObjectStore> store = ObjectStore::create(g_ceph_context,
g_conf()->osd_objectstore,
g_conf()->osd_data,
g_conf()->osd_journal);
ms->bind(g_conf()->public_addr);
MonClient mc(g_ceph_context, icp);
mc.build_initial_monmap();
- TestOSDScrub* osd = new TestOSDScrub(g_ceph_context, store, 0, ms, ms, ms, ms, ms, ms, ms, &mc, "", "", icp);
+ TestOSDScrub* osd = new TestOSDScrub(g_ceph_context, store.release(), 0, ms, ms, ms, ms, ms, ms, ms, &mc, "", "", icp);
// These are now invalid
int err = g_ceph_context->_conf.set_val("osd_scrub_begin_hour", "24");
}
}
- ObjectStore *fs = ObjectStore::create(g_ceph_context, type, dpath, jpath, flags);
+ ObjectStore *fs = ObjectStore::create(g_ceph_context, type, dpath, jpath, flags).release();
if (fs == NULL) {
cerr << "Unable to create store of type " << type << std::endl;
return 1;
target_type = string(bl.c_str(), bl.length() - 1); // drop \n
}
::close(fd);
- ObjectStore *targetfs = ObjectStore::create(
+ unique_ptr<ObjectStore> targetfs = ObjectStore::create(
g_ceph_context, target_type,
target_data_path, "", 0);
if (targetfs == NULL) {
cerr << "Unable to open store of type " << target_type << std::endl;
return 1;
}
- int r = dup(dpath, fs, target_data_path, targetfs);
+ int r = dup(dpath, fs, target_data_path, targetfs.get());
if (r < 0) {
cerr << "dup failed: " << cpp_strerror(r) << std::endl;
return 1;