#include <sys/mount.h>
#endif
-#define dout_context g_ceph_context
+#define dout_context store->cct
#define dout_subsys ceph_subsys_fuse
#include "common/debug.h"
#undef dout_prefix
FN_HASH_VAL,
};
-static int parse_fn(const char *path, coll_t *cid, ghobject_t *oid, string *key,
+static int parse_fn(CephContext* cct, const char *path, coll_t *cid,
+ ghobject_t *oid, string *key,
uint32_t *hash, uint32_t *hash_bits)
{
list<string> v;
if (!*p)
break;
}
- dout(10) << __func__ << " path " << path << " -> " << v << dendl;
+ ldout(cct, 10) << __func__ << " path " << path << " -> " << v << dendl;
if (v.empty())
return FN_ROOT;
static int os_getattr(const char *path, struct stat *stbuf)
{
- dout(10) << __func__ << " " << path << dendl;
+ fuse_context *fc = fuse_get_context();
+ FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
+ ldout(fs->store->cct, 10) << __func__ << " " << path << dendl;
coll_t cid;
ghobject_t oid;
string key;
uint32_t hash_value, hash_bits;
- int t = parse_fn(path, &cid, &oid, &key, &hash_value, &hash_bits);
+ int t = parse_fn(fs->store->cct, path, &cid, &oid, &key, &hash_value,
+ &hash_bits);
if (t < 0)
return t;
- fuse_context *fc = fuse_get_context();
- FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
std::lock_guard<std::mutex> l(fs->lock);
stbuf->st_size = 0;
off_t offset,
struct fuse_file_info *fi)
{
- dout(10) << __func__ << " " << path << " offset " << offset << dendl;
+ fuse_context *fc = fuse_get_context();
+ FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
+ ldout(fs->store->cct, 10) << __func__ << " " << path << " offset " << offset
+ << dendl;
coll_t cid;
ghobject_t oid;
string key;
uint32_t hash_value, hash_bits;
- int t = parse_fn(path, &cid, &oid, &key, &hash_value, &hash_bits);
+ int t = parse_fn(fs->store->cct, path, &cid, &oid, &key, &hash_value,
+ &hash_bits);
if (t < 0)
return t;
- fuse_context *fc = fuse_get_context();
- FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
std::lock_guard<std::mutex> l(fs->lock);
// we can't shift 32 bits or else off_t will go negative
} else {
last = ghobject_t::get_max();
}
- dout(10) << __func__ << std::hex
- << " offset " << offset << " hash "
- << hobject_t::_reverse_bits(hash_value)
- << std::dec
- << "/" << hash_bits
- << " first " << next << " last " << last
- << dendl;
+ ldout(fs->store->cct, 10) << __func__ << std::hex
+ << " offset " << offset << " hash "
+ << hobject_t::_reverse_bits(hash_value)
+ << std::dec
+ << "/" << hash_bits
+ << " first " << next << " last " << last
+ << dendl;
while (true) {
vector<ghobject_t> ls;
int r = fs->store->collection_list(
static int os_open(const char *path, struct fuse_file_info *fi)
{
- dout(10) << __func__ << " " << path << dendl;
+ fuse_context *fc = fuse_get_context();
+ FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
+ ldout(fs->store->cct, 10) << __func__ << " " << path << dendl;
coll_t cid;
ghobject_t oid;
string key;
uint32_t hash_value, hash_bits;
- int t = parse_fn(path, &cid, &oid, &key, &hash_value, &hash_bits);
+ int t = parse_fn(fs->store->cct, path, &cid, &oid, &key, &hash_value,
+ &hash_bits);
if (t < 0)
return t;
- fuse_context *fc = fuse_get_context();
- FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
std::lock_guard<std::mutex> l(fs->lock);
bufferlist *pbl = 0;
static int os_mkdir(const char *path, mode_t mode)
{
- dout(10) << __func__ << " " << path << dendl;
+ fuse_context *fc = fuse_get_context();
+ FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
+ ldout(fs->store->cct, 10) << __func__ << " " << path << dendl;
coll_t cid;
ghobject_t oid;
string key;
uint32_t hash_value, hash_bits;
- int f = parse_fn(path, &cid, &oid, &key, &hash_value, &hash_bits);
+ int f = parse_fn(fs->store->cct, path, &cid, &oid, &key, &hash_value,
+ &hash_bits);
if (f < 0)
return f;
- fuse_context *fc = fuse_get_context();
- FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
std::lock_guard<std::mutex> l(fs->lock);
ObjectStore::Transaction t;
static int os_chmod(const char *path, mode_t mode)
{
- dout(10) << __func__ << " " << path << dendl;
+ fuse_context *fc = fuse_get_context();
+ FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
+ ldout(fs->store->cct, 10) << __func__ << " " << path << dendl;
return 0;
}
static int os_create(const char *path, mode_t mode, struct fuse_file_info *fi)
{
- dout(10) << __func__ << " " << path << dendl;
+ fuse_context *fc = fuse_get_context();
+ FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
+ ldout(fs->store->cct, 10) << __func__ << " " << path << dendl;
coll_t cid;
ghobject_t oid;
string key;
uint32_t hash_value, hash_bits;
- int f = parse_fn(path, &cid, &oid, &key, &hash_value, &hash_bits);
+ int f = parse_fn(fs->store->cct, path, &cid, &oid, &key, &hash_value,
+ &hash_bits);
if (f < 0)
return f;
- fuse_context *fc = fuse_get_context();
- FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
std::lock_guard<std::mutex> l(fs->lock);
ObjectStore::Transaction t;
static int os_release(const char *path, struct fuse_file_info *fi)
{
- dout(10) << __func__ << " " << path << dendl;
fuse_context *fc = fuse_get_context();
FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
+ ldout(fs->store->cct, 10) << __func__ << " " << path << dendl;
std::lock_guard<std::mutex> l(fs->lock);
FuseStore::OpenFile *o = reinterpret_cast<FuseStore::OpenFile*>(fi->fh);
if (--o->ref == 0) {
- dout(10) << __func__ << " closing last " << o->path << dendl;
+ ldout(fs->store->cct, 10) << __func__ << " closing last " << o->path << dendl;
fs->open_files.erase(o->path);
delete o;
}
static int os_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
- dout(10) << __func__ << " " << path << " offset " << offset
- << " size " << size << dendl;
fuse_context *fc = fuse_get_context();
FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
+ ldout(fs->store->cct, 10) << __func__ << " " << path << " offset " << offset
+ << " size " << size << dendl;
std::lock_guard<std::mutex> l(fs->lock);
FuseStore::OpenFile *o = reinterpret_cast<FuseStore::OpenFile*>(fi->fh);
if (!o)
static int os_write(const char *path, const char *buf, size_t size,
off_t offset, struct fuse_file_info *fi)
{
- dout(10) << __func__ << " " << path << " offset " << offset
- << " size " << size << dendl;
fuse_context *fc = fuse_get_context();
FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
+ ldout(fs->store->cct, 10) << __func__ << " " << path << " offset " << offset
+ << " size " << size << dendl;
std::lock_guard<std::mutex> l(fs->lock);
FuseStore::OpenFile *o = reinterpret_cast<FuseStore::OpenFile*>(fi->fh);
if (!o)
int os_flush(const char *path, struct fuse_file_info *fi)
{
- dout(10) << __func__ << " " << path << dendl;
+ fuse_context *fc = fuse_get_context();
+ FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
+ ldout(fs->store->cct, 10) << __func__ << " " << path << dendl;
coll_t cid;
ghobject_t oid;
string key;
uint32_t hash_value, hash_bits;
- int f = parse_fn(path, &cid, &oid, &key, &hash_value, &hash_bits);
+ int f = parse_fn(fs->store->cct, path, &cid, &oid, &key, &hash_value,
+ &hash_bits);
if (f < 0)
return f;
- fuse_context *fc = fuse_get_context();
- FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
std::lock_guard<std::mutex> l(fs->lock);
FuseStore::OpenFile *o = reinterpret_cast<FuseStore::OpenFile*>(fi->fh);
static int os_unlink(const char *path)
{
- dout(10) << __func__ << " " << path << dendl;
+ fuse_context *fc = fuse_get_context();
+ FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
+ ldout(fs->store->cct, 10) << __func__ << " " << path << dendl;
coll_t cid;
ghobject_t oid;
string key;
uint32_t hash_value, hash_bits;
- int f = parse_fn(path, &cid, &oid, &key, &hash_value, &hash_bits);
+ int f = parse_fn(fs->store->cct, path, &cid, &oid, &key, &hash_value,
+ &hash_bits);
if (f < 0)
return f;
- fuse_context *fc = fuse_get_context();
- FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
std::lock_guard<std::mutex> l(fs->lock);
ObjectStore::Transaction t;
static int os_truncate(const char *path, off_t size)
{
- dout(10) << __func__ << " " << path << " size " << size << dendl;
+ fuse_context *fc = fuse_get_context();
+ FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
+ ldout(fs->store->cct, 10) << __func__ << " " << path << " size " << size << dendl;
coll_t cid;
ghobject_t oid;
string key;
uint32_t hash_value, hash_bits;
- int f = parse_fn(path, &cid, &oid, &key, &hash_value, &hash_bits);
+ int f = parse_fn(fs->store->cct, path, &cid, &oid, &key, &hash_value,
+ &hash_bits);
if (f < 0)
return f;
if (f != FN_OBJECT_DATA)
return -EPERM;
- fuse_context *fc = fuse_get_context();
- FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
std::lock_guard<std::mutex> l(fs->lock);
if (fs->open_files.count(path)) {
static int os_statfs(const char *path, struct statvfs *stbuf)
{
- dout(10) << __func__ << " " << path << dendl;
fuse_context *fc = fuse_get_context();
FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
+ ldout(fs->store->cct, 10) << __func__ << " " << path << dendl;
std::lock_guard<std::mutex> l(fs->lock);
struct store_statfs_t s;
"-d", // debug
};
int c = 3;
- if (g_conf->fuse_debug)
+ if (store->cct->_conf->fuse_debug)
++c;
return fuse_main(c, (char**)v, &fs_oper, (void*)this);
}
"-d", // debug
};
int c = 3;
- if (g_conf->fuse_debug)
+ if (store->cct->_conf->fuse_debug)
++c;
fuse_args a = FUSE_ARGS_INIT(c, (char**)v);
info->args = a;
#include "common/Formatter.h"
-#define dout_context g_ceph_context
+#define dout_context cct
#define dout_subsys ceph_subsys_kstore
/*
static int get_key_object(const string& key, ghobject_t *oid);
-static void get_object_key(const ghobject_t& oid, string *key)
+static void get_object_key(CephContext* cct, const ghobject_t& oid,
+ string *key)
{
key->clear();
}
void KStore::OnodeHashLRU::rename(const ghobject_t& old_oid,
- const ghobject_t& new_oid)
+ const ghobject_t& new_oid)
{
std::lock_guard<std::mutex> l(lock);
dout(30) << __func__ << " " << old_oid << " -> " << new_oid << dendl;
OnodeRef o = po->second;
// install a non-existent onode it its place
- po->second.reset(new Onode(old_oid, o->key));
+ po->second.reset(new Onode(cct, old_oid, o->key));
lru.push_back(*po->second);
// fix oid, key
onode_map.insert(make_pair(new_oid, o));
_touch(o);
o->oid = new_oid;
- get_object_key(new_oid, &o->key);
+ get_object_key(cct, new_oid, &o->key);
}
bool KStore::OnodeHashLRU::get_next(
: store(ns),
cid(c),
lock("KStore::Collection::lock", true, false),
- onode_map()
+ onode_map(store->cct)
{
}
spg_t pgid;
if (cid.is_pg(&pgid)) {
if (!oid.match(cnode.bits, pgid.ps())) {
- derr << __func__ << " oid " << oid << " not part of " << pgid
- << " bits " << cnode.bits << dendl;
+ lderr(store->cct) << __func__ << " oid " << oid << " not part of "
+ << pgid << " bits " << cnode.bits << dendl;
ceph_abort();
}
}
return o;
string key;
- get_object_key(oid, &key);
+ get_object_key(store->cct, oid, &key);
- dout(20) << __func__ << " oid " << oid << " key "
- << pretty_binary_string(key) << dendl;
+ ldout(store->cct, 20) << __func__ << " oid " << oid << " key "
+ << pretty_binary_string(key) << dendl;
bufferlist v;
int r = store->db->get(PREFIX_OBJ, key, &v);
- dout(20) << " r " << r << " v.len " << v.length() << dendl;
+ ldout(store->cct, 20) << " r " << r << " v.len " << v.length() << dendl;
Onode *on;
if (v.length() == 0) {
assert(r == -ENOENT);
return OnodeRef();
// new
- on = new Onode(oid, key);
+ on = new Onode(store->cct, oid, key);
on->dirty = true;
} else {
// loaded
assert(r >=0);
- on = new Onode(oid, key);
+ on = new Onode(store->cct, oid, key);
on->exists = true;
bufferlist::iterator p = v.begin();
::decode(on->onode, p);
void KStore::_init_logger()
{
// XXX
- PerfCountersBuilder b(g_ceph_context, "KStore",
+ PerfCountersBuilder b(cct, "KStore",
l_kstore_first, l_kstore_last);
b.add_time_avg(l_kstore_state_prepare_lat, "state_prepare_lat", "Average prepare state latency");
b.add_time_avg(l_kstore_state_kv_queued_lat, "state_kv_queued_lat", "Average kv_queued state latency");
b.add_time_avg(l_kstore_state_finishing_lat, "state_finishing_lat", "Average finishing state latency");
b.add_time_avg(l_kstore_state_done_lat, "state_done_lat", "Average done state latency");
logger = b.create_perf_counters();
- g_ceph_context->get_perfcounters_collection()->add(logger);
+ cct->get_perfcounters_collection()->add(logger);
}
void KStore::_shutdown_logger()
{
// XXX
- g_ceph_context->get_perfcounters_collection()->remove(logger);
+ cct->get_perfcounters_collection()->remove(logger);
delete logger;
}
string kv_backend;
if (create) {
- kv_backend = g_conf->kstore_backend;
+ kv_backend = cct->_conf->kstore_backend;
} else {
r = read_meta("kv_backend", &kv_backend);
if (r < 0) {
}
}
- db = KeyValueDB::create(g_ceph_context,
- kv_backend,
- fn);
+ db = KeyValueDB::create(cct, kv_backend, fn);
if (!db) {
derr << __func__ << " error creating db" << dendl;
return -EIO;
}
string options;
if (kv_backend == "rocksdb")
- options = g_conf->kstore_rocksdb_options;
+ options = cct->_conf->kstore_rocksdb_options;
db->init(options);
stringstream err;
if (create)
if (r < 0)
goto out_close_fsid;
- r = write_meta("kv_backend", g_conf->kstore_backend);
+ r = write_meta("kv_backend", cct->_conf->kstore_backend);
if (r < 0)
goto out_close_db;
{
dout(1) << __func__ << " path " << path << dendl;
- if (g_conf->kstore_fsck_on_mount) {
- int rc = fsck(g_conf->kstore_fsck_on_mount_deep);
+ if (cct->_conf->kstore_fsck_on_mount) {
+ int rc = fsck(cct->_conf->kstore_fsck_on_mount_deep);
if (rc < 0)
return rc;
}
temp = true;
} else {
string k;
- get_object_key(start, &k);
+ get_object_key(cct, start, &k);
if (start.hobj.is_temp()) {
temp = true;
assert(k >= temp_start_key && k < temp_end_key);
if (end.hobj.is_max()) {
pend = temp ? temp_end_key : end_key;
} else {
- get_object_key(end, &end_key);
+ get_object_key(cct, end, &end_key);
if (end.hobj.is_temp()) {
if (temp)
pend = end_key;
o->onode.nid = ++nid_last;
dout(20) << __func__ << " " << o->oid << " nid " << o->onode.nid << dendl;
if (nid_last > nid_max) {
- nid_max += g_conf->kstore_nid_prealloc;
+ nid_max += cct->_conf->kstore_nid_prealloc;
bufferlist bl;
::encode(nid_max, bl);
txc->t->set(PREFIX_SUPER, "nid_max", bl);
case TransContext::STATE_PREPARE:
txc->log_state_latency(logger, l_kstore_state_prepare_lat);
txc->state = TransContext::STATE_KV_QUEUED;
- if (!g_conf->kstore_sync_transaction) {
+ if (!cct->_conf->kstore_sync_transaction) {
std::lock_guard<std::mutex> l(kv_lock);
- if (g_conf->kstore_sync_submit_transaction) {
+ if (cct->_conf->kstore_sync_submit_transaction) {
int r = db->submit_transaction(txc->t);
assert(r == 0);
}
}
if (txc->first_collection) {
- txc->first_collection->onode_map.trim(g_conf->kstore_onode_map_size);
+ txc->first_collection->onode_map.trim(cct->_conf->kstore_onode_map_size);
}
osr->q.pop_front();
// one transaction to force a sync
KeyValueDB::Transaction t = db->get_transaction();
- if (!g_conf->kstore_sync_submit_transaction) {
+ if (!cct->_conf->kstore_sync_submit_transaction) {
for (std::deque<TransContext *>::iterator it = kv_committing.begin();
it != kv_committing.end();
++it) {
uint64_t stripe_size = o->onode.stripe_size;
if (!stripe_size) {
- o->onode.stripe_size = g_conf->kstore_default_stripe_size;
+ o->onode.stripe_size = cct->_conf->kstore_default_stripe_size;
stripe_size = o->onode.stripe_size;
}
o->exists = false;
o->onode = kstore_onode_t();
txc->onodes.erase(o);
- get_object_key(o->oid, &key);
+ get_object_key(cct, o->oid, &key);
txc->t->rmkey(PREFIX_OBJ, key);
return 0;
}