]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: implement open_collection
authorSage Weil <sage@redhat.com>
Mon, 18 Jan 2016 16:04:41 +0000 (11:04 -0500)
committerSage Weil <sage@redhat.com>
Wed, 27 Jan 2016 19:34:50 +0000 (14:34 -0500)
Fix up create and remove so that they poison a Collection that
gets removed.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 304a02ac936d9380526f5952f8f82794a18a8257..69ff54c9e07071ffe19325eda8a00f59fc2eb2ee 100644 (file)
@@ -634,6 +634,7 @@ BlueStore::Collection::Collection(BlueStore *ns, coll_t c)
   : store(ns),
     cid(c),
     lock("BlueStore::Collection::lock"),
+    exists(true),
     onode_map(),
     enode_set(g_conf->bluestore_onode_map_size)
 {
@@ -2329,6 +2330,11 @@ void BlueStore::_reap_collections()
 // ---------------
 // 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;
@@ -6145,6 +6151,7 @@ int BlueStore::_create_collection(
       r = -EEXIST;
       goto out;
     }
+    assert((*c)->exists);
     c->reset(new Collection(this, cid));
     (*c)->cnode.bits = bits;
     coll_map[cid] = *c;
@@ -6159,7 +6166,7 @@ int BlueStore::_create_collection(
 }
 
 int BlueStore::_remove_collection(TransContext *txc, coll_t cid,
-                                CollectionRef *c)
+                                 CollectionRef *c)
 {
   dout(15) << __func__ << " " << cid << dendl;
   int r;
@@ -6170,6 +6177,7 @@ int BlueStore::_remove_collection(TransContext *txc, coll_t cid,
       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) {
@@ -6179,6 +6187,7 @@ int BlueStore::_remove_collection(TransContext *txc, coll_t cid,
     }
     coll_map.erase(cid);
     txc->removed_collections.push_back(*c);
+    (*c)->exists = false;
     c->reset();
   }
   txc->t->rmkey(PREFIX_COLL, stringify(cid));
index cfabfe6f543c8391819affb6f8f1b0e378480604..35b44eab9a8e020cda658b6bb9e0f87c4b75c5a8 100644 (file)
@@ -166,12 +166,14 @@ public:
     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;
@@ -181,6 +183,10 @@ public:
     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;
@@ -194,7 +200,7 @@ public:
 
     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;