*/
class ObjectMap {
public:
+ CephContext* cct;
/// Set keys and values from specified map
virtual int set_keys(
const ghobject_t &oid, ///< [in] object containing map
}
+ ObjectMap(CephContext* cct) : cct(cct) {}
virtual ~ObjectMap() {}
};
osflagbits_t flags)
{
if (type == "filestore") {
- return new FileStore(data, journal, flags);
+ return new FileStore(cct, data, journal, flags);
}
if (type == "memstore") {
return new MemStore(cct, data);
string path;
public:
+ CephContext* cct;
/**
* create - create an ObjectStore instance.
*
* created in ...::queue_transaction(s)
*/
struct Sequencer_impl : public RefCountedObject {
+ CephContext* cct;
virtual void flush() = 0;
/**
Context *c ///< [in] context to call upon flush/commit
) = 0; ///< @return true if idle, false otherwise
- Sequencer_impl() : RefCountedObject(NULL, 0) {}
+ Sequencer_impl(CephContext* cct) : RefCountedObject(NULL, 0), cct(cct) {}
virtual ~Sequencer_impl() {}
};
typedef boost::intrusive_ptr<Sequencer_impl> Sequencer_implRef;
}
public:
- explicit ObjectStore(const std::string& path_) : path(path_), logger(NULL) {}
+ ObjectStore(CephContext* cct,
+ const std::string& path_) : path(path_), cct(cct),
+ logger(nullptr) {}
virtual ~ObjectStore() {}
// no copying
- explicit ObjectStore(const ObjectStore& o);
- const ObjectStore& operator=(const ObjectStore& o);
+ explicit ObjectStore(const ObjectStore& o) = delete;
+ const ObjectStore& operator=(const ObjectStore& o) = delete;
// versioning
virtual int upgrade() {
}
BlueStore::BlueStore(CephContext *cct, const string& path)
- : ObjectStore(path),
- cct(cct),
+ : ObjectStore(cct, path),
bluefs(NULL),
bluefs_shared_bdev(0),
db(NULL),
int BlueStore::_wal_replay()
{
dout(10) << __func__ << " start" << dendl;
- OpSequencerRef osr = new OpSequencer;
+ OpSequencerRef osr = new OpSequencer(cct);
int count = 0;
KeyValueDB::Iterator it = db->get_iterator(PREFIX_WAL);
for (it->lower_bound(string()); it->valid(); it->next(), ++count) {
osr = static_cast<OpSequencer *>(posr->p.get());
dout(10) << __func__ << " existing " << osr << " " << *osr << dendl;
} else {
- osr = new OpSequencer;
+ osr = new OpSequencer(cct);
osr->parent = posr;
posr->p = osr;
dout(10) << __func__ << " new " << osr << " " << *osr << dendl;
std::atomic_int kv_committing_serially = {0};
- OpSequencer()
+ OpSequencer(CephContext* cct)
//set the qlock to PTHREAD_MUTEX_RECURSIVE mode
- : parent(NULL) {
+ : Sequencer_impl(cct),
+ parent(NULL) {
}
~OpSequencer() {
assert(q.empty());
// --------------------------------------------------------
// members
private:
- CephContext *cct;
BlueFS *bluefs;
unsigned bluefs_shared_bdev; ///< which bluefs bdev we are sharing
KeyValueDB *db;
}
};
- explicit DBObjectMap(KeyValueDB *db) : db(db), header_lock("DBOBjectMap"),
- cache_lock("DBObjectMap::CacheLock"),
- caches(g_conf->filestore_omap_header_cache_size)
+ DBObjectMap(CephContext* cct, KeyValueDB *db)
+ : ObjectMap(cct), db(db), header_lock("DBOBjectMap"),
+ cache_lock("DBObjectMap::CacheLock"),
+ caches(cct->_conf->filestore_omap_header_cache_size)
{}
int set_keys(
return 0;
}
-FileStore::FileStore(const std::string &base, const std::string &jdev, osflagbits_t flags, const char *name, bool do_update) :
- JournalingObjectStore(base),
+FileStore::FileStore(CephContext* cct, const std::string &base,
+ const std::string &jdev, osflagbits_t flags,
+ const char *name, bool do_update) :
+ JournalingObjectStore(cct, base),
internal_name(name),
basedir(base), journalpath(jdev),
generic_flags(flags),
goto close_current_fd;
}
- DBObjectMap *dbomap = new DBObjectMap(omap_store);
+ DBObjectMap *dbomap = new DBObjectMap(cct, omap_store);
ret = dbomap->init(do_update);
if (ret < 0) {
delete dbomap;
osr = static_cast<OpSequencer *>(posr->p.get());
dout(5) << "queue_transactions existing " << osr << " " << *osr << dendl;
} else {
- osr = new OpSequencer(next_osr_id.inc());
+ osr = new OpSequencer(cct, next_osr_id.inc());
osr->set_cct(g_ceph_context);
osr->parent = posr;
posr->p = osr;
}
}
- explicit OpSequencer(int i)
- : qlock("FileStore::OpSequencer::qlock", false, false),
+ OpSequencer(CephContext* cct, int i)
+ : Sequencer_impl(cct),
+ qlock("FileStore::OpSequencer::qlock", false, false),
parent(0),
apply_lock("FileStore::OpSequencer::apply_lock", false, false),
id(i) {}
bool force_clear_omap=false);
public:
- FileStore(const std::string &base, const std::string &jdev,
- osflagbits_t flags = 0,
+ FileStore(CephContext* cct, const std::string &base, const std::string &jdev,
+ osflagbits_t flags = 0,
const char *internal_name = "filestore", bool update_to=false);
~FileStore();
}
public:
- explicit JournalingObjectStore(const std::string& path)
- : ObjectStore(path),
+ JournalingObjectStore(CephContext* cct, const std::string& path)
+ : ObjectStore(cct, path),
journal(NULL),
- finisher(g_ceph_context, "JournalObjectStore", "fn_jrn_objstore"),
+ finisher(cct, "JournalObjectStore", "fn_jrn_objstore"),
apply_manager(journal, finisher),
replaying(false) {}
#define dout_prefix *_dout << "kstore(" << path << ") "
KStore::KStore(CephContext *cct, const string& path)
- : ObjectStore(path),
- cct(cct),
+ : ObjectStore(cct, path),
db(NULL),
path_fd(-1),
fsid_fd(-1),
osr = static_cast<OpSequencer *>(posr->p.get());
dout(10) << __func__ << " existing " << osr << " " << *osr << dendl;
} else {
- osr = new OpSequencer;
+ osr = new OpSequencer(cct);
osr->parent = posr;
posr->p = osr;
dout(10) << __func__ << " new " << osr << " " << *osr << dendl;
Sequencer *parent;
- OpSequencer()
+ OpSequencer(CephContext* cct)
//set the qlock to PTHREAD_MUTEX_RECURSIVE mode
- : parent(NULL) {
+ : Sequencer_impl(cct),
+ parent(NULL) {
}
~OpSequencer() {
assert(q.empty());
// --------------------------------------------------------
// members
private:
- CephContext *cct;
KeyValueDB *db;
uuid_d fsid;
int path_fd; ///< open handle to $path
// Sequencer with a mutex. this guarantees ordering on a given sequencer,
// while allowing operations on different sequencers to happen in parallel
struct OpSequencer : public Sequencer_impl {
+ OpSequencer(CephContext* cct) :
+ Sequencer_impl(cct) {}
std::mutex mutex;
void flush() override {}
bool flush_commit(Context*) override { return true; }
std::unique_lock<std::mutex> lock;
if (osr) {
if (!osr->p) {
- osr->p = new OpSequencer();
+ osr->p = new OpSequencer(cct);
}
auto seq = static_cast<OpSequencer*>(osr->p.get());
lock = std::unique_lock<std::mutex>(seq->mutex);
#include "include/assert.h"
class MemStore : public ObjectStore {
-private:
- CephContext *const cct;
-
public:
struct Object : public RefCountedObject {
std::mutex xattr_mutex;
public:
MemStore(CephContext *cct, const string& path)
- : ObjectStore(path),
- cct(cct),
+ : ObjectStore(cct, path),
coll_lock("MemStore::coll_lock"),
finisher(cct),
used_bytes(0) {}
virtual void SetUp() {
char *path = getenv("OBJECT_MAP_PATH");
if (!path) {
- db.reset(new DBObjectMap(new KeyValueDBMemory()));
+ db.reset(new DBObjectMap(g_ceph_context, new KeyValueDBMemory()));
tester.db = db.get();
return;
}
KeyValueDB *store = KeyValueDB::create(g_ceph_context, "leveldb", strpath);
assert(!store->create_and_open(cerr));
- db.reset(new DBObjectMap(store));
+ db.reset(new DBObjectMap(g_ceph_context, store));
tester.db = db.get();
}
ops.insert(make_pair(vm["write-ratio"].as<double>(), Bencher::WRITE));
ops.insert(make_pair(1-vm["write-ratio"].as<double>(), Bencher::READ));
- FileStore fs(vm["filestore-path"].as<string>(),
+ FileStore fs(g_ceph_context, vm["filestore-path"].as<string>(),
vm["journal-path"].as<string>());
ObjectStore::Sequencer osr(__func__);
{
{
map<string,string> pm;
- FileStore fs("a", "b");
+ FileStore fs(g_ceph_context, "a", "b");
TestFileStore::create_backend(fs, 0);
fs.collect_metadata(&pm);
ASSERT_EQ(pm["filestore_backend"], "generic");
#if defined(__linux__)
{
map<string,string> pm;
- FileStore fs("a", "b");
+ FileStore fs(g_ceph_context, "a", "b");
TestFileStore::create_backend(fs, BTRFS_SUPER_MAGIC);
fs.collect_metadata(&pm);
ASSERT_EQ(pm["filestore_backend"], "btrfs");
# ifdef HAVE_LIBXFS
{
map<string,string> pm;
- FileStore fs("a", "b");
+ FileStore fs(g_ceph_context, "a", "b");
TestFileStore::create_backend(fs, XFS_SUPER_MAGIC);
fs.collect_metadata(&pm);
ASSERT_EQ(pm["filestore_backend"], "xfs");
} // namespace librbd
#include "librbd/AioImageRequest.cc"
+
template class librbd::AioImageRequest<librbd::MockTestImageCtx>;
namespace librbd {
KeyValueDB *_db = KeyValueDB::create(g_ceph_context, "leveldb", db_path);
assert(!_db->create_and_open(std::cerr));
boost::scoped_ptr<KeyValueDB> db(_db);
- boost::scoped_ptr<ObjectStore> store(new FileStore(store_path, store_dev));
+ boost::scoped_ptr<ObjectStore> store(new FileStore(cct.get(), store_path,
+ store_dev));
ObjectStore::Sequencer osr(__func__);
coll_t coll(spg_t(pg_t(0,12),shard_id_t::NO_SHARD));
std::string status_file;
int run_diff(std::string& a_path, std::string& a_journal,
- std::string& b_path, std::string& b_journal)
+ std::string& b_path, std::string& b_journal)
{
- FileStore *a = new FileStore(a_path, a_journal, 0, "a");
- FileStore *b = new FileStore(b_path, b_journal, 0, "b");
+ FileStore *a = new FileStore(g_ceph_context, a_path, a_journal, 0, "a");
+ FileStore *b = new FileStore(g_ceph_context, b_path, b_journal, 0, "b");
int ret = 0;
{
int run_get_last_op(std::string& filestore_path, std::string& journal_path)
{
- FileStore *store = new FileStore(filestore_path, journal_path);
+ FileStore *store = new FileStore(g_ceph_context, filestore_path,
+ journal_path);
int err = store->mount();
if (err) {
if (!is_seed_set)
seed = (int) time(NULL);
- FileStore *store = new FileStore(filestore_path, journal_path);
+ FileStore *store = new FileStore(g_ceph_context, filestore_path,
+ journal_path);
int err;
cout << "#dev " << filename << std::endl;
cout << "#mb " << mb << std::endl;
- ObjectStore *fs = new FileStore(filename, NULL);
+ ObjectStore *fs = new FileStore(cct.get(), filename, NULL);
if (fs->mount() < 0) {
cout << "mount failed" << std::endl;
return -1;
string store_path(args[1]);
string store_dev(args[2]);
- boost::scoped_ptr<ObjectStore> store(new FileStore(store_path, store_dev));
+ boost::scoped_ptr<ObjectStore> store(new FileStore(cct.get(), store_path,
+ store_dev));
std::cerr << "mkfs starting" << std::endl;
assert(!store->mkfs());
std::cerr << "Enabling paranoid checks" << std::endl;
store->options.paranoid_checks = true;
}*/
- DBObjectMap omap(store);
+ DBObjectMap omap(cct.get(), store);
stringstream out;
int r = store->open(out);
if (r < 0) {