: store(ns),
cid(c),
lock("BlueStore::Collection::lock"),
+ exists(true),
onode_map(),
enode_set(g_conf->bluestore_onode_map_size)
{
// ---------------
// read operations
+ObjectStore::CollectionHandle BlueStore::open_collection(const coll_t& cid)
+{
+ return _get_collection(cid);
+}
+
bool BlueStore::exists(coll_t cid, const ghobject_t& oid)
{
dout(10) << __func__ << " " << cid << " " << oid << dendl;
r = -EEXIST;
goto out;
}
+ assert((*c)->exists);
c->reset(new Collection(this, cid));
(*c)->cnode.bits = bits;
coll_map[cid] = *c;
}
int BlueStore::_remove_collection(TransContext *txc, coll_t cid,
- CollectionRef *c)
+ CollectionRef *c)
{
dout(15) << __func__ << " " << cid << dendl;
int r;
r = -ENOENT;
goto out;
}
+ assert((*c)->exists);
pair<ghobject_t,OnodeRef> next;
while ((*c)->onode_map.get_next(next.first, &next)) {
if (next.second->exists) {
}
coll_map.erase(cid);
txc->removed_collections.push_back(*c);
+ (*c)->exists = false;
c->reset();
}
txc->t->rmkey(PREFIX_COLL, stringify(cid));
int trim(int max=-1);
};
- struct Collection {
+ struct Collection : public CollectionImpl {
BlueStore *store;
coll_t cid;
bluestore_cnode_t cnode;
RWLock lock;
+ bool exists;
+
// cache onodes on a per-collection basis to avoid lock
// contention.
OnodeHashLRU onode_map;
OnodeRef get_onode(const ghobject_t& oid, bool create);
EnodeRef get_enode(uint32_t hash);
+ const coll_t &get_cid() override {
+ return cid;
+ }
+
bool contains(const ghobject_t& oid) {
if (cid.is_meta())
return oid.hobj.pool == -1;
Collection(BlueStore *ns, coll_t c);
};
- typedef ceph::shared_ptr<Collection> CollectionRef;
+ typedef boost::intrusive_ptr<Collection> CollectionRef;
class OmapIteratorImpl : public ObjectMap::ObjectMapIteratorImpl {
CollectionRef c;