]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/ObjectStore: make all read operations CollectionHandle-based
authorSage Weil <sage@redhat.com>
Sat, 27 Jan 2018 03:37:56 +0000 (21:37 -0600)
committerSage Weil <sage@redhat.com>
Tue, 6 Feb 2018 20:09:27 +0000 (14:09 -0600)
Drop the coll_t shims, and convert the last few that weren't already
handle-based.

Signed-off-by: Sage Weil <sage@redhat.com>
23 files changed:
src/os/FuseStore.cc
src/os/ObjectStore.h
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/os/filestore/FileStore.cc
src/os/filestore/FileStore.h
src/os/kstore/KStore.cc
src/os/kstore/KStore.h
src/os/memstore/MemStore.cc
src/os/memstore/MemStore.h
src/osd/OSD.cc
src/osd/PG.cc
src/osd/PGLog.cc
src/osd/PGLog.h
src/osd/PrimaryLogPG.cc
src/osd/ReplicatedBackend.cc
src/osd/SnapMapper.cc
src/osd/SnapMapper.h
src/test/objectstore/store_test.cc
src/test/objectstore/test_memstore_clone.cc
src/test/osd/TestPGLog.cc
src/tools/ceph_objectstore_tool.cc
src/tools/rebuild_mondb.cc

index 48aaa4407eeb18ad213610fea750c46409c1d2de..c95b1873a3ea871f0de324fa53770f6c98a47ea5 100644 (file)
@@ -250,6 +250,8 @@ static int os_getattr(const char *path, struct stat *stbuf)
   stbuf->st_gid = 0;
   stbuf->st_mode = S_IFREG | 0700;
 
+  auto ch = fs->store->open_collection(cid);
+
   switch (t) {
   case FN_OBJECT_OMAP:
   case FN_OBJECT_ATTR:
@@ -260,7 +262,10 @@ static int os_getattr(const char *path, struct stat *stbuf)
     {
       spg_t pgid;
       if (cid.is_pg(&pgid)) {
-       int bits = fs->store->collection_bits(cid);
+       if (!ch) {
+         return -ENOENT;
+       }
+       int bits = fs->store->collection_bits(ch);
        if (bits >= 0 && !oid.match(bits, pgid.ps())) {
          // sorry, not part of this PG
          return -ENOENT;
@@ -274,7 +279,7 @@ static int os_getattr(const char *path, struct stat *stbuf)
   case FN_OBJECT_OMAP:
   case FN_OBJECT_ATTR:
   case FN_OBJECT:
-    if (!fs->store->exists(cid, oid))
+    if (!fs->store->exists(ch, oid))
       return -ENOENT;
     // fall-thru
   case FN_ALL:
@@ -293,15 +298,15 @@ static int os_getattr(const char *path, struct stat *stbuf)
     break;
 
   case FN_OBJECT_HASH:
-    if (!fs->store->exists(cid, oid))
+    if (!fs->store->exists(ch, oid))
       return -ENOENT;
     stbuf->st_size = 9;
     return 0;
 
   case FN_HASH_END:
-    if (!fs->store->collection_exists(cid))
+    if (!ch)
       return -ENOENT;
-    if (fs->store->collection_bits(cid) < 0)
+    if (fs->store->collection_bits(ch) < 0)
       return -ENOENT;
     // fall-thru
   case FN_HASH_START:
@@ -310,9 +315,9 @@ static int os_getattr(const char *path, struct stat *stbuf)
 
   case FN_HASH_BITS:
     {
-      if (!fs->store->collection_exists(cid))
+      if (!ch)
        return -ENOENT;
-      int bits = fs->store->collection_bits(cid);
+      int bits = fs->store->collection_bits(ch);
       if (bits < 0)
        return -ENOENT;
       char buf[8];
@@ -323,9 +328,9 @@ static int os_getattr(const char *path, struct stat *stbuf)
 
   case FN_OBJECT_DATA:
     {
-      if (!fs->store->exists(cid, oid))
+      if (!fs->store->exists(ch, oid))
        return -ENOENT;
-      int r = fs->store->stat(cid, oid, stbuf);
+      int r = fs->store->stat(ch, oid, stbuf);
       if (r < 0)
        return r;
     }
@@ -333,22 +338,22 @@ static int os_getattr(const char *path, struct stat *stbuf)
 
   case FN_OBJECT_OMAP_HEADER:
     {
-      if (!fs->store->exists(cid, oid))
+      if (!fs->store->exists(ch, oid))
        return -ENOENT;
       bufferlist bl;
-      fs->store->omap_get_header(cid, oid, &bl);
+      fs->store->omap_get_header(ch, oid, &bl);
       stbuf->st_size = bl.length();
     }
     break;
 
   case FN_OBJECT_OMAP_VAL:
     {
-      if (!fs->store->exists(cid, oid))
+      if (!fs->store->exists(ch, oid))
        return -ENOENT;
       set<string> k;
       k.insert(key);
       map<string,bufferlist> v;
-      fs->store->omap_get_values(cid, oid, k, &v);
+      fs->store->omap_get_values(ch, oid, k, &v);
       if (!v.count(key)) {
        return -ENOENT;
       }
@@ -358,10 +363,10 @@ static int os_getattr(const char *path, struct stat *stbuf)
 
   case FN_OBJECT_ATTR_VAL:
     {
-      if (!fs->store->exists(cid, oid))
+      if (!fs->store->exists(ch, oid))
        return -ENOENT;
       bufferptr v;
-      int r = fs->store->getattr(cid, oid, key.c_str(), v);
+      int r = fs->store->getattr(ch, oid, key.c_str(), v);
       if (r == -ENODATA)
        r = -ENOENT;
       if (r < 0)
@@ -398,6 +403,8 @@ static int os_readdir(const char *path,
 
   std::lock_guard<std::mutex> l(fs->lock);
 
+  auto ch = fs->store->open_collection(cid);
+
   // we can't shift 32 bits or else off_t will go negative
   const int hash_shift = 31;
 
@@ -417,8 +424,11 @@ static int os_readdir(const char *path,
 
   case FN_COLLECTION:
     {
+      if (!ch) {
+       return -ENOENT;
+      }
       filler(buf, "bitwise_hash_start", NULL, 0);
-      if (fs->store->collection_bits(cid) >= 0) {
+      if (fs->store->collection_bits(ch) >= 0) {
        filler(buf, "bitwise_hash_end", NULL, 0);
        filler(buf, "bitwise_hash_bits", NULL, 0);
       }
@@ -426,7 +436,7 @@ static int os_readdir(const char *path,
       filler(buf, "by_bitwise_hash", NULL, 0);
       spg_t pgid;
       if (cid.is_pg(&pgid) &&
-         fs->store->exists(cid, pgid.make_pgmeta_oid())) {
+         fs->store->exists(ch, pgid.make_pgmeta_oid())) {
        filler(buf, "pgmeta", NULL, 0);
       }
     }
@@ -476,7 +486,7 @@ static int os_readdir(const char *path,
       while (true) {
        vector<ghobject_t> ls;
        int r = fs->store->collection_list(
-         cid, next, last, 1000, &ls, &next);
+         ch, next, last, 1000, &ls, &next);
        if (r < 0)
          return r;
        for (auto p : ls) {
@@ -508,7 +518,7 @@ static int os_readdir(const char *path,
   case FN_OBJECT_OMAP:
     {
       set<string> keys;
-      fs->store->omap_get_keys(cid, oid, &keys);
+      fs->store->omap_get_keys(ch, oid, &keys);
       unsigned skip = offset;
       for (auto k : keys) {
        if (skip) {
@@ -526,7 +536,7 @@ static int os_readdir(const char *path,
   case FN_OBJECT_ATTR:
     {
       map<string,bufferptr> aset;
-      fs->store->getattrs(cid, oid, aset);
+      fs->store->getattrs(ch, oid, aset);
       unsigned skip = offset;
       for (auto a : aset) {
        if (skip) {
@@ -560,6 +570,8 @@ static int os_open(const char *path, struct fuse_file_info *fi)
 
   std::lock_guard<std::mutex> l(fs->lock);
 
+  auto ch = fs->store->open_collection(cid);
+
   bufferlist *pbl = 0;
   switch (t) {
   case FN_TYPE:
@@ -586,10 +598,13 @@ static int os_open(const char *path, struct fuse_file_info *fi)
 
   case FN_HASH_END:
     {
+      if (!ch) {
+       return -ENOENT;
+      }
       spg_t pgid;
       unsigned long h;
       if (cid.is_pg(&pgid)) {
-       int hash_bits = fs->store->collection_bits(cid);
+       int hash_bits = fs->store->collection_bits(ch);
        if (hash_bits >= 0) {
          uint64_t rev_start = hobject_t::_reverse_bits(pgid.ps());
          uint64_t rev_end = (rev_start | (0xffffffff >> hash_bits));
@@ -609,7 +624,10 @@ static int os_open(const char *path, struct fuse_file_info *fi)
 
   case FN_HASH_BITS:
     {
-      int r = fs->store->collection_bits(cid);
+      if (!ch) {
+       return -ENOENT;
+      }
+      int r = fs->store->collection_bits(ch);
       if (r < 0)
         return r;
       char buf[8];
@@ -634,7 +652,7 @@ static int os_open(const char *path, struct fuse_file_info *fi)
       int r = fs->open_file(
        path, fi,
        [&](bufferlist *pbl) {
-         return fs->store->read(cid, oid, 0, 0, *pbl);
+         return fs->store->read(ch, oid, 0, 0, *pbl);
        });
       if (r < 0) {
         return r;
@@ -648,7 +666,7 @@ static int os_open(const char *path, struct fuse_file_info *fi)
        path, fi,
        [&](bufferlist *pbl) {
          bufferptr bp;
-         int r = fs->store->getattr(cid, oid, key.c_str(), bp);
+         int r = fs->store->getattr(ch, oid, key.c_str(), bp);
          if (r < 0)
            return r;
          pbl->append(bp);
@@ -667,7 +685,7 @@ static int os_open(const char *path, struct fuse_file_info *fi)
          set<string> k;
          k.insert(key);
          map<string,bufferlist> v;
-         int r = fs->store->omap_get_values(cid, oid, k, &v);
+         int r = fs->store->omap_get_values(ch, oid, k, &v);
          if (r < 0)
            return r;
          *pbl = v[key];
@@ -683,7 +701,7 @@ static int os_open(const char *path, struct fuse_file_info *fi)
       int r = fs->open_file(
        path, fi,
        [&](bufferlist *pbl) {
-         return fs->store->omap_get_header(cid, oid, pbl);
+         return fs->store->omap_get_header(ch, oid, pbl);
        });
       if (r < 0)
        return r;
@@ -721,9 +739,13 @@ static int os_mkdir(const char *path, mode_t mode)
   switch (f) {
   case FN_OBJECT:
     {
+      ch = fs->store->open_collection(cid);
+      if (!ch) {
+       return -ENOENT;
+      }
       spg_t pgid;
       if (cid.is_pg(&pgid)) {
-       int bits = fs->store->collection_bits(cid);
+       int bits = fs->store->collection_bits(ch);
        if (bits >= 0 && !oid.match(bits, pgid.ps())) {
          // sorry, not part of this PG
          return -EINVAL;
@@ -745,8 +767,7 @@ static int os_mkdir(const char *path, mode_t mode)
       mode = 0;
     }
     t.create_collection(cid, mode);
-
-    ch = fs->store->open_collection(coll_t::meta());
+    ch = fs->store->create_new_collection(cid);
     break;
 
   default:
@@ -795,7 +816,7 @@ static int os_create(const char *path, mode_t mode, struct fuse_file_info *fi)
   case FN_OBJECT_DATA:
     {
       pbl = new bufferlist;
-      fs->store->read(cid, oid, 0, 0, *pbl);
+      fs->store->read(ch, oid, 0, 0, *pbl);
     }
     break;
 
@@ -803,7 +824,7 @@ static int os_create(const char *path, mode_t mode, struct fuse_file_info *fi)
     {
       pbl = new bufferlist;
       bufferptr bp;
-      int r = fs->store->getattr(cid, oid, key.c_str(), bp);
+      int r = fs->store->getattr(ch, oid, key.c_str(), bp);
       if (r == -ENODATA) {
        bufferlist empty;
        t.setattr(cid, oid, key.c_str(), empty);
@@ -818,7 +839,7 @@ static int os_create(const char *path, mode_t mode, struct fuse_file_info *fi)
       set<string> k;
       k.insert(key);
       map<string,bufferlist> v;
-      fs->store->omap_get_values(cid, oid, k, &v);
+      fs->store->omap_get_values(ch, oid, k, &v);
       if (v.count(key) == 0) {
        map<string,bufferlist> aset;
        aset[key] = bufferlist();
@@ -990,7 +1011,7 @@ static int os_unlink(const char *path)
 
   std::lock_guard<std::mutex> l(fs->lock);
 
-  ObjectStore::CollectionHandle ch;
+  ObjectStore::CollectionHandle ch = fs->store->open_collection(cid);
   ObjectStore::Transaction t;
 
   switch (f) {
@@ -1024,7 +1045,7 @@ static int os_unlink(const char *path)
   case FN_COLLECTION:
     {
       bool empty;
-      int r = fs->store->collection_empty(cid, &empty);
+      int r = fs->store->collection_empty(ch, &empty);
       if (r < 0)
         return r;
       if (!empty)
index e9f8713c2a979b1e5c188de66fd82ee89a25a6a9..7f841e88230261e62fa17207967d500a619c1706 100644 (file)
@@ -1655,10 +1655,7 @@ public:
    * @param oid oid of object
    * @returns true if object exists, false otherwise
    */
-  virtual bool exists(const coll_t& cid, const ghobject_t& oid) = 0; // useful?
-  virtual bool exists(CollectionHandle& c, const ghobject_t& oid) {
-    return exists(c->get_cid(), oid);
-  }
+  virtual bool exists(CollectionHandle& c, const ghobject_t& oid) = 0;
   /**
    * set_collection_opts -- set pool options for a collectioninformation for an object
    *
@@ -1667,7 +1664,7 @@ public:
    * @returns 0 on success, negative error code on failure.
    */
   virtual int set_collection_opts(
-    const coll_t& cid,
+    CollectionHandle& c,
     const pool_opts_t& opts) = 0;
 
   /**
@@ -1679,19 +1676,11 @@ public:
    * @param allow_eio if false, assert on -EIO operation failure
    * @returns 0 on success, negative error code on failure.
    */
-  virtual int stat(
-    const coll_t& cid,
-    const ghobject_t& oid,
-    struct stat *st,
-    bool allow_eio = false) = 0; // struct stat?
   virtual int stat(
     CollectionHandle &c,
     const ghobject_t& oid,
     struct stat *st,
-    bool allow_eio = false) {
-    return stat(c->get_cid(), oid, st, allow_eio);
-  }
-
+    bool allow_eio = false) = 0;
   /**
    * read -- read a byte range of data from an object
    *
@@ -1706,22 +1695,13 @@ public:
    * @param op_flags is CEPH_OSD_OP_FLAG_*
    * @returns number of bytes read on success, or negative error code on failure.
    */
-   virtual int read(
-    const coll_t& cid,
-    const ghobject_t& oid,
-    uint64_t offset,
-    size_t len,
-    bufferlist& bl,
-    uint32_t op_flags = 0) = 0;
    virtual int read(
      CollectionHandle &c,
      const ghobject_t& oid,
      uint64_t offset,
      size_t len,
      bufferlist& bl,
-     uint32_t op_flags = 0) {
-     return read(c->get_cid(), oid, offset, len, bl, op_flags);
-   }
+     uint32_t op_flags = 0) = 0;
 
   /**
    * fiemap -- get extent map of data of an object
@@ -1739,19 +1719,10 @@ public:
    * @param bl output bufferlist for extent map information.
    * @returns 0 on success, negative error code on failure.
    */
-   virtual int fiemap(const coll_t& cid, const ghobject_t& oid,
-                    uint64_t offset, size_t len, bufferlist& bl) = 0;
-   virtual int fiemap(const coll_t& cid, const ghobject_t& oid,
-                    uint64_t offset, size_t len,
-                    map<uint64_t, uint64_t>& destmap) = 0;
    virtual int fiemap(CollectionHandle& c, const ghobject_t& oid,
-                    uint64_t offset, size_t len, bufferlist& bl) {
-     return fiemap(c->get_cid(), oid, offset, len, bl);
-   }
+                     uint64_t offset, size_t len, bufferlist& bl) = 0;
    virtual int fiemap(CollectionHandle& c, const ghobject_t& oid,
-                    uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap) {
-     return fiemap(c->get_cid(), oid, offset, len, destmap);
-   }
+                     uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap) = 0;
 
   /**
    * getattr -- get an xattr of an object
@@ -1762,12 +1733,8 @@ public:
    * @param value place to put output result.
    * @returns 0 on success, negative error code on failure.
    */
-  virtual int getattr(const coll_t& cid, const ghobject_t& oid,
-                     const char *name, bufferptr& value) = 0;
   virtual int getattr(CollectionHandle &c, const ghobject_t& oid,
-                     const char *name, bufferptr& value) {
-    return getattr(c->get_cid(), oid, name, value);
-  }
+                     const char *name, bufferptr& value) = 0;
 
   /**
    * getattr -- get an xattr of an object
@@ -1778,21 +1745,6 @@ public:
    * @param value place to put output result.
    * @returns 0 on success, negative error code on failure.
    */
-  int getattr(const coll_t& cid, const ghobject_t& oid, const char *name, bufferlist& value) {
-    bufferptr bp;
-    int r = getattr(cid, oid, name, bp);
-    if (bp.length())
-      value.push_back(bp);
-    return r;
-  }
-  int getattr(
-    coll_t cid, const ghobject_t& oid,
-    const string& name, bufferlist& value) {
-    bufferptr bp;
-    int r = getattr(cid, oid, name.c_str(), bp);
-    value.push_back(bp);
-    return r;
-  }
   int getattr(
     CollectionHandle &c, const ghobject_t& oid,
     const string& name, bufferlist& value) {
@@ -1810,12 +1762,8 @@ public:
    * @param aset place to put output result.
    * @returns 0 on success, negative error code on failure.
    */
-  virtual int getattrs(const coll_t& cid, const ghobject_t& oid,
-                      map<string,bufferptr>& aset) = 0;
   virtual int getattrs(CollectionHandle &c, const ghobject_t& oid,
-                      map<string,bufferptr>& aset) {
-    return getattrs(c->get_cid(), oid, aset);
-  }
+                      map<string,bufferptr>& aset) = 0;
 
   /**
    * getattrs -- get all of the xattrs of an object
@@ -1825,16 +1773,6 @@ public:
    * @param aset place to put output result.
    * @returns 0 on success, negative error code on failure.
    */
-  int getattrs(const coll_t& cid, const ghobject_t& oid, map<string,bufferlist>& aset) {
-    map<string,bufferptr> bmap;
-    int r = getattrs(cid, oid, bmap);
-    for (map<string,bufferptr>::iterator i = bmap.begin();
-       i != bmap.end();
-       ++i) {
-      aset[i->first].append(i->second);
-    }
-    return r;
-  }
   int getattrs(CollectionHandle &c, const ghobject_t& oid,
               map<string,bufferlist>& aset) {
     map<string,bufferptr> bmap;
@@ -1873,7 +1811,7 @@ public:
    * @param empty true if the specified collection is empty, false otherwise
    * @returns 0 on success, negative error code on failure.
    */
-  virtual int collection_empty(const coll_t& c, bool *empty) = 0;
+  virtual int collection_empty(CollectionHandle& c, bool *empty) = 0;
 
   /**
    * return the number of significant bits of the coll_t::pgid.
@@ -1882,7 +1820,7 @@ public:
    * set.  A legacy backend may return -EAGAIN if the value is unavailable
    * (because we upgraded from an older version, e.g., FileStore).
    */
-  virtual int collection_bits(const coll_t& c) = 0;
+  virtual int collection_bits(CollectionHandle& c) = 0;
 
 
   /**
@@ -1897,96 +1835,51 @@ public:
    * @param next [out] next item sorts >= this value
    * @return zero on success, or negative error
    */
-  virtual int collection_list(const coll_t& c,
-                             const ghobject_t& start, const ghobject_t& end,
-                             int max,
-                             vector<ghobject_t> *ls, ghobject_t *next) = 0;
   virtual int collection_list(CollectionHandle &c,
                              const ghobject_t& start, const ghobject_t& end,
                              int max,
-                             vector<ghobject_t> *ls, ghobject_t *next) {
-    return collection_list(c->get_cid(), start, end, max, ls, next);
-  }
+                             vector<ghobject_t> *ls, ghobject_t *next) = 0;
 
 
   /// OMAP
   /// Get omap contents
-  virtual int omap_get(
-    const coll_t& c,                ///< [in] Collection containing oid
-    const ghobject_t &oid,   ///< [in] Object containing omap
-    bufferlist *header,      ///< [out] omap header
-    map<string, bufferlist> *out /// < [out] Key to value map
-    ) = 0;
   virtual int omap_get(
     CollectionHandle &c,     ///< [in] Collection containing oid
     const ghobject_t &oid,   ///< [in] Object containing omap
     bufferlist *header,      ///< [out] omap header
     map<string, bufferlist> *out /// < [out] Key to value map
-    ) {
-    return omap_get(c->get_cid(), oid, header, out);
-  }
+    ) = 0;
 
   /// Get omap header
-  virtual int omap_get_header(
-    const coll_t& c,                ///< [in] Collection containing oid
-    const ghobject_t &oid,   ///< [in] Object containing omap
-    bufferlist *header,      ///< [out] omap header
-    bool allow_eio = false ///< [in] don't assert on eio
-    ) = 0;
   virtual int omap_get_header(
     CollectionHandle &c,     ///< [in] Collection containing oid
     const ghobject_t &oid,   ///< [in] Object containing omap
     bufferlist *header,      ///< [out] omap header
     bool allow_eio = false ///< [in] don't assert on eio
-    ) {
-    return omap_get_header(c->get_cid(), oid, header, allow_eio);
-  }
+    ) = 0;
 
   /// Get keys defined on oid
-  virtual int omap_get_keys(
-    const coll_t& c,              ///< [in] Collection containing oid
-    const ghobject_t &oid, ///< [in] Object containing omap
-    set<string> *keys      ///< [out] Keys defined on oid
-    ) = 0;
   virtual int omap_get_keys(
     CollectionHandle &c,   ///< [in] Collection containing oid
     const ghobject_t &oid, ///< [in] Object containing omap
     set<string> *keys      ///< [out] Keys defined on oid
-    ) {
-    return omap_get_keys(c->get_cid(), oid, keys);
-  }
+    ) = 0;
 
   /// Get key values
-  virtual int omap_get_values(
-    const coll_t& c,                    ///< [in] Collection containing oid
-    const ghobject_t &oid,       ///< [in] Object containing omap
-    const set<string> &keys,     ///< [in] Keys to get
-    map<string, bufferlist> *out ///< [out] Returned keys and values
-    ) = 0;
   virtual int omap_get_values(
     CollectionHandle &c,         ///< [in] Collection containing oid
     const ghobject_t &oid,       ///< [in] Object containing omap
     const set<string> &keys,     ///< [in] Keys to get
     map<string, bufferlist> *out ///< [out] Returned keys and values
-    ) {
-    return omap_get_values(c->get_cid(), oid, keys, out);
-  }
+    ) = 0;
 
   /// Filters keys into out which are defined on oid
-  virtual int omap_check_keys(
-    const coll_t& c,                ///< [in] Collection containing oid
-    const ghobject_t &oid,   ///< [in] Object containing omap
-    const set<string> &keys, ///< [in] Keys to check
-    set<string> *out         ///< [out] Subset of keys defined on oid
-    ) = 0;
   virtual int omap_check_keys(
     CollectionHandle &c,     ///< [in] Collection containing oid
     const ghobject_t &oid,   ///< [in] Object containing omap
     const set<string> &keys, ///< [in] Keys to check
     set<string> *out         ///< [out] Subset of keys defined on oid
-    ) {
-    return omap_check_keys(c->get_cid(), oid, keys, out);
-  }
+    ) = 0;
 
   /**
    * Returns an object map iterator
@@ -1997,16 +1890,10 @@ public:
    *
    * @return iterator, null on error
    */
-  virtual ObjectMap::ObjectMapIterator get_omap_iterator(
-    const coll_t& c,              ///< [in] collection
-    const ghobject_t &oid  ///< [in] object
-    ) = 0;
   virtual ObjectMap::ObjectMapIterator get_omap_iterator(
     CollectionHandle &c,   ///< [in] collection
     const ghobject_t &oid  ///< [in] object
-    ) {
-    return get_omap_iterator(c->get_cid(), oid);
-  }
+    ) = 0;
 
   virtual int flush_journal() { return -EOPNOTSUPP; }
 
index d2f5206082821cec42a534b5babf834fe900d21c..6c9815ae0912e5e2427ef195b0a7f731a19f2b1a 100644 (file)
@@ -6516,14 +6516,6 @@ ObjectStore::CollectionHandle BlueStore::create_new_collection(
   return c;
 }
 
-bool BlueStore::exists(const coll_t& cid, const ghobject_t& oid)
-{
-  CollectionHandle c = _get_collection(cid);
-  if (!c)
-    return false;
-  return exists(c, oid);
-}
-
 bool BlueStore::exists(CollectionHandle &c_, const ghobject_t& oid)
 {
   Collection *c = static_cast<Collection *>(c_.get());
@@ -6543,18 +6535,6 @@ bool BlueStore::exists(CollectionHandle &c_, const ghobject_t& oid)
   return r;
 }
 
-int BlueStore::stat(
-    const coll_t& cid,
-    const ghobject_t& oid,
-    struct stat *st,
-    bool allow_eio)
-{
-  CollectionHandle c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
-  return stat(c, oid, st, allow_eio);
-}
-
 int BlueStore::stat(
   CollectionHandle &c_,
   const ghobject_t& oid,
@@ -6585,14 +6565,11 @@ int BlueStore::stat(
   return r;
 }
 int BlueStore::set_collection_opts(
-  const coll_t& cid,
+  CollectionHandle& ch,
   const pool_opts_t& opts)
 {
-  CollectionHandle ch = _get_collection(cid);
-  if (!ch)
-    return -ENOENT;
   Collection *c = static_cast<Collection *>(ch.get());
-  dout(15) << __func__ << " " << cid << " options " << opts << dendl;
+  dout(15) << __func__ << " " << ch->cid << " options " << opts << dendl;
   if (!c->exists)
     return -ENOENT;
   RWLock::WLocker l(c->lock);
@@ -6600,20 +6577,6 @@ int BlueStore::set_collection_opts(
   return 0;
 }
 
-int BlueStore::read(
-  const coll_t& cid,
-  const ghobject_t& oid,
-  uint64_t offset,
-  size_t length,
-  bufferlist& bl,
-  uint32_t op_flags)
-{
-  CollectionHandle c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
-  return read(c, oid, offset, length, bl, op_flags);
-}
-
 int BlueStore::read(
   CollectionHandle &c_,
   const ghobject_t& oid,
@@ -7120,19 +7083,6 @@ int BlueStore::_fiemap(
   return 0;
 }
 
-int BlueStore::fiemap(
-  const coll_t& cid,
-  const ghobject_t& oid,
-  uint64_t offset,
-  size_t len,
-  bufferlist& bl)
-{
-  CollectionHandle c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
-  return fiemap(c, oid, offset, len, bl);
-}
-
 int BlueStore::fiemap(
   CollectionHandle &c_,
   const ghobject_t& oid,
@@ -7148,19 +7098,6 @@ int BlueStore::fiemap(
   return r;
 }
 
-int BlueStore::fiemap(
-  const coll_t& cid,
-  const ghobject_t& oid,
-  uint64_t offset,
-  size_t len,
-  map<uint64_t, uint64_t>& destmap)
-{
-  CollectionHandle c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
-  return fiemap(c, oid, offset, len, destmap);
-}
-
 int BlueStore::fiemap(
   CollectionHandle &c_,
   const ghobject_t& oid,
@@ -7176,18 +7113,6 @@ int BlueStore::fiemap(
   return r;
 }
 
-int BlueStore::getattr(
-  const coll_t& cid,
-  const ghobject_t& oid,
-  const char *name,
-  bufferptr& value)
-{
-  CollectionHandle c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
-  return getattr(c, oid, name, value);
-}
-
 int BlueStore::getattr(
   CollectionHandle &c_,
   const ghobject_t& oid,
@@ -7227,18 +7152,6 @@ int BlueStore::getattr(
   return r;
 }
 
-
-int BlueStore::getattrs(
-  const coll_t& cid,
-  const ghobject_t& oid,
-  map<string,bufferptr>& aset)
-{
-  CollectionHandle c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
-  return getattrs(c, oid, aset);
-}
-
 int BlueStore::getattrs(
   CollectionHandle &c_,
   const ghobject_t& oid,
@@ -7290,12 +7203,12 @@ bool BlueStore::collection_exists(const coll_t& c)
   return coll_map.count(c);
 }
 
-int BlueStore::collection_empty(const coll_t& cid, bool *empty)
+int BlueStore::collection_empty(CollectionHandle& ch, bool *empty)
 {
-  dout(15) << __func__ << " " << cid << dendl;
+  dout(15) << __func__ << " " << ch->cid << dendl;
   vector<ghobject_t> ls;
   ghobject_t next;
-  int r = collection_list(cid, ghobject_t(), ghobject_t::get_max(), 1,
+  int r = collection_list(ch, ghobject_t(), ghobject_t::get_max(), 1,
                          &ls, &next);
   if (r < 0) {
     derr << __func__ << " collection_list returned: " << cpp_strerror(r)
@@ -7303,31 +7216,19 @@ int BlueStore::collection_empty(const coll_t& cid, bool *empty)
     return r;
   }
   *empty = ls.empty();
-  dout(10) << __func__ << " " << cid << " = " << (int)(*empty) << dendl;
+  dout(10) << __func__ << " " << ch->cid << " = " << (int)(*empty) << dendl;
   return 0;
 }
 
-int BlueStore::collection_bits(const coll_t& cid)
+int BlueStore::collection_bits(CollectionHandle& ch)
 {
-  dout(15) << __func__ << " " << cid << dendl;
-  CollectionRef c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
+  dout(15) << __func__ << " " << ch->cid << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
   RWLock::RLocker l(c->lock);
-  dout(10) << __func__ << " " << cid << " = " << c->cnode.bits << dendl;
+  dout(10) << __func__ << " " << ch->cid << " = " << c->cnode.bits << dendl;
   return c->cnode.bits;
 }
 
-int BlueStore::collection_list(
-  const coll_t& cid, const ghobject_t& start, const ghobject_t& end, int max,
-  vector<ghobject_t> *ls, ghobject_t *pnext)
-{
-  CollectionHandle c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
-  return collection_list(c, start, end, max, ls, pnext);
-}
-
 int BlueStore::collection_list(
   CollectionHandle &c_, const ghobject_t& start, const ghobject_t& end, int max,
   vector<ghobject_t> *ls, ghobject_t *pnext)
@@ -7459,19 +7360,6 @@ out:
   return r;
 }
 
-int BlueStore::omap_get(
-  const coll_t& cid,                ///< [in] Collection containing oid
-  const ghobject_t &oid,   ///< [in] Object containing omap
-  bufferlist *header,      ///< [out] omap header
-  map<string, bufferlist> *out /// < [out] Key to value map
-  )
-{
-  CollectionHandle c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
-  return omap_get(c, oid, header, out);
-}
-
 int BlueStore::omap_get(
   CollectionHandle &c_,    ///< [in] Collection containing oid
   const ghobject_t &oid,   ///< [in] Object containing omap
@@ -7524,19 +7412,6 @@ int BlueStore::omap_get(
   return r;
 }
 
-int BlueStore::omap_get_header(
-  const coll_t& cid,                ///< [in] Collection containing oid
-  const ghobject_t &oid,   ///< [in] Object containing omap
-  bufferlist *header,      ///< [out] omap header
-  bool allow_eio ///< [in] don't assert on eio
-  )
-{
-  CollectionHandle c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
-  return omap_get_header(c, oid, header, allow_eio);
-}
-
 int BlueStore::omap_get_header(
   CollectionHandle &c_,                ///< [in] Collection containing oid
   const ghobject_t &oid,   ///< [in] Object containing omap
@@ -7574,18 +7449,6 @@ int BlueStore::omap_get_header(
   return r;
 }
 
-int BlueStore::omap_get_keys(
-  const coll_t& cid,              ///< [in] Collection containing oid
-  const ghobject_t &oid, ///< [in] Object containing omap
-  set<string> *keys      ///< [out] Keys defined on oid
-  )
-{
-  CollectionHandle c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
-  return omap_get_keys(c, oid, keys);
-}
-
 int BlueStore::omap_get_keys(
   CollectionHandle &c_,              ///< [in] Collection containing oid
   const ghobject_t &oid, ///< [in] Object containing omap
@@ -7633,19 +7496,6 @@ int BlueStore::omap_get_keys(
   return r;
 }
 
-int BlueStore::omap_get_values(
-  const coll_t& cid,                    ///< [in] Collection containing oid
-  const ghobject_t &oid,       ///< [in] Object containing omap
-  const set<string> &keys,     ///< [in] Keys to get
-  map<string, bufferlist> *out ///< [out] Returned keys and values
-  )
-{
-  CollectionHandle c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
-  return omap_get_values(c, oid, keys, out);
-}
-
 int BlueStore::omap_get_values(
   CollectionHandle &c_,        ///< [in] Collection containing oid
   const ghobject_t &oid,       ///< [in] Object containing omap
@@ -7690,19 +7540,6 @@ int BlueStore::omap_get_values(
   return r;
 }
 
-int BlueStore::omap_check_keys(
-  const coll_t& cid,                ///< [in] Collection containing oid
-  const ghobject_t &oid,   ///< [in] Object containing omap
-  const set<string> &keys, ///< [in] Keys to check
-  set<string> *out         ///< [out] Subset of keys defined on oid
-  )
-{
-  CollectionHandle c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
-  return omap_check_keys(c, oid, keys, out);
-}
-
 int BlueStore::omap_check_keys(
   CollectionHandle &c_,    ///< [in] Collection containing oid
   const ghobject_t &oid,   ///< [in] Object containing omap
@@ -7750,19 +7587,6 @@ int BlueStore::omap_check_keys(
   return r;
 }
 
-ObjectMap::ObjectMapIterator BlueStore::get_omap_iterator(
-  const coll_t& cid,              ///< [in] collection
-  const ghobject_t &oid  ///< [in] object
-  )
-{
-  CollectionHandle c = _get_collection(cid);
-  if (!c) {
-    dout(10) << __func__ << " " << cid << "doesn't exist" <<dendl;
-    return ObjectMap::ObjectMapIterator();
-  }
-  return get_omap_iterator(c, oid);
-}
-
 ObjectMap::ObjectMapIterator BlueStore::get_omap_iterator(
   CollectionHandle &c_,              ///< [in] collection
   const ghobject_t &oid  ///< [in] object
index 0d35849c58d28b32a0bf70c5cdea87ed2b84ffde..9abec3f83e1835f47ce5820c0ac8287cda7de9ba 100644 (file)
@@ -2184,28 +2184,15 @@ public:
 
   void collect_metadata(map<string,string> *pm) override;
 
-  bool exists(const coll_t& cid, const ghobject_t& oid) override;
   bool exists(CollectionHandle &c, const ghobject_t& oid) override;
   int set_collection_opts(
-    const coll_t& cid,
+    CollectionHandle& c,
     const pool_opts_t& opts) override;
-  int stat(
-    const coll_t& cid,
-    const ghobject_t& oid,
-    struct stat *st,
-    bool allow_eio = false) override;
   int stat(
     CollectionHandle &c,
     const ghobject_t& oid,
     struct stat *st,
     bool allow_eio = false) override;
-  int read(
-    const coll_t& cid,
-    const ghobject_t& oid,
-    uint64_t offset,
-    size_t len,
-    bufferlist& bl,
-    uint32_t op_flags = 0) override;
   int read(
     CollectionHandle &c,
     const ghobject_t& oid,
@@ -2225,23 +2212,15 @@ private:
   int _fiemap(CollectionHandle &c_, const ghobject_t& oid,
             uint64_t offset, size_t len, interval_set<uint64_t>& destset);
 public:
-  int fiemap(const coll_t& cid, const ghobject_t& oid,
-            uint64_t offset, size_t len, bufferlist& bl) override;
   int fiemap(CollectionHandle &c, const ghobject_t& oid,
             uint64_t offset, size_t len, bufferlist& bl) override;
-  int fiemap(const coll_t& cid, const ghobject_t& oid,
-            uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap) override;
   int fiemap(CollectionHandle &c, const ghobject_t& oid,
             uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap) override;
 
 
-  int getattr(const coll_t& cid, const ghobject_t& oid, const char *name,
-             bufferptr& value) override;
   int getattr(CollectionHandle &c, const ghobject_t& oid, const char *name,
              bufferptr& value) override;
 
-  int getattrs(const coll_t& cid, const ghobject_t& oid,
-              map<string,bufferptr>& aset) override;
   int getattrs(CollectionHandle &c, const ghobject_t& oid,
               map<string,bufferptr>& aset) override;
 
@@ -2251,26 +2230,15 @@ public:
   CollectionHandle create_new_collection(const coll_t& cid) override;
 
   bool collection_exists(const coll_t& c) override;
-  int collection_empty(const coll_t& c, bool *empty) override;
-  int collection_bits(const coll_t& c) override;
+  int collection_empty(CollectionHandle& c, bool *empty) override;
+  int collection_bits(CollectionHandle& c) override;
 
-  int collection_list(const coll_t& cid,
-                     const ghobject_t& start,
-                     const ghobject_t& end,
-                     int max,
-                     vector<ghobject_t> *ls, ghobject_t *next) override;
   int collection_list(CollectionHandle &c,
                      const ghobject_t& start,
                      const ghobject_t& end,
                      int max,
                      vector<ghobject_t> *ls, ghobject_t *next) override;
 
-  int omap_get(
-    const coll_t& cid,                ///< [in] Collection containing oid
-    const ghobject_t &oid,   ///< [in] Object containing omap
-    bufferlist *header,      ///< [out] omap header
-    map<string, bufferlist> *out /// < [out] Key to value map
-    ) override;
   int omap_get(
     CollectionHandle &c,     ///< [in] Collection containing oid
     const ghobject_t &oid,   ///< [in] Object containing omap
@@ -2279,12 +2247,6 @@ public:
     ) override;
 
   /// Get omap header
-  int omap_get_header(
-    const coll_t& cid,                ///< [in] Collection containing oid
-    const ghobject_t &oid,   ///< [in] Object containing omap
-    bufferlist *header,      ///< [out] omap header
-    bool allow_eio = false ///< [in] don't assert on eio
-    ) override;
   int omap_get_header(
     CollectionHandle &c,                ///< [in] Collection containing oid
     const ghobject_t &oid,   ///< [in] Object containing omap
@@ -2293,11 +2255,6 @@ public:
     ) override;
 
   /// Get keys defined on oid
-  int omap_get_keys(
-    const coll_t& cid,              ///< [in] Collection containing oid
-    const ghobject_t &oid, ///< [in] Object containing omap
-    set<string> *keys      ///< [out] Keys defined on oid
-    ) override;
   int omap_get_keys(
     CollectionHandle &c,              ///< [in] Collection containing oid
     const ghobject_t &oid, ///< [in] Object containing omap
@@ -2305,12 +2262,6 @@ public:
     ) override;
 
   /// Get key values
-  int omap_get_values(
-    const coll_t& cid,                    ///< [in] Collection containing oid
-    const ghobject_t &oid,       ///< [in] Object containing omap
-    const set<string> &keys,     ///< [in] Keys to get
-    map<string, bufferlist> *out ///< [out] Returned keys and values
-    ) override;
   int omap_get_values(
     CollectionHandle &c,         ///< [in] Collection containing oid
     const ghobject_t &oid,       ///< [in] Object containing omap
@@ -2319,12 +2270,6 @@ public:
     ) override;
 
   /// Filters keys into out which are defined on oid
-  int omap_check_keys(
-    const coll_t& cid,                ///< [in] Collection containing oid
-    const ghobject_t &oid,   ///< [in] Object containing omap
-    const set<string> &keys, ///< [in] Keys to check
-    set<string> *out         ///< [out] Subset of keys defined on oid
-    ) override;
   int omap_check_keys(
     CollectionHandle &c,                ///< [in] Collection containing oid
     const ghobject_t &oid,   ///< [in] Object containing omap
@@ -2332,10 +2277,6 @@ public:
     set<string> *out         ///< [out] Subset of keys defined on oid
     ) override;
 
-  ObjectMap::ObjectMapIterator get_omap_iterator(
-    const coll_t& cid,              ///< [in] collection
-    const ghobject_t &oid  ///< [in] object
-    ) override;
   ObjectMap::ObjectMapIterator get_omap_iterator(
     CollectionHandle &c,   ///< [in] collection
     const ghobject_t &oid  ///< [in] object
index c1a59f3a07f8b88f6762fbe777d97cbd2fa84a06..02494010a39fccdaccf7dd777c0fc89685f8e133 100644 (file)
@@ -3211,28 +3211,27 @@ void FileStore::_do_transaction(
 // --------------------
 // objects
 
-bool FileStore::exists(const coll_t& _cid, const ghobject_t& oid)
+bool FileStore::exists(CollectionHandle& ch, const ghobject_t& oid)
 {
-  tracepoint(objectstore, exists_enter, _cid.c_str());
-  const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp();
+  tracepoint(objectstore, exists_enter, ch->cid.c_str());
   struct stat st;
-  bool retval = stat(cid, oid, &st) == 0;
+  bool retval = stat(ch, oid, &st) == 0;
   tracepoint(objectstore, exists_exit, retval);
   return retval;
 }
 
 int FileStore::stat(
-  const coll_t& _cid, const ghobject_t& oid, struct stat *st, bool allow_eio)
+  CollectionHandle& ch, const ghobject_t& oid, struct stat *st, bool allow_eio)
 {
-  tracepoint(objectstore, stat_enter, _cid.c_str());
-  const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp();
+  tracepoint(objectstore, stat_enter, ch->cid.c_str());
+  const coll_t& cid = !_need_temp_object_collection(ch->cid, oid) ? ch->cid : ch->cid.get_temp();
   int r = lfn_stat(cid, oid, st);
   assert(allow_eio || !m_filestore_fail_eio || r != -EIO);
   if (r < 0) {
-    dout(10) << __FUNC__ << ": " << cid << "/" << oid
+    dout(10) << __FUNC__ << ": " << ch->cid << "/" << oid
             << " = " << r << dendl;
   } else {
-    dout(10) << __FUNC__ << ": " << cid << "/" << oid
+    dout(10) << __FUNC__ << ": " << ch->cid << "/" << oid
             << " = " << r
             << " (size " << st->st_size << ")" << dendl;
   }
@@ -3246,14 +3245,14 @@ int FileStore::stat(
 }
 
 int FileStore::set_collection_opts(
-  const coll_t& cid,
+  CollectionHandle& ch,
   const pool_opts_t& opts)
 {
   return -EOPNOTSUPP;
 }
 
 int FileStore::read(
-  const coll_t& _cid,
+  CollectionHandle& ch,
   const ghobject_t& oid,
   uint64_t offset,
   size_t len,
@@ -3261,8 +3260,8 @@ int FileStore::read(
   uint32_t op_flags)
 {
   int got;
-  tracepoint(objectstore, read_enter, _cid.c_str(), offset, len);
-  const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp();
+  tracepoint(objectstore, read_enter, ch->cid.c_str(), offset, len);
+  const coll_t& cid = !_need_temp_object_collection(ch->cid, oid) ? ch->cid : ch->cid.get_temp();
 
   dout(15) << __FUNC__ << ": " << cid << "/" << oid << " " << offset << "~" << len << dendl;
 
@@ -3447,24 +3446,24 @@ int FileStore::_do_seek_hole_data(int fd, uint64_t offset, size_t len,
 #endif
 }
 
-int FileStore::fiemap(const coll_t& _cid, const ghobject_t& oid,
+int FileStore::fiemap(CollectionHandle& ch, const ghobject_t& oid,
                     uint64_t offset, size_t len,
                     bufferlist& bl)
 {
   map<uint64_t, uint64_t> exomap;
-  int r = fiemap(_cid, oid, offset, len, exomap);
+  int r = fiemap(ch, oid, offset, len, exomap);
   if (r >= 0) {
     encode(exomap, bl);
   }
   return r;
 }
 
-int FileStore::fiemap(const coll_t& _cid, const ghobject_t& oid,
+int FileStore::fiemap(CollectionHandle& ch, const ghobject_t& oid,
                     uint64_t offset, size_t len,
                     map<uint64_t, uint64_t>& destmap)
 {
-  tracepoint(objectstore, fiemap_enter, _cid.c_str(), offset, len);
-  const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp();
+  tracepoint(objectstore, fiemap_enter, ch->cid.c_str(), offset, len);
+  const coll_t& cid = !_need_temp_object_collection(ch->cid, oid) ? ch->cid : ch->cid.get_temp();
   destmap.clear();
 
   if ((!backend->has_seek_data_hole() && !backend->has_fiemap()) ||
@@ -4434,10 +4433,10 @@ bool FileStore::debug_mdata_eio(const ghobject_t &oid) {
 
 // objects
 
-int FileStore::getattr(const coll_t& _cid, const ghobject_t& oid, const char *name, bufferptr &bp)
+int FileStore::getattr(CollectionHandle& ch, const ghobject_t& oid, const char *name, bufferptr &bp)
 {
-  tracepoint(objectstore, getattr_enter, _cid.c_str());
-  const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp();
+  tracepoint(objectstore, getattr_enter, ch->cid.c_str());
+  const coll_t& cid = !_need_temp_object_collection(ch->cid, oid) ? ch->cid : ch->cid.get_temp();
   dout(15) << __FUNC__ << ": " << cid << "/" << oid << " '" << name << "'" << dendl;
   FDRef fd;
   int r = lfn_open(cid, oid, false, &fd);
@@ -4483,10 +4482,10 @@ int FileStore::getattr(const coll_t& _cid, const ghobject_t& oid, const char *na
   }
 }
 
-int FileStore::getattrs(const coll_t& _cid, const ghobject_t& oid, map<string,bufferptr>& aset)
+int FileStore::getattrs(CollectionHandle& ch, const ghobject_t& oid, map<string,bufferptr>& aset)
 {
-  tracepoint(objectstore, getattrs_enter, _cid.c_str());
-  const coll_t& cid = !_need_temp_object_collection(_cid, oid) ? _cid : _cid.get_temp();
+  tracepoint(objectstore, getattrs_enter, ch->cid.c_str());
+  const coll_t& cid = !_need_temp_object_collection(ch->cid, oid) ? ch->cid : ch->cid.get_temp();
   set<string> omap_attrs;
   map<string, bufferlist> omap_aset;
   Index index;
@@ -4903,12 +4902,12 @@ bool FileStore::collection_exists(const coll_t& c)
   return ret;
 }
 
-int FileStore::collection_empty(const coll_t& c, bool *empty)
+int FileStore::collection_empty(const coll_t& cid, bool *empty)
 {
-  tracepoint(objectstore, collection_empty_enter, c.c_str());
-  dout(15) << __FUNC__ << ": " << c << dendl;
+  tracepoint(objectstore, collection_empty_enter, cid.c_str());
+  dout(15) << __FUNC__ << ": " << cid << dendl;
   Index index;
-  int r = get_index(c, &index);
+  int r = get_index(cid, &index);
   if (r < 0) {
     derr << __FUNC__ << ": get_index returned: " << cpp_strerror(r)
          << dendl;
@@ -4953,10 +4952,10 @@ int FileStore::_collection_set_bits(const coll_t& c, int bits)
   return r;
 }
 
-int FileStore::collection_bits(const coll_t& c)
+int FileStore::collection_bits(CollectionHandle& ch)
 {
   char fn[PATH_MAX];
-  get_cdir(c, fn, sizeof(fn));
+  get_cdir(ch->cid, fn, sizeof(fn));
   dout(15) << __FUNC__ << ": " << fn << dendl;
   int r;
   char n[PATH_MAX];
@@ -5061,12 +5060,12 @@ int FileStore::collection_list(const coll_t& c,
   return 0;
 }
 
-int FileStore::omap_get(const coll_t& _c, const ghobject_t &hoid,
+int FileStore::omap_get(CollectionHandle& ch, const ghobject_t &hoid,
                        bufferlist *header,
                        map<string, bufferlist> *out)
 {
-  tracepoint(objectstore, omap_get_enter, _c.c_str());
-  const coll_t& c = !_need_temp_object_collection(_c, hoid) ? _c : _c.get_temp();
+  tracepoint(objectstore, omap_get_enter, ch->cid.c_str());
+  const coll_t& c = !_need_temp_object_collection(ch->cid, hoid) ? ch->cid : ch->cid.get_temp();
   dout(15) << __FUNC__ << ": " << c << "/" << hoid << dendl;
   Index index;
   int r = get_index(c, &index);
@@ -5089,13 +5088,13 @@ int FileStore::omap_get(const coll_t& _c, const ghobject_t &hoid,
 }
 
 int FileStore::omap_get_header(
-  const coll_t& _c,
+  CollectionHandle& ch,
   const ghobject_t &hoid,
   bufferlist *bl,
   bool allow_eio)
 {
-  tracepoint(objectstore, omap_get_header_enter, _c.c_str());
-  const coll_t& c = !_need_temp_object_collection(_c, hoid) ? _c : _c.get_temp();
+  tracepoint(objectstore, omap_get_header_enter, ch->cid.c_str());
+  const coll_t& c = !_need_temp_object_collection(ch->cid, hoid) ? ch->cid : ch->cid.get_temp();
   dout(15) << __FUNC__ << ": " << c << "/" << hoid << dendl;
   Index index;
   int r = get_index(c, &index);
@@ -5117,10 +5116,10 @@ int FileStore::omap_get_header(
   return 0;
 }
 
-int FileStore::omap_get_keys(const coll_t& _c, const ghobject_t &hoid, set<string> *keys)
+int FileStore::omap_get_keys(CollectionHandle& ch, const ghobject_t &hoid, set<string> *keys)
 {
-  tracepoint(objectstore, omap_get_keys_enter, _c.c_str());
-  const coll_t& c = !_need_temp_object_collection(_c, hoid) ? _c : _c.get_temp();
+  tracepoint(objectstore, omap_get_keys_enter, ch->cid.c_str());
+  const coll_t& c = !_need_temp_object_collection(ch->cid, hoid) ? ch->cid : ch->cid.get_temp();
   dout(15) << __FUNC__ << ": " << c << "/" << hoid << dendl;
   Index index;
   int r = get_index(c, &index);
@@ -5142,12 +5141,12 @@ int FileStore::omap_get_keys(const coll_t& _c, const ghobject_t &hoid, set<strin
   return 0;
 }
 
-int FileStore::omap_get_values(const coll_t& _c, const ghobject_t &hoid,
+int FileStore::omap_get_values(CollectionHandle& ch, const ghobject_t &hoid,
                               const set<string> &keys,
                               map<string, bufferlist> *out)
 {
-  tracepoint(objectstore, omap_get_values_enter, _c.c_str());
-  const coll_t& c = !_need_temp_object_collection(_c, hoid) ? _c : _c.get_temp();
+  tracepoint(objectstore, omap_get_values_enter, ch->cid.c_str());
+  const coll_t& c = !_need_temp_object_collection(ch->cid, hoid) ? ch->cid : ch->cid.get_temp();
   dout(15) << __FUNC__ << ": " << c << "/" << hoid << dendl;
   Index index;
   const char *where = "()";
@@ -5179,12 +5178,12 @@ int FileStore::omap_get_values(const coll_t& _c, const ghobject_t &hoid,
   return r;
 }
 
-int FileStore::omap_check_keys(const coll_t& _c, const ghobject_t &hoid,
+int FileStore::omap_check_keys(CollectionHandle& ch, const ghobject_t &hoid,
                               const set<string> &keys,
                               set<string> *out)
 {
-  tracepoint(objectstore, omap_check_keys_enter, _c.c_str());
-  const coll_t& c = !_need_temp_object_collection(_c, hoid) ? _c : _c.get_temp();
+  tracepoint(objectstore, omap_check_keys_enter, ch->cid.c_str());
+  const coll_t& c = !_need_temp_object_collection(ch->cid, hoid) ? ch->cid : ch->cid.get_temp();
   dout(15) << __FUNC__ << ": " << c << "/" << hoid << dendl;
 
   Index index;
index 87b9e2faa3d55828eabee6e2eb16a279cfa72cbd..af479e70753a2c57e173fa75cc2d42e540ec805d 100644 (file)
@@ -577,20 +577,20 @@ public:
     return 0;
   }
   using ObjectStore::exists;
-  bool exists(const coll_t& cid, const ghobject_t& oid) override;
+  bool exists(CollectionHandle& c, const ghobject_t& oid) override;
   using ObjectStore::stat;
   int stat(
-    const coll_t& cid,
+    CollectionHandle& c,
     const ghobject_t& oid,
     struct stat *st,
     bool allow_eio = false) override;
   using ObjectStore::set_collection_opts;
   int set_collection_opts(
-    const coll_t& cid,
+    CollectionHandle& c,
     const pool_opts_t& opts) override;
   using ObjectStore::read;
   int read(
-    const coll_t& cid,
+    CollectionHandle& c,
     const ghobject_t& oid,
     uint64_t offset,
     size_t len,
@@ -601,8 +601,8 @@ public:
   int _do_seek_hole_data(int fd, uint64_t offset, size_t len,
                          map<uint64_t, uint64_t> *m);
   using ObjectStore::fiemap;
-  int fiemap(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl) override;
-  int fiemap(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap) override;
+  int fiemap(CollectionHandle& c, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl) override;
+  int fiemap(CollectionHandle& c, const ghobject_t& oid, uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap) override;
 
   int _touch(const coll_t& cid, const ghobject_t& oid);
   int _write(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len,
@@ -665,8 +665,8 @@ public:
   // attrs
   using ObjectStore::getattr;
   using ObjectStore::getattrs;
-  int getattr(const coll_t& cid, const ghobject_t& oid, const char *name, bufferptr &bp) override;
-  int getattrs(const coll_t& cid, const ghobject_t& oid, map<string,bufferptr>& aset) override;
+  int getattr(CollectionHandle& c, const ghobject_t& oid, const char *name, bufferptr &bp) override;
+  int getattrs(CollectionHandle& c, const ghobject_t& oid, map<string,bufferptr>& aset) override;
 
   int _setattrs(const coll_t& cid, const ghobject_t& oid, map<string,bufferptr>& aset,
                const SequencerPosition &spos);
@@ -682,36 +682,47 @@ public:
 
   // collections
   using ObjectStore::collection_list;
-  int collection_bits(const coll_t& c) override;
-  int collection_list(const coll_t& c,
+  int collection_bits(CollectionHandle& c) override;
+  int collection_list(CollectionHandle& c,
                      const ghobject_t& start, const ghobject_t& end, int max,
-                     vector<ghobject_t> *ls, ghobject_t *next) override;
+                     vector<ghobject_t> *ls, ghobject_t *next) override {
+    return collection_list(c->cid, start, end, max, ls, next);
+  }
+  int collection_list(const coll_t& cid,
+                     const ghobject_t& start, const ghobject_t& end, int max,
+                     vector<ghobject_t> *ls, ghobject_t *next);
   int list_collections(vector<coll_t>& ls) override;
   int list_collections(vector<coll_t>& ls, bool include_temp);
   int collection_stat(const coll_t& c, struct stat *st);
   bool collection_exists(const coll_t& c) override;
-  int collection_empty(const coll_t& c, bool *empty) override;
+  int collection_empty(CollectionHandle& c, bool *empty) override {
+    return collection_empty(c->cid, empty);
+  }
+  int collection_empty(const coll_t& cid, bool *empty);
 
   // omap (see ObjectStore.h for documentation)
   using ObjectStore::omap_get;
-  int omap_get(const coll_t& c, const ghobject_t &oid, bufferlist *header,
+  int omap_get(CollectionHandle& c, const ghobject_t &oid, bufferlist *header,
               map<string, bufferlist> *out) override;
   using ObjectStore::omap_get_header;
   int omap_get_header(
-    const coll_t& c,
+    CollectionHandle& c,
     const ghobject_t &oid,
     bufferlist *out,
     bool allow_eio = false) override;
   using ObjectStore::omap_get_keys;
-  int omap_get_keys(const coll_t& c, const ghobject_t &oid, set<string> *keys) override;
+  int omap_get_keys(CollectionHandle& c, const ghobject_t &oid, set<string> *keys) override;
   using ObjectStore::omap_get_values;
-  int omap_get_values(const coll_t& c, const ghobject_t &oid, const set<string> &keys,
+  int omap_get_values(CollectionHandle& c, const ghobject_t &oid, const set<string> &keys,
                      map<string, bufferlist> *out) override;
   using ObjectStore::omap_check_keys;
-  int omap_check_keys(const coll_t& c, const ghobject_t &oid, const set<string> &keys,
+  int omap_check_keys(CollectionHandle& c, const ghobject_t &oid, const set<string> &keys,
                      set<string> *out) override;
   using ObjectStore::get_omap_iterator;
-  ObjectMap::ObjectMapIterator get_omap_iterator(const coll_t& c, const ghobject_t &oid) override;
+  ObjectMap::ObjectMapIterator get_omap_iterator(CollectionHandle& c, const ghobject_t &oid) override {
+    return get_omap_iterator(c->cid, oid);
+  }
+  ObjectMap::ObjectMapIterator get_omap_iterator(const coll_t& cid, const ghobject_t &oid);
 
   int _create_collection(const coll_t& c, int bits,
                         const SequencerPosition &spos);
index 9cbe592416bb545e401d6a68be3e5f6d9e1450e9..dce11a5f0e45a8c7daa1201577ca65017146da7a 100644 (file)
@@ -1148,12 +1148,10 @@ void KStore::_reap_collections()
 // ---------------
 // read operations
 
-bool KStore::exists(const coll_t& cid, const ghobject_t& oid)
+bool KStore::exists(CollectionHandle& ch, const ghobject_t& oid)
 {
-  dout(10) << __func__ << " " << cid << " " << oid << dendl;
-  CollectionRef c = _get_collection(cid);
-  if (!c)
-    return false;
+  dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
   RWLock::RLocker l(c->lock);
   OnodeRef o = c->get_onode(oid, false);
   if (!o || !o->exists)
@@ -1162,15 +1160,13 @@ bool KStore::exists(const coll_t& cid, const ghobject_t& oid)
 }
 
 int KStore::stat(
-    const coll_t& cid,
-    const ghobject_t& oid,
-    struct stat *st,
-    bool allow_eio)
+  CollectionHandle& ch,
+  const ghobject_t& oid,
+  struct stat *st,
+  bool allow_eio)
 {
-  dout(10) << __func__ << " " << cid << " " << oid << dendl;
-  CollectionRef c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
+  dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
   RWLock::RLocker l(c->lock);
   OnodeRef o = c->get_onode(oid, false);
   if (!o || !o->exists)
@@ -1183,27 +1179,25 @@ int KStore::stat(
 }
 
 int KStore::set_collection_opts(
-  const coll_t& cid,
+  CollectionHandle& ch,
   const pool_opts_t& opts)
 {
   return -EOPNOTSUPP;
 }
 
 int KStore::read(
-  const coll_t& cid,
+  CollectionHandle& ch,
   const ghobject_t& oid,
   uint64_t offset,
   size_t length,
   bufferlist& bl,
   uint32_t op_flags)
 {
-  dout(15) << __func__ << " " << cid << " " << oid
+  dout(15) << __func__ << " " << ch->cid << " " << oid
           << " " << offset << "~" << length
           << dendl;
   bl.clear();
-  CollectionRef c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
+  Collection *c = static_cast<Collection*>(ch.get());
   RWLock::RLocker l(c->lock);
 
   int r;
@@ -1220,7 +1214,7 @@ int KStore::read(
   r = _do_read(o, offset, length, bl, op_flags);
 
  out:
-  dout(10) << __func__ << " " << cid << " " << oid
+  dout(10) << __func__ << " " << ch->cid << " " << oid
           << " " << offset << "~" << length
           << " = " << r << dendl;
   return r;
@@ -1298,29 +1292,28 @@ int KStore::_do_read(
 }
 
 int KStore::fiemap(
-  const coll_t& cid,
+  CollectionHandle& ch,
   const ghobject_t& oid,
   uint64_t offset,
   size_t len,
   bufferlist& bl)
 {
   map<uint64_t, uint64_t> m;
-  int r = fiemap(cid, oid, offset, len, m);
+  int r = fiemap(ch, oid, offset, len, m);
   if (r >= 0) {
     encode(m, bl);
   }
-
   return r;
 }
 
 int KStore::fiemap(
-  const coll_t& cid,
+  CollectionHandle& ch,
   const ghobject_t& oid,
   uint64_t offset,
   size_t len,
   map<uint64_t, uint64_t>& destmap)
 {
-  CollectionRef c = _get_collection(cid);
+  CollectionRef c = static_cast<Collection*>(ch.get());
   if (!c)
     return -ENOENT;
   RWLock::RLocker l(c->lock);
@@ -1350,15 +1343,13 @@ int KStore::fiemap(
 }
 
 int KStore::getattr(
-  const coll_t& cid,
+  CollectionHandle& ch,
   const ghobject_t& oid,
   const char *name,
   bufferptr& value)
 {
-  dout(15) << __func__ << " " << cid << " " << oid << " " << name << dendl;
-  CollectionRef c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
+  dout(15) << __func__ << " " << ch->cid << " " << oid << " " << name << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
   RWLock::RLocker l(c->lock);
   int r;
   string k(name);
@@ -1376,20 +1367,18 @@ int KStore::getattr(
   value = o->onode.attrs[k];
   r = 0;
  out:
-  dout(10) << __func__ << " " << cid << " " << oid << " " << name
+  dout(10) << __func__ << " " << ch->cid << " " << oid << " " << name
           << " = " << r << dendl;
   return r;
 }
 
 int KStore::getattrs(
-  const coll_t& cid,
+  CollectionHandle& ch,
   const ghobject_t& oid,
   map<string,bufferptr>& aset)
 {
-  dout(15) << __func__ << " " << cid << " " << oid << dendl;
-  CollectionRef c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
+  dout(15) << __func__ << " " << ch->cid << " " << oid << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
   RWLock::RLocker l(c->lock);
   int r;
 
@@ -1401,7 +1390,7 @@ int KStore::getattrs(
   aset = o->onode.attrs;
   r = 0;
  out:
-  dout(10) << __func__ << " " << cid << " " << oid
+  dout(10) << __func__ << " " << ch->cid << " " << oid
           << " = " << r << dendl;
   return r;
 }
@@ -1422,12 +1411,12 @@ bool KStore::collection_exists(const coll_t& c)
   return coll_map.count(c);
 }
 
-int KStore::collection_empty(const coll_t& cid, bool *empty)
+int KStore::collection_empty(CollectionHandle& ch, bool *empty)
 {
-  dout(15) << __func__ << " " << cid << dendl;
+  dout(15) << __func__ << " " << ch->cid << dendl;
   vector<ghobject_t> ls;
   ghobject_t next;
-  int r = collection_list(cid, ghobject_t(), ghobject_t::get_max(), 1,
+  int r = collection_list(ch, ghobject_t(), ghobject_t::get_max(), 1,
                          &ls, &next);
   if (r < 0) {
     derr << __func__ << " collection_list returned: " << cpp_strerror(r)
@@ -1435,32 +1424,19 @@ int KStore::collection_empty(const coll_t& cid, bool *empty)
     return r;
   }
   *empty = ls.empty();
-  dout(10) << __func__ << " " << cid << " = " << (int)(*empty) << dendl;
+  dout(10) << __func__ << " " << ch->cid << " = " << (int)(*empty) << dendl;
   return 0;
 }
 
-int KStore::collection_bits(const coll_t& cid)
+int KStore::collection_bits(CollectionHandle& ch)
 {
-  dout(15) << __func__ << " " << cid << dendl;
-  CollectionHandle ch = _get_collection(cid);
-  if (!ch)
-    return -ENOENT;
+  dout(15) << __func__ << " " << ch->cid << dendl;
   Collection *c = static_cast<Collection*>(ch.get());
   RWLock::RLocker l(c->lock);
-  dout(10) << __func__ << " " << cid << " = " << c->cnode.bits << dendl;
+  dout(10) << __func__ << " " << ch->cid << " = " << c->cnode.bits << dendl;
   return c->cnode.bits;
 }
 
-int KStore::collection_list(
-  const coll_t& cid, const ghobject_t& start, const ghobject_t& end, int max,
-  vector<ghobject_t> *ls, ghobject_t *pnext)
-{
-  CollectionHandle c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
-  return collection_list(c, start, end, max, ls, pnext);
-}
-
 int KStore::collection_list(
   CollectionHandle &c_, const ghobject_t& start, const ghobject_t& end, int max,
   vector<ghobject_t> *ls, ghobject_t *pnext)
@@ -1672,16 +1648,14 @@ bufferlist KStore::OmapIteratorImpl::value()
 }
 
 int KStore::omap_get(
-  const coll_t& cid,                ///< [in] Collection containing oid
+  CollectionHandle& ch,                ///< [in] Collection containing oid
   const ghobject_t &oid,   ///< [in] Object containing omap
   bufferlist *header,      ///< [out] omap header
   map<string, bufferlist> *out /// < [out] Key to value map
   )
 {
-  dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
-  CollectionRef c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
+  dout(15) << __func__ << " " << ch->cid << " oid " << oid << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
   RWLock::RLocker l(c->lock);
   int r = 0;
   OnodeRef o = c->get_onode(oid, false);
@@ -1717,21 +1691,19 @@ int KStore::omap_get(
     }
   }
  out:
-  dout(10) << __func__ << " " << cid << " oid " << oid << " = " << r << dendl;
+  dout(10) << __func__ << " " << ch->cid << " oid " << oid << " = " << r << dendl;
   return r;
 }
 
 int KStore::omap_get_header(
-  const coll_t& cid,                ///< [in] Collection containing oid
+  CollectionHandle& ch,                ///< [in] Collection containing oid
   const ghobject_t &oid,   ///< [in] Object containing omap
   bufferlist *header,      ///< [out] omap header
   bool allow_eio ///< [in] don't assert on eio
   )
 {
-  dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
-  CollectionRef c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
+  dout(15) << __func__ << " " << ch->cid << " oid " << oid << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
   RWLock::RLocker l(c->lock);
   int r = 0;
   OnodeRef o = c->get_onode(oid, false);
@@ -1752,20 +1724,18 @@ int KStore::omap_get_header(
     }
   }
  out:
-  dout(10) << __func__ << " " << cid << " oid " << oid << " = " << r << dendl;
+  dout(10) << __func__ << " " << ch->cid << " oid " << oid << " = " << r << dendl;
   return r;
 }
 
 int KStore::omap_get_keys(
-  const coll_t& cid,              ///< [in] Collection containing oid
+  CollectionHandle& ch,              ///< [in] Collection containing oid
   const ghobject_t &oid, ///< [in] Object containing omap
   set<string> *keys      ///< [out] Keys defined on oid
   )
 {
-  dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
-  CollectionRef c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
+  dout(15) << __func__ << " " << ch->cid << " oid " << oid << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
   RWLock::RLocker l(c->lock);
   int r = 0;
   OnodeRef o = c->get_onode(oid, false);
@@ -1797,21 +1767,19 @@ int KStore::omap_get_keys(
     }
   }
  out:
-  dout(10) << __func__ << " " << cid << " oid " << oid << " = " << r << dendl;
+  dout(10) << __func__ << " " << ch->cid << " oid " << oid << " = " << r << dendl;
   return r;
 }
 
 int KStore::omap_get_values(
-  const coll_t& cid,                    ///< [in] Collection containing oid
+  CollectionHandle& ch,                    ///< [in] Collection containing oid
   const ghobject_t &oid,       ///< [in] Object containing omap
   const set<string> &keys,     ///< [in] Keys to get
   map<string, bufferlist> *out ///< [out] Returned keys and values
   )
 {
-  dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
-  CollectionRef c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
+  dout(15) << __func__ << " " << ch->cid << " oid " << oid << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
   RWLock::RLocker l(c->lock);
   int r = 0;
   OnodeRef o = c->get_onode(oid, false);
@@ -1833,21 +1801,19 @@ int KStore::omap_get_values(
     }
   }
  out:
-  dout(10) << __func__ << " " << cid << " oid " << oid << " = " << r << dendl;
+  dout(10) << __func__ << " " << ch->cid << " oid " << oid << " = " << r << dendl;
   return r;
 }
 
 int KStore::omap_check_keys(
-  const coll_t& cid,                ///< [in] Collection containing oid
+  CollectionHandle& ch,                ///< [in] Collection containing oid
   const ghobject_t &oid,   ///< [in] Object containing omap
   const set<string> &keys, ///< [in] Keys to check
   set<string> *out         ///< [out] Subset of keys defined on oid
   )
 {
-  dout(15) << __func__ << " " << cid << " oid " << oid << dendl;
-  CollectionRef c = _get_collection(cid);
-  if (!c)
-    return -ENOENT;
+  dout(15) << __func__ << " " << ch->cid << " oid " << oid << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
   RWLock::RLocker l(c->lock);
   int r = 0;
   OnodeRef o = c->get_onode(oid, false);
@@ -1872,22 +1838,18 @@ int KStore::omap_check_keys(
     }
   }
  out:
-  dout(10) << __func__ << " " << cid << " oid " << oid << " = " << r << dendl;
+  dout(10) << __func__ << " " << ch->cid << " oid " << oid << " = " << r << dendl;
   return r;
 }
 
 ObjectMap::ObjectMapIterator KStore::get_omap_iterator(
-  const coll_t& cid,              ///< [in] collection
+  CollectionHandle& ch,              ///< [in] collection
   const ghobject_t &oid  ///< [in] object
   )
 {
 
-  dout(10) << __func__ << " " << cid << " " << oid << dendl;
-  CollectionRef c = _get_collection(cid);
-  if (!c) {
-    dout(10) << __func__ << " " << cid << "doesn't exist" <<dendl;
-    return ObjectMap::ObjectMapIterator();
-  }
+  dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
   RWLock::RLocker l(c->lock);
   OnodeRef o = c->get_onode(oid, false);
   if (!o || !o->exists) {
index c1a2a9c16e75a020ed0a8d3ee909fb8f55a08dbc..e1938bbb0bc7fec5c0a03594a2fdc0926d40980c 100644 (file)
@@ -442,19 +442,19 @@ public:
   CollectionHandle create_new_collection(const coll_t& c) override;
 
   using ObjectStore::exists;
-  bool exists(const coll_t& cid, const ghobject_t& oid) override;
+  bool exists(CollectionHandle& c, const ghobject_t& oid) override;
   using ObjectStore::stat;
   int stat(
-    const coll_t& cid,
+    CollectionHandle& c,
     const ghobject_t& oid,
     struct stat *st,
     bool allow_eio = false) override; // struct stat?
   int set_collection_opts(
-    const coll_t& cid,
+    CollectionHandle& c,
     const pool_opts_t& opts) override;
   using ObjectStore::read;
   int read(
-    const coll_t& cid,
+    CollectionHandle& c,
     const ghobject_t& oid,
     uint64_t offset,
     size_t len,
@@ -468,21 +468,17 @@ public:
     uint32_t op_flags = 0);
 
   using ObjectStore::fiemap;
-  int fiemap(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl) override;
-  int fiemap(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap) override;
+  int fiemap(CollectionHandle& c, const ghobject_t& oid, uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap) override;
+  int fiemap(CollectionHandle& c, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& outbl) override;
   using ObjectStore::getattr;
-  int getattr(const coll_t& cid, const ghobject_t& oid, const char *name, bufferptr& value) override;
+  int getattr(CollectionHandle& c, const ghobject_t& oid, const char *name, bufferptr& value) override;
   using ObjectStore::getattrs;
-  int getattrs(const coll_t& cid, const ghobject_t& oid, map<string,bufferptr>& aset) override;
+  int getattrs(CollectionHandle& c, const ghobject_t& oid, map<string,bufferptr>& aset) override;
 
   int list_collections(vector<coll_t>& ls) override;
   bool collection_exists(const coll_t& c) override;
-  int collection_empty(const coll_t& c, bool *empty) override;
-  int collection_bits(const coll_t& c) override;
-  int collection_list(
-    const coll_t& cid, const ghobject_t& start, const ghobject_t& end,
-    int max,
-    vector<ghobject_t> *ls, ghobject_t *next) override;
+  int collection_empty(CollectionHandle& c, bool *empty) override;
+  int collection_bits(CollectionHandle& c) override;
   int collection_list(
     CollectionHandle &c, const ghobject_t& start, const ghobject_t& end,
     int max,
@@ -490,7 +486,7 @@ public:
 
   using ObjectStore::omap_get;
   int omap_get(
-    const coll_t& cid,                ///< [in] Collection containing oid
+    CollectionHandle& c,                ///< [in] Collection containing oid
     const ghobject_t &oid,   ///< [in] Object containing omap
     bufferlist *header,      ///< [out] omap header
     map<string, bufferlist> *out /// < [out] Key to value map
@@ -499,7 +495,7 @@ public:
   using ObjectStore::omap_get_header;
   /// Get omap header
   int omap_get_header(
-    const coll_t& cid,                ///< [in] Collection containing oid
+    CollectionHandle& c,                ///< [in] Collection containing oid
     const ghobject_t &oid,   ///< [in] Object containing omap
     bufferlist *header,      ///< [out] omap header
     bool allow_eio = false ///< [in] don't assert on eio
@@ -508,7 +504,7 @@ public:
   using ObjectStore::omap_get_keys;
   /// Get keys defined on oid
   int omap_get_keys(
-    const coll_t& cid,              ///< [in] Collection containing oid
+    CollectionHandle& c,              ///< [in] Collection containing oid
     const ghobject_t &oid, ///< [in] Object containing omap
     set<string> *keys      ///< [out] Keys defined on oid
     ) override;
@@ -516,7 +512,7 @@ public:
   using ObjectStore::omap_get_values;
   /// Get key values
   int omap_get_values(
-    const coll_t& cid,                    ///< [in] Collection containing oid
+    CollectionHandle& c,                    ///< [in] Collection containing oid
     const ghobject_t &oid,       ///< [in] Object containing omap
     const set<string> &keys,     ///< [in] Keys to get
     map<string, bufferlist> *out ///< [out] Returned keys and values
@@ -525,7 +521,7 @@ public:
   using ObjectStore::omap_check_keys;
   /// Filters keys into out which are defined on oid
   int omap_check_keys(
-    const coll_t& cid,                ///< [in] Collection containing oid
+    CollectionHandle& c,                ///< [in] Collection containing oid
     const ghobject_t &oid,   ///< [in] Object containing omap
     const set<string> &keys, ///< [in] Keys to check
     set<string> *out         ///< [out] Subset of keys defined on oid
@@ -533,7 +529,7 @@ public:
 
   using ObjectStore::get_omap_iterator;
   ObjectMap::ObjectMapIterator get_omap_iterator(
-    const coll_t& cid,              ///< [in] collection
+    CollectionHandle& c,              ///< [in] collection
     const ghobject_t &oid  ///< [in] object
     ) override;
 
index a8197d19463deb02adf937da61ed87e7959c82f5..47ec85d296fa3d9d2326bdc538fad38f373cc4d3 100644 (file)
@@ -259,14 +259,6 @@ ObjectStore::CollectionHandle MemStore::create_new_collection(const coll_t& cid)
 // ---------------
 // read operations
 
-bool MemStore::exists(const coll_t& cid, const ghobject_t& oid)
-{
-  CollectionHandle c = get_collection(cid);
-  if (!c)
-    return false;
-  return exists(c, oid);
-}
-
 bool MemStore::exists(CollectionHandle &c_, const ghobject_t& oid)
 {
   Collection *c = static_cast<Collection*>(c_.get());
@@ -279,18 +271,6 @@ bool MemStore::exists(CollectionHandle &c_, const ghobject_t& oid)
   return (bool)c->get_object(oid);
 }
 
-int MemStore::stat(
-    const coll_t& cid,
-    const ghobject_t& oid,
-    struct stat *st,
-    bool allow_eio)
-{
-  CollectionHandle c = get_collection(cid);
-  if (!c)
-    return -ENOENT;
-  return stat(c, oid, st, allow_eio);
-}
-
 int MemStore::stat(
   CollectionHandle &c_,
   const ghobject_t& oid,
@@ -312,26 +292,12 @@ int MemStore::stat(
 }
 
 int MemStore::set_collection_opts(
-  const coll_t& cid,
+  CollectionHandle& ch,
   const pool_opts_t& opts)
 {
   return -EOPNOTSUPP;
 }
 
-int MemStore::read(
-    const coll_t& cid,
-    const ghobject_t& oid,
-    uint64_t offset,
-    size_t len,
-    bufferlist& bl,
-    uint32_t op_flags)
-{
-  CollectionHandle c = get_collection(cid);
-  if (!c)
-    return -ENOENT;
-  return read(c, oid, offset, len, bl, op_flags);
-}
-
 int MemStore::read(
   CollectionHandle &c_,
   const ghobject_t& oid,
@@ -359,22 +325,22 @@ int MemStore::read(
   return o->read(offset, l, bl);
 }
 
-int MemStore::fiemap(const coll_t& cid, const ghobject_t& oid,
+int MemStore::fiemap(CollectionHandle& ch, const ghobject_t& oid,
                     uint64_t offset, size_t len, bufferlist& bl)
 {
   map<uint64_t, uint64_t> destmap;
-  int r = fiemap(cid, oid, offset, len, destmap);
+  int r = fiemap(ch, oid, offset, len, destmap);
   if (r >= 0)
     encode(destmap, bl);
   return r;
 }
 
-int MemStore::fiemap(const coll_t& cid, const ghobject_t& oid,
+int MemStore::fiemap(CollectionHandle& ch, const ghobject_t& oid,
                     uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap)
 {
-  dout(10) << __func__ << " " << cid << " " << oid << " " << offset << "~"
+  dout(10) << __func__ << " " << ch->cid << " " << oid << " " << offset << "~"
           << len << dendl;
-  CollectionRef c = get_collection(cid);
+  Collection *c = static_cast<Collection*>(ch.get());
   if (!c)
     return -ENOENT;
 
@@ -391,15 +357,6 @@ int MemStore::fiemap(const coll_t& cid, const ghobject_t& oid,
   return 0;
 }
 
-int MemStore::getattr(const coll_t& cid, const ghobject_t& oid,
-                     const char *name, bufferptr& value)
-{
-  CollectionHandle c = get_collection(cid);
-  if (!c)
-    return -ENOENT;
-  return getattr(c, oid, name, value);
-}
-
 int MemStore::getattr(CollectionHandle &c_, const ghobject_t& oid,
                      const char *name, bufferptr& value)
 {
@@ -419,15 +376,6 @@ int MemStore::getattr(CollectionHandle &c_, const ghobject_t& oid,
   return 0;
 }
 
-int MemStore::getattrs(const coll_t& cid, const ghobject_t& oid,
-                      map<string,bufferptr>& aset)
-{
-  CollectionHandle c = get_collection(cid);
-  if (!c)
-    return -ENOENT;
-  return getattrs(c, oid, aset);
-}
-
 int MemStore::getattrs(CollectionHandle &c_, const ghobject_t& oid,
                       map<string,bufferptr>& aset)
 {
@@ -463,39 +411,33 @@ bool MemStore::collection_exists(const coll_t& cid)
   return coll_map.count(cid);
 }
 
-int MemStore::collection_empty(const coll_t& cid, bool *empty)
+int MemStore::collection_empty(CollectionHandle& ch, bool *empty)
 {
-  dout(10) << __func__ << " " << cid << dendl;
-  CollectionRef c = get_collection(cid);
-  if (!c)
-    return -ENOENT;
+  dout(10) << __func__ << " " << ch->cid << dendl;
+  CollectionRef c = static_cast<Collection*>(ch.get());
   RWLock::RLocker l(c->lock);
   *empty = c->object_map.empty();
   return 0;
 }
 
-int MemStore::collection_bits(const coll_t& cid)
+int MemStore::collection_bits(CollectionHandle& ch)
 {
-  dout(10) << __func__ << " " << cid << dendl;
-  CollectionRef c = get_collection(cid);
-  if (!c)
-    return -ENOENT;
+  dout(10) << __func__ << " " << ch->cid << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
   RWLock::RLocker l(c->lock);
   return c->bits;
 }
 
-int MemStore::collection_list(const coll_t& cid,
+int MemStore::collection_list(CollectionHandle& ch,
                              const ghobject_t& start,
                              const ghobject_t& end,
                              int max,
                              vector<ghobject_t> *ls, ghobject_t *next)
 {
-  CollectionRef c = get_collection(cid);
-  if (!c)
-    return -ENOENT;
+  Collection *c = static_cast<Collection*>(ch.get());
   RWLock::RLocker l(c->lock);
 
-  dout(10) << __func__ << " cid " << cid << " start " << start
+  dout(10) << __func__ << " cid " << ch->cid << " start " << start
           << " end " << end << dendl;
   map<ghobject_t,ObjectRef>::iterator p = c->object_map.lower_bound(start);
   while (p != c->object_map.end() &&
@@ -510,21 +452,19 @@ int MemStore::collection_list(const coll_t& cid,
     else
       *next = p->first;
   }
-  dout(10) << __func__ << " cid " << cid << " got " << ls->size() << dendl;
+  dout(10) << __func__ << " cid " << ch->cid << " got " << ls->size() << dendl;
   return 0;
 }
 
 int MemStore::omap_get(
-    const coll_t& cid,                ///< [in] Collection containing oid
-    const ghobject_t &oid,   ///< [in] Object containing omap
-    bufferlist *header,      ///< [out] omap header
-    map<string, bufferlist> *out /// < [out] Key to value map
-    )
+  CollectionHandle& ch,                ///< [in] Collection containing oid
+  const ghobject_t &oid,   ///< [in] Object containing omap
+  bufferlist *header,      ///< [out] omap header
+  map<string, bufferlist> *out /// < [out] Key to value map
+  )
 {
-  dout(10) << __func__ << " " << cid << " " << oid << dendl;
-  CollectionRef c = get_collection(cid);
-  if (!c)
-    return -ENOENT;
+  dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
 
   ObjectRef o = c->get_object(oid);
   if (!o)
@@ -536,17 +476,14 @@ int MemStore::omap_get(
 }
 
 int MemStore::omap_get_header(
-    const coll_t& cid,                ///< [in] Collection containing oid
-    const ghobject_t &oid,   ///< [in] Object containing omap
-    bufferlist *header,      ///< [out] omap header
-    bool allow_eio ///< [in] don't assert on eio
-    )
+  CollectionHandle& ch,                ///< [in] Collection containing oid
+  const ghobject_t &oid,   ///< [in] Object containing omap
+  bufferlist *header,      ///< [out] omap header
+  bool allow_eio ///< [in] don't assert on eio
+  )
 {
-  dout(10) << __func__ << " " << cid << " " << oid << dendl;
-  CollectionRef c = get_collection(cid);
-  if (!c)
-    return -ENOENT;
-
+  dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
   ObjectRef o = c->get_object(oid);
   if (!o)
     return -ENOENT;
@@ -556,16 +493,13 @@ int MemStore::omap_get_header(
 }
 
 int MemStore::omap_get_keys(
-    const coll_t& cid,              ///< [in] Collection containing oid
-    const ghobject_t &oid, ///< [in] Object containing omap
-    set<string> *keys      ///< [out] Keys defined on oid
-    )
+  CollectionHandle& ch,              ///< [in] Collection containing oid
+  const ghobject_t &oid, ///< [in] Object containing omap
+  set<string> *keys      ///< [out] Keys defined on oid
+  )
 {
-  dout(10) << __func__ << " " << cid << " " << oid << dendl;
-  CollectionRef c = get_collection(cid);
-  if (!c)
-    return -ENOENT;
-
+  dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
   ObjectRef o = c->get_object(oid);
   if (!o)
     return -ENOENT;
@@ -578,17 +512,14 @@ int MemStore::omap_get_keys(
 }
 
 int MemStore::omap_get_values(
-    const coll_t& cid,                    ///< [in] Collection containing oid
-    const ghobject_t &oid,       ///< [in] Object containing omap
-    const set<string> &keys,     ///< [in] Keys to get
-    map<string, bufferlist> *out ///< [out] Returned keys and values
-    )
+  CollectionHandle& ch,                    ///< [in] Collection containing oid
+  const ghobject_t &oid,       ///< [in] Object containing omap
+  const set<string> &keys,     ///< [in] Keys to get
+  map<string, bufferlist> *out ///< [out] Returned keys and values
+  )
 {
-  dout(10) << __func__ << " " << cid << " " << oid << dendl;
-  CollectionRef c = get_collection(cid);
-  if (!c)
-    return -ENOENT;
-
+  dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
   ObjectRef o = c->get_object(oid);
   if (!o)
     return -ENOENT;
@@ -604,17 +535,14 @@ int MemStore::omap_get_values(
 }
 
 int MemStore::omap_check_keys(
-    const coll_t& cid,                ///< [in] Collection containing oid
-    const ghobject_t &oid,   ///< [in] Object containing omap
-    const set<string> &keys, ///< [in] Keys to check
-    set<string> *out         ///< [out] Subset of keys defined on oid
-    )
+  CollectionHandle& ch,                ///< [in] Collection containing oid
+  const ghobject_t &oid,   ///< [in] Object containing omap
+  const set<string> &keys, ///< [in] Keys to check
+  set<string> *out         ///< [out] Subset of keys defined on oid
+  )
 {
-  dout(10) << __func__ << " " << cid << " " << oid << dendl;
-  CollectionRef c = get_collection(cid);
-  if (!c)
-    return -ENOENT;
-
+  dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
   ObjectRef o = c->get_object(oid);
   if (!o)
     return -ENOENT;
@@ -674,14 +602,12 @@ public:
   }
 };
 
-ObjectMap::ObjectMapIterator MemStore::get_omap_iterator(const coll_t& cid,
-                                                        const ghobject_t& oid)
+ObjectMap::ObjectMapIterator MemStore::get_omap_iterator(
+  CollectionHandle& ch,
+  const ghobject_t& oid)
 {
-  dout(10) << __func__ << " " << cid << " " << oid << dendl;
-  CollectionRef c = get_collection(cid);
-  if (!c)
-    return ObjectMap::ObjectMapIterator();
-
+  dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
+  Collection *c = static_cast<Collection*>(ch.get());
   ObjectRef o = c->get_object(oid);
   if (!o)
     return ObjectMap::ObjectMapIterator();
index b8663122a0e0c9ee58788c7de9b0d06fe7992872..f31320fc1b647a6b2b6f1535ec20eba0357064a3 100644 (file)
@@ -292,22 +292,12 @@ public:
 
   int statfs(struct store_statfs_t *buf) override;
 
-  bool exists(const coll_t& cid, const ghobject_t& oid) override;
   bool exists(CollectionHandle &c, const ghobject_t& oid) override;
-  int stat(const coll_t& cid, const ghobject_t& oid,
-          struct stat *st, bool allow_eio = false) override;
   int stat(CollectionHandle &c, const ghobject_t& oid,
           struct stat *st, bool allow_eio = false) override;
   int set_collection_opts(
-    const coll_t& cid,
+    CollectionHandle& c,
     const pool_opts_t& opts) override;
-  int read(
-    const coll_t& cid,
-    const ghobject_t& oid,
-    uint64_t offset,
-    size_t len,
-    bufferlist& bl,
-    uint32_t op_flags = 0) override;
   int read(
     CollectionHandle &c,
     const ghobject_t& oid,
@@ -316,16 +306,12 @@ public:
     bufferlist& bl,
     uint32_t op_flags = 0) override;
   using ObjectStore::fiemap;
-  int fiemap(const coll_t& cid, const ghobject_t& oid,
+  int fiemap(CollectionHandle& c, const ghobject_t& oid,
             uint64_t offset, size_t len, bufferlist& bl) override;
-  int fiemap(const coll_t& cid, const ghobject_t& oid, uint64_t offset,
+  int fiemap(CollectionHandle& c, const ghobject_t& oid, uint64_t offset,
             size_t len, map<uint64_t, uint64_t>& destmap) override;
-  int getattr(const coll_t& cid, const ghobject_t& oid, const char *name,
-             bufferptr& value) override;
   int getattr(CollectionHandle &c, const ghobject_t& oid, const char *name,
              bufferptr& value) override;
-  int getattrs(const coll_t& cid, const ghobject_t& oid,
-              map<string,bufferptr>& aset) override;
   int getattrs(CollectionHandle &c, const ghobject_t& oid,
               map<string,bufferptr>& aset) override;
 
@@ -336,16 +322,15 @@ public:
   }
   CollectionHandle create_new_collection(const coll_t& c) override;
   bool collection_exists(const coll_t& c) override;
-  int collection_empty(const coll_t& c, bool *empty) override;
-  int collection_bits(const coll_t& c) override;
-  using ObjectStore::collection_list;
-  int collection_list(const coll_t& cid,
+  int collection_empty(CollectionHandle& c, bool *empty) override;
+  int collection_bits(CollectionHandle& c) override;
+  int collection_list(CollectionHandle& cid,
                      const ghobject_t& start, const ghobject_t& end, int max,
                      vector<ghobject_t> *ls, ghobject_t *next) override;
 
   using ObjectStore::omap_get;
   int omap_get(
-    const coll_t& cid,                ///< [in] Collection containing oid
+    CollectionHandle& c,                ///< [in] Collection containing oid
     const ghobject_t &oid,   ///< [in] Object containing omap
     bufferlist *header,      ///< [out] omap header
     map<string, bufferlist> *out /// < [out] Key to value map
@@ -354,7 +339,7 @@ public:
   using ObjectStore::omap_get_header;
   /// Get omap header
   int omap_get_header(
-    const coll_t& cid,                ///< [in] Collection containing oid
+    CollectionHandle& c,                ///< [in] Collection containing oid
     const ghobject_t &oid,   ///< [in] Object containing omap
     bufferlist *header,      ///< [out] omap header
     bool allow_eio = false ///< [in] don't assert on eio
@@ -363,7 +348,7 @@ public:
   using ObjectStore::omap_get_keys;
   /// Get keys defined on oid
   int omap_get_keys(
-    const coll_t& cid,              ///< [in] Collection containing oid
+    CollectionHandle& c,              ///< [in] Collection containing oid
     const ghobject_t &oid, ///< [in] Object containing omap
     set<string> *keys      ///< [out] Keys defined on oid
     ) override;
@@ -371,7 +356,7 @@ public:
   using ObjectStore::omap_get_values;
   /// Get key values
   int omap_get_values(
-    const coll_t& cid,                    ///< [in] Collection containing oid
+    CollectionHandle& c,                    ///< [in] Collection containing oid
     const ghobject_t &oid,       ///< [in] Object containing omap
     const set<string> &keys,     ///< [in] Keys to get
     map<string, bufferlist> *out ///< [out] Returned keys and values
@@ -380,7 +365,7 @@ public:
   using ObjectStore::omap_check_keys;
   /// Filters keys into out which are defined on oid
   int omap_check_keys(
-    const coll_t& cid,                ///< [in] Collection containing oid
+    CollectionHandle& c,                ///< [in] Collection containing oid
     const ghobject_t &oid,   ///< [in] Object containing omap
     const set<string> &keys, ///< [in] Keys to check
     set<string> *out         ///< [out] Subset of keys defined on oid
@@ -388,7 +373,7 @@ public:
 
   using ObjectStore::get_omap_iterator;
   ObjectMap::ObjectMapIterator get_omap_iterator(
-    const coll_t& cid,              ///< [in] collection
+    CollectionHandle& c,              ///< [in] collection
     const ghobject_t &oid  ///< [in] object
     ) override;
 
index 13809be1167cde5dbd42b63e5c6ad0d8019931c6..f529f7e8d1090210c93739293530adfb84d37be9 100644 (file)
@@ -1459,7 +1459,7 @@ bool OSDService::_get_map_bl(epoch_t e, bufferlist& bl)
   }
   if (logger)
     logger->inc(l_osd_map_bl_cache_miss);
-  found = store->read(coll_t::meta(),
+  found = store->read(meta_ch,
                      OSD::get_osdmap_pobject_name(e), 0, 0, bl,
                      CEPH_OSD_OP_FLAG_FADVISE_WILLNEED) >= 0;
   if (found) {
@@ -1479,7 +1479,7 @@ bool OSDService::get_inc_map_bl(epoch_t e, bufferlist& bl)
   }
   if (logger)
     logger->inc(l_osd_map_bl_cache_miss);
-  found = store->read(coll_t::meta(),
+  found = store->read(meta_ch,
                      OSD::get_inc_osdmap_pobject_name(e), 0, 0, bl,
                      CEPH_OSD_OP_FLAG_FADVISE_WILLNEED) >= 0;
   if (found) {
@@ -1581,7 +1581,7 @@ int OSDService::get_deleted_pool_pg_num(int64_t pool)
   dout(20) << __func__ << " " << pool << " loading" << dendl;
   ghobject_t oid = OSD::make_final_pool_info_oid(pool);
   bufferlist bl;
-  int r = store->read(coll_t::meta(), oid, 0, 0, bl);
+  int r = store->read(meta_ch, oid, 0, 0, bl);
   ceph_assert(r >= 0);
   auto blp = bl.begin();
   pg_pool_t pi;
@@ -1824,6 +1824,7 @@ int OSD::mkfs(CephContext *cct, ObjectStore *store, const string &dev,
 
   OSDSuperblock sb;
   bufferlist sbbl;
+  ObjectStore::CollectionHandle ch;
 
   // if we are fed a uuid for this osd, use it.
   store->set_fsid(cct->_conf->osd_uuid);
@@ -1844,8 +1845,13 @@ int OSD::mkfs(CephContext *cct, ObjectStore *store, const string &dev,
     goto free_store;
   }
 
-  ret = store->read(coll_t::meta(), OSD_SUPERBLOCK_GOBJECT, 0, 0, sbbl);
-  if (ret >= 0) {
+  ch = store->open_collection(coll_t::meta());
+  if (ch) {
+    ret = store->read(ch, OSD_SUPERBLOCK_GOBJECT, 0, 0, sbbl);
+    if (ret < 0) {
+      derr << "OSD::mkfs: have meta collection but no superblock" << dendl;
+      goto free_store;
+    }
     /* if we already have superblock, check content of superblock */
     dout(0) << " have superblock" << dendl;
     bufferlist::iterator p;
@@ -2626,7 +2632,7 @@ int OSD::init()
       if (c.is_pg(&pgid) &&
          !osdmap->have_pg_pool(pgid.pool())) {
        ghobject_t oid = make_final_pool_info_oid(pgid.pool());
-       if (!store->exists(coll_t::meta(), oid)) {
+       if (!store->exists(service.meta_ch, oid)) {
          derr << __func__ << " missing pg_pool_t for deleted pool "
               << pgid.pool() << " for pg " << pgid
               << "; please downgrade to luminous and allow "
@@ -2651,7 +2657,7 @@ int OSD::init()
   }
 
   // make sure snap mapper object exists
-  if (!store->exists(coll_t::meta(), OSD::make_snapmapper_oid())) {
+  if (!store->exists(service.meta_ch, OSD::make_snapmapper_oid())) {
     dout(10) << "init creating/touching snapmapper object" << dendl;
     ObjectStore::Transaction t;
     t.touch(coll_t::meta(), OSD::make_snapmapper_oid());
@@ -3686,7 +3692,7 @@ void OSD::write_superblock(ObjectStore::Transaction& t)
 int OSD::read_superblock()
 {
   bufferlist bl;
-  int r = store->read(coll_t::meta(), OSD_SUPERBLOCK_GOBJECT, 0, 0, bl);
+  int r = store->read(service.meta_ch, OSD_SUPERBLOCK_GOBJECT, 0, 0, bl);
   if (r < 0)
     return r;
 
@@ -3715,7 +3721,9 @@ void OSD::clear_temp_objects()
     ghobject_t next;
     while (1) {
       vector<ghobject_t> objects;
-      store->collection_list(*p, next, ghobject_t::get_max(),
+      auto ch = store->open_collection(*p);
+      assert(ch);
+      store->collection_list(ch, next, ghobject_t::get_max(),
                             store->get_ideal_list_max(),
                             &objects, &next);
       if (objects.empty())
@@ -3767,7 +3775,7 @@ void OSD::recursive_remove_collection(CephContext* cct,
   SnapMapper mapper(cct, &driver, 0, 0, 0, pgid.shard);
 
   vector<ghobject_t> objects;
-  store->collection_list(tmp, ghobject_t(), ghobject_t::get_max(),
+  store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
                         INT_MAX, &objects, 0);
   generic_dout(10) << __func__ << " " << objects << dendl;
   // delete them.
@@ -3832,7 +3840,7 @@ PG* OSD::_make_pg(
     // pool was deleted; grab final pg_pool_t off disk.
     ghobject_t oid = make_final_pool_info_oid(pgid.pool());
     bufferlist bl;
-    int r = store->read(coll_t::meta(), oid, 0, 0, bl);
+    int r = store->read(service.meta_ch, oid, 0, 0, bl);
     ceph_assert(r >= 0);
     auto p = bl.begin();
     decode(pi, p);
@@ -5124,15 +5132,21 @@ void TestOpsSocketHook::test_ops(OSDService *service, ObjectStore *store,
       //Debug: Output entire omap
       bufferlist hdrbl;
       map<string, bufferlist> keyvals;
-      r = store->omap_get(coll_t(pgid), ghobject_t(obj), &hdrbl, &keyvals);
-      if (r >= 0) {
+      auto ch = store->open_collection(coll_t(pgid));
+      if (!ch) {
+       ss << "unable to open collection for " << pgid;
+       r = -ENOENT;
+      } else {
+       r = store->omap_get(ch, ghobject_t(obj), &hdrbl, &keyvals);
+       if (r >= 0) {
           ss << "header=" << string(hdrbl.c_str(), hdrbl.length());
           for (map<string, bufferlist>::iterator it = keyvals.begin();
-              it != keyvals.end(); ++it)
+              it != keyvals.end(); ++it)
             ss << " key=" << (*it).first << " val="
                << string((*it).second.c_str(), (*it).second.length());
-      } else {
+       } else {
           ss << "error=" << r;
+       }
       }
     } else if (command == "truncobj") {
       int64_t trunclen;
index 28055987727548c58429ea4c24923e75e891f753..e5d7c9f1ed8a17e0d8c6616c4ece64f034f9b959 100644 (file)
@@ -3200,7 +3200,9 @@ bool PG::_has_removal_flag(ObjectStore *store,
   set<string> keys;
   keys.insert("_remove");
   map<string,bufferlist> values;
-  if (store->omap_get_values(coll, pgmeta_oid, keys, &values) == 0 &&
+  auto ch = store->open_collection(coll);
+  assert(ch);
+  if (store->omap_get_values(ch, pgmeta_oid, keys, &values) == 0 &&
       values.size() == 1)
     return true;
 
@@ -3224,7 +3226,9 @@ int PG::peek_map_epoch(ObjectStore *store,
   keys.insert(infover_key);
   keys.insert(epoch_key);
   map<string,bufferlist> values;
-  int r = store->omap_get_values(coll, pgmeta_oid, keys, &values);
+  auto ch = store->open_collection(coll);
+  assert(ch);
+  int r = store->omap_get_values(ch, pgmeta_oid, keys, &values);
   if (r == 0) {
     assert(values.size() == 2);
 
@@ -3437,7 +3441,9 @@ int PG::read_info(
   keys.insert(fastinfo_key);
   ghobject_t pgmeta_oid(pgid.make_pgmeta_oid());
   map<string,bufferlist> values;
-  int r = store->omap_get_values(coll, pgmeta_oid, keys, &values);
+  auto ch = store->open_collection(coll);
+  assert(ch);
+  int r = store->omap_get_values(ch, pgmeta_oid, keys, &values);
   assert(r == 0);
   assert(values.size() == 3 ||
         values.size() == 4);
@@ -3479,7 +3485,7 @@ void PG::read_state(ObjectStore *store)
   ostringstream oss;
   pg_log.read_log_and_missing(
     store,
-    coll,
+    ch,
     pgmeta_oid,
     info,
     oss,
@@ -6185,7 +6191,7 @@ void PG::handle_query_state(Formatter *f)
 
 void PG::update_store_with_options()
 {
-  auto r = osd->store->set_collection_opts(coll, pool.info.opts);
+  auto r = osd->store->set_collection_opts(ch, pool.info.opts);
   if(r < 0 && r != -EOPNOTSUPP) {
     derr << __func__ << " set_collection_opts returns error:" << r << dendl;
   }
@@ -6195,7 +6201,7 @@ void PG::update_store_on_load()
 {
   if (osd->store->get_type() == "filestore") {
     // legacy filestore didn't store collection bit width; fix.
-    int bits = osd->store->collection_bits(coll);
+    int bits = osd->store->collection_bits(ch);
     if (bits < 0) {
       assert(!coll.is_meta()); // otherwise OSD::load_pgs() did a bad thing
       bits = info.pgid.get_split_bits(pool.info.get_pg_num());
@@ -6245,7 +6251,7 @@ void PG::_delete_some()
                     (int)cct->_conf->osd_target_transaction_size);
   ghobject_t next;
   osd->store->collection_list(
-    coll,
+    ch,
     next,
     ghobject_t::get_max(),
     max,
index b340ebf219dbcf85c37502860f1707259b5a5e41..22476bcec6ad97f845ab58fedc0da2cbe46a2085 100644 (file)
@@ -915,9 +915,10 @@ void PGLog::_write_log_and_missing(
     t.omap_rmkeys(coll, log_oid, to_remove);
 }
 
-void PGLog::rebuild_missing_set_with_deletes(ObjectStore *store,
-                                            coll_t pg_coll,
-                                            const pg_info_t &info)
+void PGLog::rebuild_missing_set_with_deletes(
+  ObjectStore *store,
+  ObjectStore::CollectionHandle& ch,
+  const pg_info_t &info)
 {
   // save entries not generated from the current log (e.g. added due
   // to repair, EIO handling, or divergent_priors).
@@ -949,7 +950,7 @@ void PGLog::rebuild_missing_set_with_deletes(ObjectStore *store,
 
     bufferlist bv;
     int r = store->getattr(
-       pg_coll,
+      ch,
        ghobject_t(i->soid, ghobject_t::NO_GEN, info.pgid.shard),
        OI_ATTR,
        bv);
index fc98994d7ce41b3789e8da64717a678bc2b77c0f..b46e6c973f2718df70fee8d4f14d0614737f719b 100644 (file)
@@ -800,7 +800,7 @@ public:
                        pg_missing_t& omissing, pg_shard_t from) const;
 
   void rebuild_missing_set_with_deletes(ObjectStore *store,
-                                       coll_t pg_coll,
+                                       ObjectStore::CollectionHandle& ch,
                                        const pg_info_t &info);
 
 protected:
@@ -1251,7 +1251,7 @@ public:
 
   void read_log_and_missing(
     ObjectStore *store,
-    coll_t pg_coll,
+    ObjectStore::CollectionHandle& ch,
     ghobject_t pgmeta_oid,
     const pg_info_t &info,
     ostringstream &oss,
@@ -1259,7 +1259,7 @@ public:
     bool debug_verify_stored_missing = false
     ) {
     return read_log_and_missing(
-      store, pg_coll, pgmeta_oid, info,
+      store, ch, pgmeta_oid, info,
       log, missing, oss,
       tolerate_divergent_missing_log,
       &clear_divergent_priors,
@@ -1271,7 +1271,7 @@ public:
   template <typename missing_type>
   static void read_log_and_missing(
     ObjectStore *store,
-    coll_t pg_coll,
+    ObjectStore::CollectionHandle &ch,
     ghobject_t pgmeta_oid,
     const pg_info_t &info,
     IndexedLog &log,
@@ -1283,19 +1283,19 @@ public:
     set<string> *log_keys_debug = nullptr,
     bool debug_verify_stored_missing = false
     ) {
-    ldpp_dout(dpp, 20) << "read_log_and_missing coll " << pg_coll
+    ldpp_dout(dpp, 20) << "read_log_and_missing coll " << ch->cid
                       << " " << pgmeta_oid << dendl;
 
     // legacy?
     struct stat st;
-    int r = store->stat(pg_coll, pgmeta_oid, &st);
+    int r = store->stat(ch, pgmeta_oid, &st);
     assert(r == 0);
     assert(st.st_size == 0);
 
     // will get overridden below if it had been recorded
     eversion_t on_disk_can_rollback_to = info.last_update;
     eversion_t on_disk_rollback_info_trimmed_to = eversion_t();
-    ObjectMap::ObjectMapIterator p = store->get_omap_iterator(pg_coll,
+    ObjectMap::ObjectMapIterator p = store->get_omap_iterator(ch,
                                                              pgmeta_oid);
     map<eversion_t, hobject_t> divergent_priors;
     bool must_rebuild = false;
@@ -1387,7 +1387,7 @@ public:
 
          bufferlist bv;
          int r = store->getattr(
-           pg_coll,
+           ch,
            ghobject_t(i->soid, ghobject_t::NO_GEN, info.pgid.shard),
            OI_ATTR,
            bv);
@@ -1441,7 +1441,7 @@ public:
            }
            bufferlist bv;
            int r = store->getattr(
-             pg_coll,
+             ch,
              ghobject_t(i.first, ghobject_t::NO_GEN, info.pgid.shard),
              OI_ATTR,
              bv);
@@ -1465,7 +1465,7 @@ public:
            did.insert(i->second);
            bufferlist bv;
            int r = store->getattr(
-             pg_coll,
+             ch,
              ghobject_t(i->second, ghobject_t::NO_GEN, info.pgid.shard),
              OI_ATTR,
              bv);
index 36ccfbf61ede2b26824b46c2490ed6f0f6a94542..7dfd3a6b9481ddc481b7c3c2934909e20fe111d6 100644 (file)
@@ -6975,7 +6975,7 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
        bool truncated = false;
        if (oi.is_omap()) {
          ObjectMap::ObjectMapIterator iter = osd->store->get_omap_iterator(
-           coll, ghobject_t(soid)
+           ch, ghobject_t(soid)
            );
          assert(iter);
          iter->upper_bound(start_after);
@@ -7022,7 +7022,7 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
        bufferlist bl;
        if (oi.is_omap()) {
          ObjectMap::ObjectMapIterator iter = osd->store->get_omap_iterator(
-           coll, ghobject_t(soid)
+           ch, ghobject_t(soid)
            );
           if (!iter) {
             result = -ENOENT;
@@ -8422,7 +8422,7 @@ int PrimaryLogPG::do_copy_get(OpContext *ctx, bufferlist::iterator& bp,
       }
       bufferlist omap_data;
       ObjectMap::ObjectMapIterator iter =
-       osd->store->get_omap_iterator(coll, ghobject_t(oi.soid));
+       osd->store->get_omap_iterator(ch, ghobject_t(oi.soid));
       assert(iter);
       iter->upper_bound(cursor.omap_offset);
       for (; iter->valid(); iter->next(false)) {
@@ -11753,7 +11753,7 @@ void PrimaryLogPG::_on_new_interval()
   dout(20) << __func__ << " checking missing set deletes flag. missing = " << pg_log.get_missing() << dendl;
   if (!pg_log.get_missing().may_include_deletes &&
       get_osdmap()->test_flag(CEPH_OSDMAP_RECOVERY_DELETES)) {
-    pg_log.rebuild_missing_set_with_deletes(osd->store, coll, info);
+    pg_log.rebuild_missing_set_with_deletes(osd->store, ch, info);
   }
   assert(pg_log.get_missing().may_include_deletes == get_osdmap()->test_flag(CEPH_OSDMAP_RECOVERY_DELETES));
 }
index 10a7aadaf692fb13f3490c023aef661d28895064..506383a7ec74f02d041c2750f8931bfd97f48b6a 100644 (file)
@@ -717,7 +717,7 @@ int ReplicatedBackend::be_deep_scrub(
 
     bufferlist hdrbl;
     r = store->omap_get_header(
-      coll,
+      ch,
       ghobject_t(
        poid, ghobject_t::NO_GEN, get_parent()->whoami_shard().shard),
       &hdrbl, true);
@@ -736,7 +736,7 @@ int ReplicatedBackend::be_deep_scrub(
 
   // omap
   ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(
-    coll,
+    ch,
     ghobject_t(
       poid, ghobject_t::NO_GEN, get_parent()->whoami_shard().shard));
   assert(iter);
@@ -1919,7 +1919,7 @@ int ReplicatedBackend::build_push_op(const ObjectRecoveryInfo &recovery_info,
 
   eversion_t v  = recovery_info.version;
   if (progress.first) {
-    int r = store->omap_get_header(coll, ghobject_t(recovery_info.soid), &out_op->omap_header);
+    int r = store->omap_get_header(ch, ghobject_t(recovery_info.soid), &out_op->omap_header);
     if(r < 0) {
       dout(1) << __func__ << " get omap header failed: " << cpp_strerror(-r) << dendl; 
       return r;
@@ -1962,7 +1962,7 @@ int ReplicatedBackend::build_push_op(const ObjectRecoveryInfo &recovery_info,
   uint64_t available = cct->_conf->osd_recovery_max_chunk;
   if (!progress.omap_complete) {
     ObjectMap::ObjectMapIterator iter =
-      store->get_omap_iterator(coll,
+      store->get_omap_iterator(ch,
                               ghobject_t(recovery_info.soid));
     assert(iter);
     for (iter->lower_bound(progress.omap_recovered_to);
index 03e54c3f037435b9c0e076ce48311d1cc7b13720..a544c92b537102cae2cd2b70285b6e0b292f393c 100644 (file)
@@ -28,7 +28,7 @@ int OSDriver::get_keys(
   const std::set<std::string> &keys,
   std::map<std::string, bufferlist> *out)
 {
-  return os->omap_get_values(cid, hoid, keys, out);
+  return os->omap_get_values(ch, hoid, keys, out);
 }
 
 int OSDriver::get_next(
@@ -36,7 +36,7 @@ int OSDriver::get_next(
   pair<std::string, bufferlist> *next)
 {
   ObjectMap::ObjectMapIterator iter =
-    os->get_omap_iterator(cid, hoid);
+    os->get_omap_iterator(ch, hoid);
   if (!iter) {
     ceph_abort();
     return -EINVAL;
index 241f581b6d7f54cd74187a8937c25d86d5d9f300..ef2da3ccc18797b650553009181bfc016507720b 100644 (file)
@@ -29,7 +29,7 @@
 
 class OSDriver : public MapCacher::StoreDriver<std::string, bufferlist> {
   ObjectStore *os;
-  coll_t cid;
+  ObjectStore::CollectionHandle ch;
   ghobject_t hoid;
 
 public:
@@ -60,11 +60,14 @@ public:
 
   OSTransaction get_transaction(
     ObjectStore::Transaction *t) {
-    return OSTransaction(cid, hoid, t);
+    return OSTransaction(ch->cid, hoid, t);
   }
 
-  OSDriver(ObjectStore *os, coll_t cid, const ghobject_t &hoid) :
-    os(os), cid(cid), hoid(hoid) {}
+  OSDriver(ObjectStore *os, const coll_t& cid, const ghobject_t &hoid) :
+    os(os),
+    hoid(hoid) {
+    ch = os->open_collection(cid);
+  }
   int get_keys(
     const std::set<std::string> &keys,
     std::map<std::string, bufferlist> *out) override;
index 5d4ac0726114423503bfc22a7b8e510aebc410e9..745b93e9ae5b4500a6a3650ae0518a4ff198bb2c 100644 (file)
@@ -327,7 +327,7 @@ TEST_P(StoreTest, SimpleRemount) {
     t.create_collection(cid, 0);
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
-    bool exists = store->exists(cid, hoid);
+    bool exists = store->exists(ch, hoid);
     ASSERT_TRUE(!exists);
   }
   {
@@ -433,7 +433,7 @@ TEST_P(StoreTest, FiemapEmpty) {
   }
   {
     bufferlist bl;
-    store->fiemap(cid, oid, 0, 100000, bl);
+    store->fiemap(ch, oid, 0, 100000, bl);
     map<uint64_t,uint64_t> m, e;
     bufferlist::iterator p = bl.begin();
     decode(m, p);
@@ -472,7 +472,7 @@ TEST_P(StoreTest, FiemapHoles) {
   {
     //fiemap test from 0 to SKIP_STEP * (MAX_EXTENTS - 1) + 3
     bufferlist bl;
-    store->fiemap(cid, oid, 0, SKIP_STEP * (MAX_EXTENTS - 1) + 3, bl);
+    store->fiemap(ch, oid, 0, SKIP_STEP * (MAX_EXTENTS - 1) + 3, bl);
     map<uint64_t,uint64_t> m, e;
     bufferlist::iterator p = bl.begin();
     decode(m, p);
@@ -492,7 +492,7 @@ TEST_P(StoreTest, FiemapHoles) {
   {
     // fiemap test from SKIP_STEP to SKIP_STEP * (MAX_EXTENTS - 2) + 3
     bufferlist bl;
-    store->fiemap(cid, oid, SKIP_STEP, SKIP_STEP * (MAX_EXTENTS - 2) + 3, bl);
+    store->fiemap(ch, oid, SKIP_STEP, SKIP_STEP * (MAX_EXTENTS - 2) + 3, bl);
     map<uint64_t,uint64_t> m, e;
     auto p = bl.begin();
     decode(m, p);
@@ -684,7 +684,7 @@ TEST_P(StoreTest, SmallBlockWrites) {
     ASSERT_EQ(r, 0);
 
     bufferlist in, exp;
-    r = store->read(cid, hoid, 0, 0x4000, in);
+    r = store->read(ch, hoid, 0, 0x4000, in);
     ASSERT_EQ(0x1000, r);
     exp.append(a);
     ASSERT_TRUE(bl_eq(exp, in));
@@ -696,7 +696,7 @@ TEST_P(StoreTest, SmallBlockWrites) {
     ASSERT_EQ(r, 0);
 
     bufferlist in, exp;
-    r = store->read(cid, hoid, 0, 0x4000, in);
+    r = store->read(ch, hoid, 0, 0x4000, in);
     ASSERT_EQ(0x2000, r);
     exp.append(a);
     exp.append(b);
@@ -709,7 +709,7 @@ TEST_P(StoreTest, SmallBlockWrites) {
     ASSERT_EQ(r, 0);
 
     bufferlist in, exp;
-    r = store->read(cid, hoid, 0, 0x4000, in);
+    r = store->read(ch, hoid, 0, 0x4000, in);
     ASSERT_EQ(0x4000, r);
     exp.append(a);
     exp.append(b);
@@ -724,7 +724,7 @@ TEST_P(StoreTest, SmallBlockWrites) {
     ASSERT_EQ(r, 0);
 
     bufferlist in, exp;
-    r = store->read(cid, hoid, 0, 0x4000, in);
+    r = store->read(ch, hoid, 0, 0x4000, in);
     ASSERT_EQ(0x4000, r);
     exp.append(a);
     exp.append(b);
@@ -740,7 +740,7 @@ TEST_P(StoreTest, SmallBlockWrites) {
   }
   {
     bufferlist in, exp;
-    r = store->read(cid, hoid, 0, 0x4000, in);
+    r = store->read(ch, hoid, 0, 0x4000, in);
     ASSERT_EQ(0x4000, r);
     exp.append(c);
     exp.append(b);
@@ -763,9 +763,8 @@ TEST_P(StoreTest, BufferCacheReadTest) {
   coll_t cid;
   ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
   {
-    bufferlist in;
-    r = store->read(cid, hoid, 0, 5, in);
-    ASSERT_EQ(-ENOENT, r);
+    auto ch = store->open_collection(cid);
+    ASSERT_FALSE(ch);
   }
   auto ch = store->create_new_collection(cid);
   {
@@ -776,7 +775,7 @@ TEST_P(StoreTest, BufferCacheReadTest) {
     ASSERT_EQ(r, 0);
   }
   {
-    bool exists = store->exists(cid, hoid);
+    bool exists = store->exists(ch, hoid);
     ASSERT_TRUE(!exists);
 
     ObjectStore::Transaction t;
@@ -785,7 +784,7 @@ TEST_P(StoreTest, BufferCacheReadTest) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
 
-    exists = store->exists(cid, hoid);
+    exists = store->exists(ch, hoid);
     ASSERT_EQ(true, exists);
   }
   {
@@ -798,7 +797,7 @@ TEST_P(StoreTest, BufferCacheReadTest) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
 
-    r = store->read(cid, hoid, 0, 15, newdata);
+    r = store->read(ch, hoid, 0, 15, newdata);
     ASSERT_EQ(r, 15);
     {
       bufferlist expected;
@@ -819,7 +818,7 @@ TEST_P(StoreTest, BufferCacheReadTest) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
 
-    r = store->read(cid, hoid, 0, 15, newdata);
+    r = store->read(ch, hoid, 0, 15, newdata);
     ASSERT_EQ(r, 15);
     {
       bufferlist expected;
@@ -840,7 +839,7 @@ TEST_P(StoreTest, BufferCacheReadTest) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
 
-    r = store->read(cid, hoid, 0, 30, newdata);
+    r = store->read(ch, hoid, 0, 30, newdata);
     ASSERT_EQ(r, 30);
     {
       bufferlist expected;
@@ -868,7 +867,7 @@ TEST_P(StoreTest, BufferCacheReadTest) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
 
-    r = store->read(cid, hoid, 0, 40, newdata);
+    r = store->read(ch, hoid, 0, 40, newdata);
     ASSERT_EQ(r, 40);
     {
       bufferlist expected;
@@ -890,9 +889,8 @@ void doCompressionTest( boost::scoped_ptr<ObjectStore>& store)
   coll_t cid;
   ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
   {
-    bufferlist in;
-    r = store->read(cid, hoid, 0, 5, in);
-    ASSERT_EQ(-ENOENT, r);
+    auto ch = store->open_collection(cid);
+    ASSERT_FALSE(ch);
   }
   auto ch = store->create_new_collection(cid);
   {
@@ -903,7 +901,7 @@ void doCompressionTest( boost::scoped_ptr<ObjectStore>& store)
     ASSERT_EQ(r, 0);
   }
   {
-    bool exists = store->exists(cid, hoid);
+    bool exists = store->exists(ch, hoid);
     ASSERT_TRUE(!exists);
 
     ObjectStore::Transaction t;
@@ -912,7 +910,7 @@ void doCompressionTest( boost::scoped_ptr<ObjectStore>& store)
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
 
-    exists = store->exists(cid, hoid);
+    exists = store->exists(ch, hoid);
     ASSERT_EQ(true, exists);
   }
   std::string data;
@@ -928,7 +926,7 @@ void doCompressionTest( boost::scoped_ptr<ObjectStore>& store)
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
 
-    r = store->read(cid, hoid, 0, data.size() , newdata);
+    r = store->read(ch, hoid, 0, data.size() , newdata);
 
     ASSERT_EQ(r, (int)data.size());
     {
@@ -937,7 +935,7 @@ void doCompressionTest( boost::scoped_ptr<ObjectStore>& store)
       ASSERT_TRUE(bl_eq(expected, newdata));
     }
     newdata.clear();
-    r = store->read(cid, hoid, 0, 711 , newdata);
+    r = store->read(ch, hoid, 0, 711 , newdata);
     ASSERT_EQ(r, 711);
     {
       bufferlist expected;
@@ -945,7 +943,7 @@ void doCompressionTest( boost::scoped_ptr<ObjectStore>& store)
       ASSERT_TRUE(bl_eq(expected, newdata));
     }
     newdata.clear();
-    r = store->read(cid, hoid, 0xf00f, data.size(), newdata);
+    r = store->read(ch, hoid, 0xf00f, data.size(), newdata);
     ASSERT_EQ(r, int(data.size() - 0xf00f) );
     {
       bufferlist expected;
@@ -975,7 +973,7 @@ void doCompressionTest( boost::scoped_ptr<ObjectStore>& store)
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
 
-    r = store->read(cid, hoid, 0, 0x10000, newdata);
+    r = store->read(ch, hoid, 0, 0x10000, newdata);
     ASSERT_EQ(r, (int)0x10000);
     {
       bufferlist expected;
@@ -984,7 +982,7 @@ void doCompressionTest( boost::scoped_ptr<ObjectStore>& store)
       ASSERT_TRUE(bl_eq(expected, newdata));
     }
     newdata.clear();
-    r = store->read(cid, hoid, 0x9000, 711 , newdata);
+    r = store->read(ch, hoid, 0x9000, 711 , newdata);
     ASSERT_EQ(r, 711);
     {
       bufferlist expected;
@@ -992,7 +990,7 @@ void doCompressionTest( boost::scoped_ptr<ObjectStore>& store)
       ASSERT_TRUE(bl_eq(expected, newdata));
     }
     newdata.clear();
-    r = store->read(cid, hoid, 0x0, 0x40000, newdata);
+    r = store->read(ch, hoid, 0x0, 0x40000, newdata);
     ASSERT_EQ(r, int(0x40000) );
     {
       bufferlist expected;
@@ -1014,7 +1012,7 @@ void doCompressionTest( boost::scoped_ptr<ObjectStore>& store)
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
 
-    r = store->read(cid, hoid, 0, 0x3e000 - 1, newdata);
+    r = store->read(ch, hoid, 0, 0x3e000 - 1, newdata);
     ASSERT_EQ(r, (int)0x3e000 - 1);
     {
       bufferlist expected;
@@ -1022,7 +1020,7 @@ void doCompressionTest( boost::scoped_ptr<ObjectStore>& store)
       ASSERT_TRUE(bl_eq(expected, newdata));
     }
     newdata.clear();
-    r = store->read(cid, hoid, 0x3e000-1, 0x2001, newdata);
+    r = store->read(ch, hoid, 0x3e000-1, 0x2001, newdata);
     ASSERT_EQ(r, 0x2001);
     {
       bufferlist expected;
@@ -1031,7 +1029,7 @@ void doCompressionTest( boost::scoped_ptr<ObjectStore>& store)
       ASSERT_TRUE(bl_eq(expected, newdata));
     }
     newdata.clear();
-    r = store->read(cid, hoid, 0x0, 0x40000, newdata);
+    r = store->read(ch, hoid, 0x0, 0x40000, newdata);
     ASSERT_EQ(r, int(0x40000) );
     {
       bufferlist expected;
@@ -1052,7 +1050,7 @@ void doCompressionTest( boost::scoped_ptr<ObjectStore>& store)
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
 
-    r = store->read(cid, hoid, 0x3e000, 0x2000, newdata);
+    r = store->read(ch, hoid, 0x3e000, 0x2000, newdata);
     ASSERT_EQ(r, (int)0x2000);
     {
       bufferlist expected;
@@ -1133,9 +1131,8 @@ TEST_P(StoreTest, SimpleObjectTest) {
   coll_t cid;
   ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
   {
-    bufferlist in;
-    r = store->read(cid, hoid, 0, 5, in);
-    ASSERT_EQ(-ENOENT, r);
+    auto ch = store->open_collection(cid);
+    ASSERT_FALSE(ch);
   }
   auto ch = store->create_new_collection(cid);
   {
@@ -1146,7 +1143,7 @@ TEST_P(StoreTest, SimpleObjectTest) {
     ASSERT_EQ(r, 0);
   }
   {
-    bool exists = store->exists(cid, hoid);
+    bool exists = store->exists(ch, hoid);
     ASSERT_TRUE(!exists);
 
     ObjectStore::Transaction t;
@@ -1155,7 +1152,7 @@ TEST_P(StoreTest, SimpleObjectTest) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
 
-    exists = store->exists(cid, hoid);
+    exists = store->exists(ch, hoid);
     ASSERT_EQ(true, exists);
   }
   {
@@ -1178,7 +1175,7 @@ TEST_P(StoreTest, SimpleObjectTest) {
     ASSERT_EQ(r, 0);
 
     bufferlist in;
-    r = store->read(cid, hoid, 0, 5, in);
+    r = store->read(ch, hoid, 0, 5, in);
     ASSERT_EQ(5, r);
     ASSERT_TRUE(bl_eq(orig, in));
   }
@@ -1194,7 +1191,7 @@ TEST_P(StoreTest, SimpleObjectTest) {
     ASSERT_EQ(r, 0);
 
     bufferlist in;
-    r = store->read(cid, hoid, 0, 10, in);
+    r = store->read(ch, hoid, 0, 10, in);
     ASSERT_EQ(10, r);
     ASSERT_TRUE(bl_eq(exp, in));
   }
@@ -1209,7 +1206,7 @@ TEST_P(StoreTest, SimpleObjectTest) {
     ASSERT_EQ(r, 0);
 
     bufferlist in;
-    r = store->read(cid, hoid, 0, 10, in);
+    r = store->read(ch, hoid, 0, 10, in);
     ASSERT_EQ(10, r);
     ASSERT_TRUE(bl_eq(exp, in));
   }
@@ -1224,7 +1221,7 @@ TEST_P(StoreTest, SimpleObjectTest) {
 
     bufferlist in, exp;
     exp.append("abcabcdede");
-    r = store->read(cid, hoid, 0, 10, in);
+    r = store->read(ch, hoid, 0, 10, in);
     ASSERT_EQ(10, r);
     in.hexdump(cout);
     ASSERT_TRUE(bl_eq(exp, in));
@@ -1252,7 +1249,7 @@ TEST_P(StoreTest, SimpleObjectTest) {
 
     bufferlist in, exp;
     exp.append("abcdefghij");
-    r = store->read(cid, hoid, 0, 10, in);
+    r = store->read(ch, hoid, 0, 10, in);
     ASSERT_EQ(10, r);
     in.hexdump(cout);
     ASSERT_TRUE(bl_eq(exp, in));
@@ -1267,7 +1264,7 @@ TEST_P(StoreTest, SimpleObjectTest) {
     ASSERT_EQ(r, 0);
 
     bufferlist in;
-    r = store->read(cid, hoid, 0, bl.length(), in);
+    r = store->read(ch, hoid, 0, bl.length(), in);
     ASSERT_EQ((int)bl.length(), r);
     in.hexdump(cout);
     ASSERT_TRUE(bl_eq(bl, in));
@@ -1278,7 +1275,7 @@ TEST_P(StoreTest, SimpleObjectTest) {
 
     //test: offset=len=0 mean read all data
     bufferlist in;
-    r = store->read(cid, hoid, 0, 0, in);
+    r = store->read(ch, hoid, 0, 0, in);
     ASSERT_EQ((int)bl.length(), r);
     in.hexdump(cout);
     ASSERT_TRUE(bl_eq(bl, in));
@@ -1302,11 +1299,11 @@ TEST_P(StoreTest, SimpleObjectTest) {
     exp1.append(s1);
     exp2.append(s2);
     exp3.append(s3);
-    r = store->read(cid, hoid, 0x1000-1, 1, in);
+    r = store->read(ch, hoid, 0x1000-1, 1, in);
     ASSERT_EQ(1, r);
     ASSERT_TRUE(bl_eq(exp1, in));
     in.clear();
-    r = store->read(cid, hoid, 0x1000, 0x1000, in);
+    r = store->read(ch, hoid, 0x1000, 0x1000, in);
     ASSERT_EQ(0x1000, r);
     ASSERT_TRUE(bl_eq(exp2, in));
 
@@ -1320,15 +1317,15 @@ TEST_P(StoreTest, SimpleObjectTest) {
       ASSERT_EQ(r, 0);
     }
     in.clear();
-    r = store->read(cid, hoid, 1, 2, in);
+    r = store->read(ch, hoid, 1, 2, in);
     ASSERT_EQ(2, r);
     ASSERT_TRUE(bl_eq(exp3, in));
     in.clear();
-    r = store->read(cid, hoid, 0x1000-1, 1, in);
+    r = store->read(ch, hoid, 0x1000-1, 1, in);
     ASSERT_EQ(1, r);
     ASSERT_TRUE(bl_eq(exp1, in));
     in.clear();
-    r = store->read(cid, hoid, 0x1000, 0x1000, in);
+    r = store->read(ch, hoid, 0x1000, 0x1000, in);
     ASSERT_EQ(0x1000, r);
     ASSERT_TRUE(bl_eq(exp2, in));
 
@@ -1361,9 +1358,8 @@ TEST_P(StoreTestSpecificAUSize, BluestoreStatFSTest) {
   ghobject_t hoid2 = hoid;
   hoid2.hobj.snap = 1;
   {
-    bufferlist in;
-    r = store->read(cid, hoid, 0, 5, in);
-    ASSERT_EQ(-ENOENT, r);
+    auto ch = store->open_collection(cid);
+    ASSERT_FALSE(ch);
   }
   auto ch = store->create_new_collection(cid);
   {
@@ -1374,7 +1370,7 @@ TEST_P(StoreTestSpecificAUSize, BluestoreStatFSTest) {
     ASSERT_EQ(r, 0);
   }
   {
-    bool exists = store->exists(cid, hoid);
+    bool exists = store->exists(ch, hoid);
     ASSERT_TRUE(!exists);
 
     ObjectStore::Transaction t;
@@ -1383,7 +1379,7 @@ TEST_P(StoreTestSpecificAUSize, BluestoreStatFSTest) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
 
-    exists = store->exists(cid, hoid);
+    exists = store->exists(ch, hoid);
     ASSERT_EQ(true, exists);
   }
   {
@@ -1626,7 +1622,7 @@ TEST_P(StoreTestSpecificAUSize, BluestoreFragmentedBlobTest) {
     ASSERT_EQ(r, 0);
   }
   {
-    bool exists = store->exists(cid, hoid);
+    bool exists = store->exists(ch, hoid);
     ASSERT_TRUE(!exists);
 
     ObjectStore::Transaction t;
@@ -1635,7 +1631,7 @@ TEST_P(StoreTestSpecificAUSize, BluestoreFragmentedBlobTest) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
 
-    exists = store->exists(cid, hoid);
+    exists = store->exists(ch, hoid);
     ASSERT_EQ(true, exists);
   }
   {
@@ -1667,7 +1663,7 @@ TEST_P(StoreTestSpecificAUSize, BluestoreFragmentedBlobTest) {
     ASSERT_EQ(0x20000, statfs.stored);
     ASSERT_EQ(0x20000, statfs.allocated);
 
-    r = store->read(cid, hoid, 0, data.size(), newdata);
+    r = store->read(ch, hoid, 0, data.size(), newdata);
     ASSERT_EQ(r, (int)data.size());
     {
       bufferlist expected;
@@ -1678,7 +1674,7 @@ TEST_P(StoreTestSpecificAUSize, BluestoreFragmentedBlobTest) {
     }
     newdata.clear();
 
-    r = store->read(cid, hoid, 1, data.size()-2, newdata);
+    r = store->read(ch, hoid, 1, data.size()-2, newdata);
     ASSERT_EQ(r, (int)data.size()-2);
     {
       bufferlist expected;
@@ -1711,7 +1707,7 @@ TEST_P(StoreTestSpecificAUSize, BluestoreFragmentedBlobTest) {
     ASSERT_EQ(0x20000, statfs.allocated);
     ASSERT_EQ(0x20000, statfs.stored);
 
-    r = store->read(cid, hoid, 0x20000-1, 21, newdata);
+    r = store->read(ch, hoid, 0x20000-1, 21, newdata);
     ASSERT_EQ(r, (int)21);
     {
       bufferlist expected;
@@ -1744,7 +1740,7 @@ TEST_P(StoreTestSpecificAUSize, BluestoreFragmentedBlobTest) {
     ASSERT_EQ(0x30000, statfs.allocated);
     ASSERT_EQ(0x20003, statfs.stored);
 
-    r = store->read(cid, hoid, 0x10000-1, 0x10000+22, newdata);
+    r = store->read(ch, hoid, 0x10000-1, 0x10000+22, newdata);
     ASSERT_EQ(r, (int)0x10000+22);
     {
       bufferlist expected;
@@ -1775,7 +1771,7 @@ TEST_P(StoreTestSpecificAUSize, BluestoreFragmentedBlobTest) {
     ASSERT_EQ(0x10000, statfs.allocated);
     ASSERT_EQ(0x10000, statfs.stored);
 
-    r = store->read(cid, hoid, 0, 0x30000, newdata);
+    r = store->read(ch, hoid, 0, 0x30000, newdata);
     ASSERT_EQ(r, (int)0x30000);
     {
       bufferlist expected;
@@ -1895,7 +1891,7 @@ TEST_P(StoreTest, MultiSmallWriteSameBlock) {
   d.wait();
   {
     bufferlist bl2;
-    r = store->read(cid, a, 0, 16000, bl2);
+    r = store->read(ch, a, 0, 16000, bl2);
     ASSERT_GE(r, 0);
   }
   {
@@ -1939,7 +1935,7 @@ TEST_P(StoreTest, SmallSkipFront) {
   }
   {
     bufferlist bl;
-    ASSERT_EQ(8192, store->read(cid, a, 0, 8192, bl));
+    ASSERT_EQ(8192, store->read(ch, a, 0, 8192, bl));
     for (unsigned i=0; i<4096; ++i)
       ASSERT_EQ(0, bl[i]);
     for (unsigned i=4096; i<8192; ++i)
@@ -2019,7 +2015,7 @@ TEST_P(StoreTest, AppendDeferredVsTailCache) {
   bufferlist actual;
   {
     ASSERT_EQ((int)final.length(),
-             store->read(cid, a, 0, final.length(), actual));
+             store->read(ch, a, 0, final.length(), actual));
     ASSERT_TRUE(bl_eq(final, actual));
   }
   {
@@ -2099,7 +2095,7 @@ TEST_P(StoreTest, AppendZeroTrailingSharedBlock) {
   bufferlist actual;
   {
     ASSERT_EQ((int)final.length(),
-             store->read(cid, a, 0, final.length(), actual));
+             store->read(ch, a, 0, final.length(), actual));
     final.hexdump(cout);
     actual.hexdump(cout);
     ASSERT_TRUE(bl_eq(final, actual));
@@ -2279,7 +2275,7 @@ TEST_P(StoreTest, MiscFragmentTests) {
   }
   {
     bufferlist inbl;
-    int r = store->read(cid, a, 524288 + 131072, 1024, inbl);
+    int r = store->read(ch, a, 524288 + 131072, 1024, inbl);
     ASSERT_EQ(r, 1024);
     ASSERT_EQ(inbl.length(), 1024u);
     ASSERT_TRUE(inbl.is_zero());
@@ -2322,7 +2318,7 @@ TEST_P(StoreTest, ZeroVsObjectSize) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
   }
-  ASSERT_EQ(0, store->stat(cid, hoid, &stat));
+  ASSERT_EQ(0, store->stat(ch, hoid, &stat));
   ASSERT_EQ(5, stat.st_size);
   {
     ObjectStore::Transaction t;
@@ -2330,7 +2326,7 @@ TEST_P(StoreTest, ZeroVsObjectSize) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
   }
-  ASSERT_EQ(0, store->stat(cid, hoid, &stat));
+  ASSERT_EQ(0, store->stat(ch, hoid, &stat));
   ASSERT_EQ(5, stat.st_size);
   {
     ObjectStore::Transaction t;
@@ -2338,7 +2334,7 @@ TEST_P(StoreTest, ZeroVsObjectSize) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
   }
-  ASSERT_EQ(0, store->stat(cid, hoid, &stat));
+  ASSERT_EQ(0, store->stat(ch, hoid, &stat));
   ASSERT_EQ(203, stat.st_size);
   {
     ObjectStore::Transaction t;
@@ -2346,7 +2342,7 @@ TEST_P(StoreTest, ZeroVsObjectSize) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
   }
-  ASSERT_EQ(0, store->stat(cid, hoid, &stat));
+  ASSERT_EQ(0, store->stat(ch, hoid, &stat));
   ASSERT_EQ(100200, stat.st_size);
 }
 
@@ -2370,12 +2366,12 @@ TEST_P(StoreTest, ZeroLengthWrite) {
     ASSERT_EQ(r, 0);
   }
   struct stat stat;
-  r = store->stat(cid, hoid, &stat);
+  r = store->stat(ch, hoid, &stat);
   ASSERT_EQ(0, r);
   ASSERT_EQ(0, stat.st_size);
 
   bufferlist newdata;
-  r = store->read(cid, hoid, 0, 1048576, newdata);
+  r = store->read(ch, hoid, 0, 1048576, newdata);
   ASSERT_EQ(0, r);
 }
 
@@ -2398,12 +2394,12 @@ TEST_P(StoreTest, ZeroLengthZero) {
     ASSERT_EQ(0, r);
   }
   struct stat stat;
-  r = store->stat(cid, hoid, &stat);
+  r = store->stat(ch, hoid, &stat);
   ASSERT_EQ(0, r);
   ASSERT_EQ(0, stat.st_size);
 
   bufferlist newdata;
-  r = store->read(cid, hoid, 0, 1048576, newdata);
+  r = store->read(ch, hoid, 0, 1048576, newdata);
   ASSERT_EQ(0, r);
 }
 
@@ -2415,12 +2411,8 @@ TEST_P(StoreTest, SimpleAttrTest) {
   val.append("value");
   val.append("value2");
   {
-    bufferptr bp;
-    map<string,bufferptr> aset;
-    r = store->getattr(cid, hoid, "nofoo", bp);
-    ASSERT_EQ(-ENOENT, r);
-    r = store->getattrs(cid, hoid, aset);
-    ASSERT_EQ(-ENOENT, r);
+    auto ch = store->open_collection(cid);
+    ASSERT_FALSE(ch);
   }
   auto ch = store->create_new_collection(cid);
   {
@@ -2432,13 +2424,13 @@ TEST_P(StoreTest, SimpleAttrTest) {
   ch->flush();
   {
     bool empty;
-    int r = store->collection_empty(cid, &empty);
+    int r = store->collection_empty(ch, &empty);
     ASSERT_EQ(0, r);
     ASSERT_TRUE(empty);
   }
   {
     bufferptr bp;
-    r = store->getattr(cid, hoid, "nofoo", bp);
+    r = store->getattr(ch, hoid, "nofoo", bp);
     ASSERT_EQ(-ENOENT, r);
   }
   {
@@ -2452,23 +2444,23 @@ TEST_P(StoreTest, SimpleAttrTest) {
   ch->flush();
   {
     bool empty;
-    int r = store->collection_empty(cid, &empty);
+    int r = store->collection_empty(ch, &empty);
     ASSERT_EQ(0, r);
     ASSERT_TRUE(!empty);
   }
   {
     bufferptr bp;
-    r = store->getattr(cid, hoid, "nofoo", bp);
+    r = store->getattr(ch, hoid, "nofoo", bp);
     ASSERT_EQ(-ENODATA, r);
 
-    r = store->getattr(cid, hoid, "foo", bp);
+    r = store->getattr(ch, hoid, "foo", bp);
     ASSERT_EQ(0, r);
     bufferlist bl;
     bl.append(bp);
     ASSERT_TRUE(bl_eq(val, bl));
 
     map<string,bufferptr> bm;
-    r = store->getattrs(cid, hoid, bm);
+    r = store->getattrs(ch, hoid, bm);
     ASSERT_EQ(0, r);
 
   }
@@ -2514,7 +2506,7 @@ TEST_P(StoreTest, SimpleListTest) {
     vector<ghobject_t> objects;
     ghobject_t next, current;
     while (!next.is_max()) {
-      int r = store->collection_list(cid, current, ghobject_t::get_max(),
+      int r = store->collection_list(ch, current, ghobject_t::get_max(),
                                     50,
                                     &objects, &next);
       ASSERT_EQ(r, 0);
@@ -2580,7 +2572,7 @@ TEST_P(StoreTest, ListEndTest) {
     end.hobj.pool = 1;
     vector<ghobject_t> objects;
     ghobject_t next;
-    int r = store->collection_list(cid, ghobject_t(), end, 500,
+    int r = store->collection_list(ch, ghobject_t(), end, 500,
                                   &objects, &next);
     ASSERT_EQ(r, 0);
     for (auto &p : objects) {
@@ -2661,7 +2653,7 @@ TEST_P(StoreTest, MultipoolListTest) {
     vector<ghobject_t> objects;
     ghobject_t next, current;
     while (!next.is_max()) {
-      int r = store->collection_list(cid, current, ghobject_t::get_max(), 50,
+      int r = store->collection_list(ch, current, ghobject_t::get_max(), 50,
                                     &objects, &next);
       ASSERT_EQ(r, 0);
       cout << " got " << objects.size() << " next " << next << std::endl;
@@ -2730,31 +2722,31 @@ TEST_P(StoreTest, SimpleCloneTest) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
 
-    r = store->read(cid, hoid, 10, 5, newdata);
+    r = store->read(ch, hoid, 10, 5, newdata);
     ASSERT_EQ(r, 5);
     ASSERT_TRUE(bl_eq(large, newdata));
 
     newdata.clear();
-    r = store->read(cid, hoid, 0, 5, newdata);
+    r = store->read(ch, hoid, 0, 5, newdata);
     ASSERT_EQ(r, 5);
     ASSERT_TRUE(bl_eq(small, newdata));
 
     newdata.clear();
-    r = store->read(cid, hoid2, 10, 5, newdata);
+    r = store->read(ch, hoid2, 10, 5, newdata);
     ASSERT_EQ(r, 5);
     ASSERT_TRUE(bl_eq(small, newdata));
 
-    r = store->getattr(cid, hoid2, "attr2", attr);
+    r = store->getattr(ch, hoid2, "attr2", attr);
     ASSERT_EQ(r, 0);
     ASSERT_TRUE(bl_eq(small, attr));
 
     attr.clear();
-    r = store->getattr(cid, hoid2, "attr3", attr);
+    r = store->getattr(ch, hoid2, "attr3", attr);
     ASSERT_EQ(r, 0);
     ASSERT_TRUE(bl_eq(xlarge, attr));
 
     attr.clear();
-    r = store->getattr(cid, hoid, "attr1", attr);
+    r = store->getattr(ch, hoid, "attr1", attr);
     ASSERT_EQ(r, 0);
     ASSERT_TRUE(bl_eq(large, attr));
   }
@@ -2784,7 +2776,7 @@ TEST_P(StoreTest, SimpleCloneTest) {
     ASSERT_EQ(r, 0);
     bufferlist rl;
     ASSERT_EQ((int)final.length(),
-             store->read(cid, hoid, 0, final.length(), rl));
+             store->read(ch, hoid, 0, final.length(), rl));
     ASSERT_TRUE(bl_eq(rl, final));
   }
   {
@@ -2816,7 +2808,7 @@ TEST_P(StoreTest, SimpleCloneTest) {
     ASSERT_EQ(r, 0);
     bufferlist rl;
     ASSERT_EQ((int)final.length(),
-             store->read(cid, hoid, 0, final.length(), rl));
+             store->read(ch, hoid, 0, final.length(), rl));
     ASSERT_TRUE(bl_eq(rl, final));
   }
   {
@@ -2847,7 +2839,7 @@ TEST_P(StoreTest, SimpleCloneTest) {
     ASSERT_EQ(0, apply_transaction(store, ch, std::move(t)));
     bufferlist rl;
     ASSERT_EQ((int)final.length(),
-             store->read(cid, hoid, 0, final.length(), rl));
+             store->read(ch, hoid, 0, final.length(), rl));
     /*cout << "expected:\n";
     final.hexdump(cout);
     cout << "got:\n";
@@ -2882,7 +2874,7 @@ TEST_P(StoreTest, SimpleCloneTest) {
     end.substr_of(pl, al.length()*2, pl.length() - al.length()*2);
     final.append(end);
     ASSERT_EQ((int)final.length(),
-             store->read(cid, hoid, 0, final.length(), rl));
+             store->read(ch, hoid, 0, final.length(), rl));
     /*cout << "expected:\n";
     final.hexdump(cout);
     cout << "got:\n";
@@ -2917,7 +2909,7 @@ TEST_P(StoreTest, SimpleCloneTest) {
     end.substr_of(pl, final.length(), pl.length() - final.length());
     final.append(end);
     ASSERT_EQ((int)final.length(),
-             store->read(cid, hoid, 0, final.length(), rl));
+             store->read(ch, hoid, 0, final.length(), rl));
     /*cout << "expected:\n";
     final.hexdump(cout);
     cout << "got:\n";
@@ -2952,7 +2944,7 @@ TEST_P(StoreTest, SimpleCloneTest) {
     end.substr_of(pl, final.length(), pl.length() - final.length());
     final.append(end);
     ASSERT_EQ((int)final.length(),
-             store->read(cid, hoid, 0, final.length(), rl));
+             store->read(ch, hoid, 0, final.length(), rl));
     /*cout << "expected:\n";
     final.hexdump(cout);
     cout << "got:\n";
@@ -3050,7 +3042,7 @@ TEST_P(StoreTest, OmapSimple) {
   {
     bufferlist h;
     map<string,bufferlist> r;
-    store->omap_get(cid, hoid, &h, &r);
+    store->omap_get(ch, hoid, &h, &r);
     ASSERT_TRUE(bl_eq(header, h));
     ASSERT_EQ(r.size(), km.size());
     cout << "r: " << r << std::endl;
@@ -3058,7 +3050,7 @@ TEST_P(StoreTest, OmapSimple) {
   // test iterator with seek_to_first
   {
     map<string,bufferlist> r;
-    ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(cid, hoid);
+    ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(ch, hoid);
     for (iter->seek_to_first(); iter->valid(); iter->next(false)) {
       r[iter->key()] = iter->value();
     }
@@ -3068,7 +3060,7 @@ TEST_P(StoreTest, OmapSimple) {
   // test iterator with initial lower_bound
   {
     map<string,bufferlist> r;
-    ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(cid, hoid);
+    ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(ch, hoid);
     for (iter->lower_bound(string()); iter->valid(); iter->next(false)) {
       r[iter->key()] = iter->value();
     }
@@ -3126,7 +3118,7 @@ TEST_P(StoreTest, OmapCloneTest) {
   {
     map<string,bufferlist> r;
     bufferlist h;
-    store->omap_get(cid, hoid2, &h, &r);
+    store->omap_get(ch, hoid2, &h, &r);
     ASSERT_TRUE(bl_eq(header, h));
     ASSERT_EQ(r.size(), km.size());
   }
@@ -3171,7 +3163,7 @@ TEST_P(StoreTest, SimpleCloneRangeTest) {
     cerr << "Clone range object" << std::endl;
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
-    r = store->read(cid, hoid2, 10, 5, newdata);
+    r = store->read(ch, hoid2, 10, 5, newdata);
     ASSERT_EQ(r, 5);
     ASSERT_TRUE(bl_eq(small, newdata));
   }
@@ -3183,8 +3175,8 @@ TEST_P(StoreTest, SimpleCloneRangeTest) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
     struct stat stat, stat2;
-    r = store->stat(cid, hoid, &stat);
-    r = store->stat(cid, hoid2, &stat2);
+    r = store->stat(ch, hoid, &stat);
+    r = store->stat(ch, hoid2, &stat2);
     ASSERT_EQ(stat.st_size, stat2.st_size);
     ASSERT_EQ(1024*1024, stat2.st_size);
   }
@@ -3323,14 +3315,14 @@ TEST_P(StoreTest, ManyObjectTest) {
        i != created.end();
        ++i) {
     struct stat buf;
-    ASSERT_TRUE(!store->stat(cid, *i, &buf));
+    ASSERT_TRUE(!store->stat(ch, *i, &buf));
   }
 
   ch->flush();
 
   set<ghobject_t> listed, listed2;
   vector<ghobject_t> objects;
-  r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, &objects, 0);
+  r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(), INT_MAX, &objects, 0);
   ASSERT_EQ(r, 0);
 
   cerr << "objects.size() is " << objects.size() << std::endl;
@@ -3345,7 +3337,7 @@ TEST_P(StoreTest, ManyObjectTest) {
   ghobject_t start, next;
   objects.clear();
   r = store->collection_list(
-    cid,
+    ch,
     ghobject_t::get_max(),
     ghobject_t::get_max(),
     50,
@@ -3359,7 +3351,7 @@ TEST_P(StoreTest, ManyObjectTest) {
   listed.clear();
   ghobject_t start2, next2;
   while (1) {
-    r = store->collection_list(cid, start, ghobject_t::get_max(),
+    r = store->collection_list(ch, start, ghobject_t::get_max(),
                               50,
                               &objects,
                               &next);
@@ -3488,7 +3480,7 @@ public:
       state->cond.Signal();
 
       bufferlist r2;
-      r = state->store->read(state->cid, hoid, 0, state->contents[hoid].data.length(), r2);
+      r = state->store->read(state->ch, hoid, 0, state->contents[hoid].data.length(), r2);
       assert(bl_eq(state->contents[hoid].data, r2));
       state->cond.Signal();
     }
@@ -3514,7 +3506,7 @@ public:
       --(state->in_flight);
       bufferlist r2;
       r = state->store->read(
-       state->cid, noid, 0,
+       state->ch, noid, 0,
        state->contents[noid].data.length(), r2);
       assert(bl_eq(state->contents[noid].data, r2));
       state->cond.Signal();
@@ -3542,7 +3534,7 @@ public:
         state->available_objects.insert(noid);
       --(state->in_flight);
       bufferlist r2;
-      r = state->store->read(state->cid, noid, 0, state->contents[noid].data.length(), r2);
+      r = state->store->read(state->ch, noid, 0, state->contents[noid].data.length(), r2);
       assert(bl_eq(state->contents[noid].data, r2));
       state->cond.Signal();
     }
@@ -3588,7 +3580,7 @@ public:
     while (1) {
       ch->flush();
       vector<ghobject_t> objects;
-      int r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(),
+      int r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
                                     10, &objects, 0);
       assert(r >= 0);
       if (objects.empty())
@@ -4016,7 +4008,7 @@ public:
         << " size " << expected.length()
         << " offset " << offset
         << " len " << len << std::endl;
-    r = store->read(cid, obj, offset, len, result);
+    r = store->read(ch, obj, offset, len, result);
     if (offset >= expected.length()) {
       ASSERT_EQ(r, 0);
     } else {
@@ -4099,7 +4091,7 @@ public:
       expected = contents[obj].attrs;
     }
     map<string, bufferlist> attrs;
-    int r = store->getattrs(cid, obj, attrs);
+    int r = store->getattrs(ch, obj, attrs);
     ASSERT_TRUE(r == 0);
     ASSERT_TRUE(attrs.size() == expected.size());
     for (map<string, bufferlist>::iterator it = expected.begin();
@@ -4138,7 +4130,7 @@ public:
     }
 
     bufferlist bl;
-    r = store->getattr(cid, obj, it->first, bl);
+    r = store->getattr(ch, obj, it->first, bl);
     ASSERT_EQ(r, 0);
     ASSERT_TRUE(bl_eq(it->second, bl));
   }
@@ -4202,7 +4194,7 @@ public:
     ghobject_t next, current;
     while (1) {
       //cerr << "scanning..." << std::endl;
-      int r = store->collection_list(cid, current, ghobject_t::get_max(), 100,
+      int r = store->collection_list(ch, current, ghobject_t::get_max(), 100,
                                     &objects, &next);
       ASSERT_EQ(r, 0);
       ASSERT_TRUE(sorted(objects));
@@ -4236,7 +4228,7 @@ public:
       ASSERT_GT(available_objects.count(*i), (unsigned)0);
     }
 
-    int r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(),
+    int r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
                                   INT_MAX, &objects, 0);
     ASSERT_EQ(r, 0);
     objects_set2.insert(objects.begin(), objects.end());
@@ -4267,7 +4259,7 @@ public:
       expected = contents[hoid].data.length();
     }
     struct stat buf;
-    int r = store->stat(cid, hoid, &buf);
+    int r = store->stat(ch, hoid, &buf);
     ASSERT_EQ(0, r);
     assert((uint64_t)buf.st_size == expected);
     ASSERT_TRUE((uint64_t)buf.st_size == expected);
@@ -4619,7 +4611,7 @@ TEST_P(StoreTest, HashCollisionTest) {
   }
   vector<ghobject_t> objects;
   ch->flush();
-  r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, &objects, 0);
+  r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(), INT_MAX, &objects, 0);
   ASSERT_EQ(r, 0);
   set<ghobject_t> listed(objects.begin(), objects.end());
   cerr << "listed.size() is " << listed.size() << " and created.size() is " << created.size() << std::endl;
@@ -4628,7 +4620,7 @@ TEST_P(StoreTest, HashCollisionTest) {
   listed.clear();
   ghobject_t current, next;
   while (1) {
-    r = store->collection_list(cid, current, ghobject_t::get_max(), 60,
+    r = store->collection_list(ch, current, ghobject_t::get_max(), 60,
                               &objects, &next);
     ASSERT_EQ(r, 0);
     ASSERT_TRUE(sorted(objects));
@@ -4718,7 +4710,7 @@ TEST_P(StoreTest, ScrubTest) {
 
   ch->flush();
   vector<ghobject_t> objects;
-  r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(),
+  r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
                             INT_MAX, &objects, 0);
   ASSERT_EQ(r, 0);
   set<ghobject_t> listed(objects.begin(), objects.end());
@@ -4728,7 +4720,7 @@ TEST_P(StoreTest, ScrubTest) {
   listed.clear();
   ghobject_t current, next;
   while (1) {
-    r = store->collection_list(cid, current, ghobject_t::get_max(), 60,
+    r = store->collection_list(ch, current, ghobject_t::get_max(), 60,
                               &objects, &next);
     ASSERT_EQ(r, 0);
     ASSERT_TRUE(sorted(objects));
@@ -4798,7 +4790,7 @@ TEST_P(StoreTest, OMapTest) {
     ObjectStore::Transaction t;
     bufferlist bl;
     map<string, bufferlist> cur_attrs;
-    r = store->omap_get(cid, hoid, &bl, &cur_attrs);
+    r = store->omap_get(ch, hoid, &bl, &cur_attrs);
     ASSERT_EQ(r, 0);
     for (map<string, bufferlist>::iterator j = attrs.begin();
         j != attrs.end();
@@ -4835,7 +4827,7 @@ TEST_P(StoreTest, OMapTest) {
     ObjectStore::Transaction t;
     bufferlist bl;
     map<string, bufferlist> cur_attrs;
-    r = store->omap_get(cid, hoid, &bl, &cur_attrs);
+    r = store->omap_get(ch, hoid, &bl, &cur_attrs);
     ASSERT_EQ(r, 0);
     for (map<string, bufferlist>::iterator j = attrs.begin();
         j != attrs.end();
@@ -4881,13 +4873,13 @@ TEST_P(StoreTest, OMapTest) {
 
     bufferlist bl3;
     map<string, bufferlist> cur_attrs;
-    r = store->omap_get(cid, hoid, &bl3, &cur_attrs);
+    r = store->omap_get(ch, hoid, &bl3, &cur_attrs);
     ASSERT_EQ(r, 0);
     ASSERT_EQ(cur_attrs.size(), size_t(1));
     ASSERT_TRUE(bl_eq(bl1, bl3));
  
     set<string> keys;
-    r = store->omap_get_keys(cid, hoid, &keys);
+    r = store->omap_get_keys(ch, hoid, &keys);
     ASSERT_EQ(r, 0);
     ASSERT_EQ(keys.size(), size_t(1));
   }
@@ -4918,7 +4910,7 @@ TEST_P(StoreTest, OMapTest) {
     {
       bufferlist hdr;
       map<string,bufferlist> m;
-      store->omap_get(cid, hoid, &hdr, &m);
+      store->omap_get(ch, hoid, &hdr, &m);
       ASSERT_EQ(6u, hdr.length());
       ASSERT_TRUE(m.count("2"));
       ASSERT_TRUE(!m.count("3"));
@@ -4937,7 +4929,7 @@ TEST_P(StoreTest, OMapTest) {
     {
       bufferlist hdr;
       map<string,bufferlist> m;
-      store->omap_get(cid, hoid, &hdr, &m);
+      store->omap_get(ch, hoid, &hdr, &m);
       ASSERT_EQ(0u, hdr.length());
       ASSERT_EQ(0u, m.size());
     }
@@ -4985,7 +4977,7 @@ TEST_P(StoreTest, OMapIterator) {
     // FileStore may deadlock two active iterators over the same data
     iter = ObjectMap::ObjectMapIterator();
 
-    iter = store->get_omap_iterator(cid, hoid);
+    iter = store->get_omap_iterator(ch, hoid);
     for (iter->seek_to_first(), count=0; iter->valid(); iter->next(), count++) {
       string key = iter->key();
       bufferlist value = iter->value();
@@ -5018,7 +5010,7 @@ TEST_P(StoreTest, OMapIterator) {
     ASSERT_EQ(r, 0);
   }
 
-  iter = store->get_omap_iterator(cid, hoid);
+  iter = store->get_omap_iterator(ch, hoid);
   //lower bound
   string bound_key = "key-5";
   iter->lower_bound(bound_key);
@@ -5087,7 +5079,7 @@ TEST_P(StoreTest, XattrTest) {
   }
 
   map<string, bufferptr> aset;
-  store->getattrs(cid, hoid, aset);
+  store->getattrs(ch, hoid, aset);
   ASSERT_EQ(aset.size(), attrs.size());
   for (map<string, bufferptr>::iterator i = aset.begin();
        i != aset.end();
@@ -5106,7 +5098,7 @@ TEST_P(StoreTest, XattrTest) {
   }
 
   aset.clear();
-  store->getattrs(cid, hoid, aset);
+  store->getattrs(ch, hoid, aset);
   ASSERT_EQ(aset.size(), attrs.size());
   for (map<string, bufferptr>::iterator i = aset.begin();
        i != aset.end();
@@ -5117,10 +5109,10 @@ TEST_P(StoreTest, XattrTest) {
   }
 
   bufferptr bp;
-  r = store->getattr(cid, hoid, "attr2", bp);
+  r = store->getattr(ch, hoid, "attr2", bp);
   ASSERT_EQ(r, -ENODATA);
 
-  r = store->getattr(cid, hoid, "attr3", bp);
+  r = store->getattr(ch, hoid, "attr3", bp);
   ASSERT_EQ(r, 0);
   bufferlist bl2;
   bl2.push_back(bp);
@@ -5195,7 +5187,7 @@ void colsplittest(
   ch->flush();
   ObjectStore::Transaction t;
   vector<ghobject_t> objects;
-  r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(),
+  r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
                             INT_MAX, &objects, 0);
   ASSERT_EQ(r, 0);
   ASSERT_EQ(objects.size(), num_objects);
@@ -5215,7 +5207,7 @@ void colsplittest(
 
   ch->flush();
   objects.clear();
-  r = store->collection_list(tid, ghobject_t(), ghobject_t::get_max(),
+  r = store->collection_list(tch, ghobject_t(), ghobject_t::get_max(),
                             INT_MAX, &objects, 0);
   ASSERT_EQ(r, 0);
   ASSERT_EQ(objects.size(), num_objects);
@@ -5304,14 +5296,14 @@ TEST_P(StoreTest, TwoHash) {
     ghobject_t o;
     o.hobj.set_hash((i << 16) | 0xA1);
     o.hobj.pool = -1;
-    bool exists = store->exists(cid, o);
+    bool exists = store->exists(ch, o);
     ASSERT_EQ(exists, false);
   }
   {
     ghobject_t o;
     o.hobj.set_hash(0xA1);
     o.hobj.pool = -1;
-    bool exists = store->exists(cid, o);
+    bool exists = store->exists(ch, o);
     ASSERT_EQ(exists, true);
   }
   std::cout << "Cleanup" << std::endl;
@@ -5348,7 +5340,7 @@ TEST_P(StoreTest, Rename) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
   }
-  ASSERT_TRUE(store->exists(cid, srcoid));
+  ASSERT_TRUE(store->exists(ch, srcoid));
   {
     ObjectStore::Transaction t;
     t.collection_move_rename(cid, srcoid, cid, dstoid);
@@ -5357,13 +5349,13 @@ TEST_P(StoreTest, Rename) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
   }
-  ASSERT_TRUE(store->exists(cid, srcoid));
-  ASSERT_TRUE(store->exists(cid, dstoid));
+  ASSERT_TRUE(store->exists(ch, srcoid));
+  ASSERT_TRUE(store->exists(ch, dstoid));
   {
     bufferlist bl;
-    store->read(cid, srcoid, 0, 3, bl);
+    store->read(ch, srcoid, 0, 3, bl);
     ASSERT_TRUE(bl_eq(b, bl));
-    store->read(cid, dstoid, 0, 3, bl);
+    store->read(ch, dstoid, 0, 3, bl);
     ASSERT_TRUE(bl_eq(a, bl));
   }
   {
@@ -5373,11 +5365,11 @@ TEST_P(StoreTest, Rename) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
   }
-  ASSERT_TRUE(store->exists(cid, dstoid));
-  ASSERT_FALSE(store->exists(cid, srcoid));
+  ASSERT_TRUE(store->exists(ch, dstoid));
+  ASSERT_FALSE(store->exists(ch, srcoid));
   {
     bufferlist bl;
-    store->read(cid, dstoid, 0, 3, bl);
+    store->read(ch, dstoid, 0, 3, bl);
     ASSERT_TRUE(bl_eq(b, bl));
   }
   {
@@ -5402,7 +5394,7 @@ TEST_P(StoreTest, MoveRename) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
   }
-  ASSERT_TRUE(store->exists(cid, oid));
+  ASSERT_TRUE(store->exists(ch, oid));
   bufferlist data, attr;
   map<string, bufferlist> omap;
   data.append("data payload");
@@ -5417,7 +5409,7 @@ TEST_P(StoreTest, MoveRename) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
   }
-  ASSERT_TRUE(store->exists(cid, temp_oid));
+  ASSERT_TRUE(store->exists(ch, temp_oid));
   {
     ObjectStore::Transaction t;
     t.remove(cid, oid);
@@ -5425,21 +5417,21 @@ TEST_P(StoreTest, MoveRename) {
     r = apply_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
   }
-  ASSERT_TRUE(store->exists(cid, oid));
-  ASSERT_FALSE(store->exists(cid, temp_oid));
+  ASSERT_TRUE(store->exists(ch, oid));
+  ASSERT_FALSE(store->exists(ch, temp_oid));
   {
     bufferlist newdata;
-    r = store->read(cid, oid, 0, 1000, newdata);
+    r = store->read(ch, oid, 0, 1000, newdata);
     ASSERT_GE(r, 0);
     ASSERT_TRUE(bl_eq(data, newdata));
     bufferlist newattr;
-    r = store->getattr(cid, oid, "attr", newattr);
+    r = store->getattr(ch, oid, "attr", newattr);
     ASSERT_EQ(r, 0);
     ASSERT_TRUE(bl_eq(attr, newattr));
     set<string> keys;
     keys.insert("omap_key");
     map<string, bufferlist> newomap;
-    r = store->omap_get_values(cid, oid, keys, &newomap);
+    r = store->omap_get_values(ch, oid, keys, &newomap);
     ASSERT_GE(r, 0);
     ASSERT_EQ(1u, newomap.size());
     ASSERT_TRUE(newomap.count("omap_key"));
@@ -5496,14 +5488,14 @@ TEST_P(StoreTest, BigRGWObjectName) {
 
   {
     vector<ghobject_t> objects;
-    r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(),
+    r = store->collection_list(ch, ghobject_t(), ghobject_t::get_max(),
                               INT_MAX, &objects, 0);
     ASSERT_EQ(r, 0);
     ASSERT_EQ(objects.size(), 1u);
     ASSERT_EQ(objects[0], oid2);
   }
 
-  ASSERT_FALSE(store->exists(cid, oid));
+  ASSERT_FALSE(store->exists(ch, oid));
 
   {
     ObjectStore::Transaction t;
@@ -5584,8 +5576,8 @@ TEST_P(StoreTest, TryMoveRename) {
     ASSERT_EQ(r, 0);
   }
   struct stat st;
-  ASSERT_EQ(store->stat(cid, hoid, &st), -ENOENT);
-  ASSERT_EQ(store->stat(cid, hoid2, &st), 0);
+  ASSERT_EQ(store->stat(ch, hoid, &st), -ENOENT);
+  ASSERT_EQ(store->stat(ch, hoid2, &st), 0);
 }
 
 #if defined(WITH_BLUESTORE)
@@ -5599,9 +5591,8 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) {
   coll_t cid;
   ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
   {
-    bufferlist in;
-    r = store->read(cid, hoid, 0, 5, in);
-    ASSERT_EQ(-ENOENT, r);
+    auto ch = store->open_collection(cid);
+    ASSERT_FALSE(ch);
   }
   auto ch = store->create_new_collection(cid);
   {
@@ -5629,7 +5620,7 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) {
     g_conf->apply_changes(NULL);
 
     bufferlist in;
-    r = store->read(cid, hoid, 0, block_size, in);
+    r = store->read(ch, hoid, 0, block_size, in);
     ASSERT_EQ((int)block_size, r);
     ASSERT_TRUE(bl_eq(orig, in));
 
@@ -5653,7 +5644,7 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) {
     g_conf->apply_changes(NULL);
 
     bufferlist in;
-    r = store->read(cid, hoid, 0, block_size, in);
+    r = store->read(ch, hoid, 0, block_size, in);
     ASSERT_EQ((int)block_size, r);
     ASSERT_TRUE(bl_eq(orig, in));
   }
@@ -5681,22 +5672,22 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) {
     ASSERT_EQ(r, 0);
 
     bufferlist in;
-    r = store->read(cid, hoid, 0, block_size, in);
+    r = store->read(ch, hoid, 0, block_size, in);
     ASSERT_EQ((int)block_size, r);
     ASSERT_TRUE(bl_eq(orig, in));
     in.clear();
-    r = store->read(cid, hoid, block_size*2, block_size, in);
+    r = store->read(ch, hoid, block_size*2, block_size, in);
     ASSERT_EQ((int)block_size, r);
     ASSERT_TRUE(bl_eq(orig, in));
 
     g_conf->set_val("bluestore_csum_type", "crc32c");
     g_conf->apply_changes(NULL);
     in.clear();
-    r = store->read(cid, hoid, 0, block_size, in);
+    r = store->read(ch, hoid, 0, block_size, in);
     ASSERT_EQ((int)block_size, r);
     ASSERT_TRUE(bl_eq(orig, in));
     in.clear();
-    r = store->read(cid, hoid, block_size*2, block_size, in);
+    r = store->read(ch, hoid, block_size*2, block_size, in);
     ASSERT_EQ((int)block_size, r);
     ASSERT_TRUE(bl_eq(orig, in));
   }
@@ -5733,11 +5724,11 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) {
     orig.append( std::string(block_size0 - block_size, 'a'));
 
     bufferlist in;
-    r = store->read(cid, hoid, 0, block_size0, in);
+    r = store->read(ch, hoid, 0, block_size0, in);
     ASSERT_EQ((int)block_size0, r);
     ASSERT_TRUE(bl_eq(orig, in));
 
-    r = store->read(cid, hoid, block_size0, block_size, in);
+    r = store->read(ch, hoid, block_size0, block_size, in);
     ASSERT_EQ((int)block_size, r);
     ASSERT_TRUE(bl_eq(orig2, in));
 
@@ -5755,7 +5746,7 @@ TEST_P(StoreTest, BluestoreOnOffCSumTest) {
     in.clear();
     orig = bl;
     orig.append( std::string(block_size - block_size2, 'b'));
-    r = store->read(cid, hoid, block_size0, block_size, in);
+    r = store->read(ch, hoid, block_size0, block_size, in);
     ASSERT_EQ((int)block_size, r);
     ASSERT_TRUE(bl_eq(orig, in));
   }
@@ -5975,7 +5966,7 @@ TEST_P(StoreTestSpecificAUSize, OnodeSizeTracking) {
   {
     bufferlist bl;
     for (size_t i = 0; i < obj_size; i += 0x1000) {
-      store->read(cid, hoid, i, 0x1000, bl);
+      store->read(ch, hoid, i, 0x1000, bl);
     }
   }
   get_mempool_stats(&total_bytes, &total_onodes);
@@ -6074,7 +6065,7 @@ TEST_P(StoreTestSpecificAUSize, BlobReuseOnOverwrite) {
     // thread to update stats.
     sleep(1);
     bufferlist bl, expected;
-    r = store->read(cid, hoid, 0, block_size, bl);
+    r = store->read(ch, hoid, 0, block_size, bl);
     ASSERT_EQ(r, (int)block_size);
     expected.append(string(block_size, 'b'));
     ASSERT_TRUE(bl_eq(expected, bl));
@@ -6099,7 +6090,7 @@ TEST_P(StoreTestSpecificAUSize, BlobReuseOnOverwrite) {
     // thread to update stats.
     sleep(1);
     bufferlist bl, expected;
-    r = store->read(cid, hoid, 0, block_size, bl);
+    r = store->read(ch, hoid, 0, block_size, bl);
     ASSERT_EQ(r, (int)block_size);
     expected.append(string(block_size, 'b'));
     ASSERT_TRUE(bl_eq(expected, bl));
@@ -6124,42 +6115,42 @@ TEST_P(StoreTestSpecificAUSize, BlobReuseOnOverwrite) {
     sleep(1);
 
     bufferlist bl, expected;
-    r = store->read(cid, hoid, 0, block_size, bl);
+    r = store->read(ch, hoid, 0, block_size, bl);
     ASSERT_EQ(r, (int)block_size);
     expected.append(string(block_size, 'b'));
     ASSERT_TRUE(bl_eq(expected, bl));
 
     bl.clear();
     expected.clear();
-    r = store->read(cid, hoid, block_size, block_size, bl);
+    r = store->read(ch, hoid, block_size, block_size, bl);
     ASSERT_EQ(r, (int)block_size);
     expected.append(string(block_size, 'a'));
     ASSERT_TRUE(bl_eq(expected, bl));
 
     bl.clear();
     expected.clear();
-    r = store->read(cid, hoid, block_size * 2, block_size * 2, bl);
+    r = store->read(ch, hoid, block_size * 2, block_size * 2, bl);
     ASSERT_EQ(r, (int)block_size * 2);
     expected.append(string(block_size * 2, 'c'));
     ASSERT_TRUE(bl_eq(expected, bl));
 
     bl.clear();
     expected.clear();
-    r = store->read(cid, hoid, block_size * 4, block_size, bl);
+    r = store->read(ch, hoid, block_size * 4, block_size, bl);
     ASSERT_EQ(r, (int)block_size);
     expected.append(string(block_size, 'f'));
     ASSERT_TRUE(bl_eq(expected, bl));
 
     bl.clear();
     expected.clear();
-    r = store->read(cid, hoid, block_size * 5, block_size, bl);
+    r = store->read(ch, hoid, block_size * 5, block_size, bl);
     ASSERT_EQ(r, (int)block_size);
     expected.append(string(block_size, 'd'));
     ASSERT_TRUE(bl_eq(expected, bl));
 
     bl.clear();
     expected.clear();
-    r = store->read(cid, hoid, block_size * 5, block_size * 3, bl);
+    r = store->read(ch, hoid, block_size * 5, block_size * 3, bl);
     ASSERT_EQ(r, (int)block_size * 3);
     expected.append(string(block_size, 'd'));
     expected.append(string(block_size * 2, 'e'));
@@ -6232,7 +6223,7 @@ TEST_P(StoreTestSpecificAUSize, BlobReuseOnOverwriteReverse) {
     // thread to update stats.
     sleep(1);
     bufferlist bl, expected;
-    r = store->read(cid, hoid, block_size * 9, block_size * 2, bl);
+    r = store->read(ch, hoid, block_size * 9, block_size * 2, bl);
     ASSERT_EQ(r, (int)block_size * 2);
     expected.append(string(block_size, 'b'));
     expected.append(string(block_size, 'a'));
@@ -6259,7 +6250,7 @@ TEST_P(StoreTestSpecificAUSize, BlobReuseOnOverwriteReverse) {
     // thread to update stats.
     sleep(1);
     bufferlist bl, expected;
-    r = store->read(cid, hoid, block_size * 7, block_size * 3, bl);
+    r = store->read(ch, hoid, block_size * 7, block_size * 3, bl);
     ASSERT_EQ(r, (int)block_size * 3);
     expected.append(string(block_size, 'c'));
     expected.append(string(block_size, 0));
@@ -6286,7 +6277,7 @@ TEST_P(StoreTestSpecificAUSize, BlobReuseOnOverwriteReverse) {
     // thread to update stats.
     sleep(1);
     bufferlist bl, expected;
-    r = store->read(cid, hoid, block_size * 11, block_size * 3, bl);
+    r = store->read(ch, hoid, block_size * 11, block_size * 3, bl);
     ASSERT_EQ(r, (int)block_size * 3);
     expected.append(string(block_size, 'a'));
     expected.append(string(block_size, 0));
@@ -6315,7 +6306,7 @@ TEST_P(StoreTestSpecificAUSize, BlobReuseOnOverwriteReverse) {
     // thread to update stats.
     sleep(1);
     bufferlist bl, expected;
-    r = store->read(cid, hoid, block_size * 17, block_size * 3, bl);
+    r = store->read(ch, hoid, block_size * 17, block_size * 3, bl);
     ASSERT_EQ(r, (int)block_size * 3);
     expected.append(string(block_size, 'e'));
     expected.append(string(block_size, 0));
@@ -6343,7 +6334,7 @@ TEST_P(StoreTestSpecificAUSize, BlobReuseOnOverwriteReverse) {
     // thread to update stats.
     sleep(1);
     bufferlist bl, expected;
-    r = store->read(cid, hoid, block_size * 16, block_size * 4, bl);
+    r = store->read(ch, hoid, block_size * 16, block_size * 4, bl);
     ASSERT_EQ(r, (int)block_size * 4);
     expected.append(string(block_size, 'f'));
     expected.append(string(block_size, 'e'));
@@ -6415,7 +6406,7 @@ TEST_P(StoreTestSpecificAUSize, BlobReuseOnSmallOverwrite) {
     // thread to update stats.
     sleep(1);
     bufferlist bl, expected;
-    r = store->read(cid, hoid, 0, block_size * 3, bl);
+    r = store->read(ch, hoid, 0, block_size * 3, bl);
     ASSERT_EQ(r, (int)block_size * 3);
     expected.append(string(block_size, 'a'));
     expected.append(string(1, 0));
@@ -6506,7 +6497,7 @@ TEST_P(StoreTestSpecificAUSize, SmallWriteOnShardedExtents) {
     ObjectStore::Transaction t;
     bufferlist bl, expected;
 
-    r = store->read(cid, hoid1, 0x70000, 0x9c00, bl);
+    r = store->read(ch, hoid1, 0x70000, 0x9c00, bl);
     ASSERT_EQ(r, (int)0x9c00);
     expected.append(string(0x19e0, 'a'));
     expected.append(string(0x220, 0));
@@ -6651,7 +6642,7 @@ TEST_P(StoreTestSpecificAUSize, garbageCollection) {
   ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
   {
     bufferlist in;
-    r = store->read(cid, hoid, 0, 5, in);
+    r = store->read(ch, hoid, 0, 5, in);
     ASSERT_EQ(-ENOENT, r);
   }
   {
@@ -6667,7 +6658,7 @@ TEST_P(StoreTestSpecificAUSize, garbageCollection) {
 
   {
     { 
-      bool exists = store->exists(cid, hoid);
+      bool exists = store->exists(ch, hoid);
       ASSERT_TRUE(!exists);
 
       ObjectStore::Transaction t;
@@ -6676,7 +6667,7 @@ TEST_P(StoreTestSpecificAUSize, garbageCollection) {
       r = apply_transaction(store, ch, std::move(t));
       ASSERT_EQ(r, 0);
 
-      exists = store->exists(cid, hoid);
+      exists = store->exists(ch, hoid);
       ASSERT_EQ(true, exists);
     } 
     bufferlist bl;
index 9540f230b69159db330f09f1673362f4073cda13..3b24807b831bcd314e869a41d96f0c1b38549e32 100644 (file)
@@ -78,7 +78,7 @@ TEST_F(MemStoreClone, CloneRangeAllocated)
   t.write(cid, dst, 0, 12, dstbl);
   t.clone_range(cid, src, dst, 2, 8, 2);
   ASSERT_EQ(0u, store->apply_transaction(ch, std::move(t)));
-  ASSERT_EQ(12, store->read(cid, dst, 0, 12, result));
+  ASSERT_EQ(12, store->read(ch, dst, 0, 12, result));
   ASSERT_EQ(expected, result);
 }
 
@@ -102,7 +102,7 @@ TEST_F(MemStoreClone, CloneRangeHole)
   t.write(cid, dst, 0, 12, dstbl);
   t.clone_range(cid, src, dst, 2, 8, 2);
   ASSERT_EQ(0u, store->apply_transaction(ch, std::move(t)));
-  ASSERT_EQ(12, store->read(cid, dst, 0, 12, result));
+  ASSERT_EQ(12, store->read(ch, dst, 0, 12, result));
   ASSERT_EQ(expected, result);
 }
 
@@ -126,7 +126,7 @@ TEST_F(MemStoreClone, CloneRangeHoleStart)
   t.write(cid, dst, 0, 12, dstbl);
   t.clone_range(cid, src, dst, 2, 8, 2);
   ASSERT_EQ(0u, store->apply_transaction(ch, std::move(t)));
-  ASSERT_EQ(12, store->read(cid, dst, 0, 12, result));
+  ASSERT_EQ(12, store->read(ch, dst, 0, 12, result));
   ASSERT_EQ(expected, result);
 }
 
@@ -151,7 +151,7 @@ TEST_F(MemStoreClone, CloneRangeHoleMiddle)
   t.write(cid, dst, 0, 12, dstbl);
   t.clone_range(cid, src, dst, 2, 8, 2);
   ASSERT_EQ(0u, store->apply_transaction(ch, std::move(t)));
-  ASSERT_EQ(12, store->read(cid, dst, 0, 12, result));
+  ASSERT_EQ(12, store->read(ch, dst, 0, 12, result));
   ASSERT_EQ(expected, result);
 }
 
@@ -176,7 +176,7 @@ TEST_F(MemStoreClone, CloneRangeHoleEnd)
   t.write(cid, dst, 0, 12, dstbl);
   t.clone_range(cid, src, dst, 2, 8, 2);
   ASSERT_EQ(0u, store->apply_transaction(ch, std::move(t)));
-  ASSERT_EQ(12, store->read(cid, dst, 0, 12, result));
+  ASSERT_EQ(12, store->read(ch, dst, 0, 12, result));
   ASSERT_EQ(expected, result);
 }
 
index 93bd044ca15387ac28b168ca4e503d43cfee5dfc..e66b8f09367d303590704359f45e8bcbe990a053 100644 (file)
@@ -2348,7 +2348,7 @@ public:
   hobject_t existing_oid, nonexistent_oid;
 
   void run_rebuild_missing_test(const map<hobject_t, pg_missing_item> &expected_missing_items) {
-    rebuild_missing_set_with_deletes(store.get(), test_coll, info);
+    rebuild_missing_set_with_deletes(store.get(), ch, info);
     ASSERT_EQ(expected_missing_items, missing.get_items());
   }
 };
@@ -2495,7 +2495,7 @@ public:
     auto orig_dups = log.dups;
     clear();
     ostringstream err;
-    read_log_and_missing(store.get(), test_coll, log_oid,
+    read_log_and_missing(store.get(), ch, log_oid,
                         pg_info_t(), err, false);
     ASSERT_EQ(orig_dups.size(), log.dups.size());
     ASSERT_EQ(orig_dups, log.dups);
index 41408f963a24c265c9887f50aebce6975d9028ff..0518cc97e1ce87b71dabfc86d73965f51ed1d83b 100644 (file)
@@ -81,12 +81,12 @@ struct action_on_object_t {
 
 int _action_on_all_objects_in_pg(ObjectStore *store, coll_t coll, action_on_object_t &action, bool debug)
 {
+  auto ch = store->open_collection(coll);
   unsigned LIST_AT_A_TIME = 100;
   ghobject_t next;
   while (!next.is_max()) {
     vector<ghobject_t> list;
-    int r = store->collection_list(
-                                  coll,
+    int r = store->collection_list(ch,
                                   next,
                                   ghobject_t::get_max(),
                                   LIST_AT_A_TIME,
@@ -105,7 +105,7 @@ int _action_on_all_objects_in_pg(ObjectStore *store, coll_t coll, action_on_obje
       object_info_t oi;
       if (coll != coll_t::meta()) {
         bufferlist attr;
-        r = store->getattr(coll, *obj, OI_ATTR, attr);
+        r = store->getattr(ch, *obj, OI_ATTR, attr);
         if (r < 0) {
          cerr << "Error getting attr on : " << make_pair(coll, *obj) << ", "
               << cpp_strerror(r) << std::endl;
@@ -314,14 +314,18 @@ static int get_fd_data(int fd, bufferlist &bl)
 }
 
 int get_log(ObjectStore *fs, __u8 struct_ver,
-           coll_t coll, spg_t pgid, const pg_info_t &info,
+           spg_t pgid, const pg_info_t &info,
            PGLog::IndexedLog &log, pg_missing_t &missing)
 {
   try {
+    auto ch = fs->open_collection(coll_t(pgid));
+    if (!ch) {
+      return -ENOENT;
+    }
     ostringstream oss;
     assert(struct_ver > 0);
     PGLog::read_log_and_missing(
-      fs, coll,
+      fs, ch,
       pgid.make_pgmeta_oid(),
       info, log, missing,
       oss,
@@ -497,7 +501,8 @@ int ObjectStoreTool::export_file(ObjectStore *store, coll_t cid, ghobject_t &obj
   mysize_t total;
   footer ft;
 
-  int ret = store->stat(cid, obj, &st);
+  auto ch = store->open_collection(cid);
+  int ret = store->stat(ch, obj, &st);
   if (ret < 0)
     return ret;
 
@@ -512,7 +517,7 @@ int ObjectStoreTool::export_file(ObjectStore *store, coll_t cid, ghobject_t &obj
   {
     bufferptr bp;
     bufferlist bl;
-    ret = store->getattr(cid, obj, OI_ATTR, bp);
+    ret = store->getattr(ch, obj, OI_ATTR, bp);
     if (ret < 0) {
       cerr << "getattr failure object_info " << ret << std::endl;
       return ret;
@@ -537,7 +542,7 @@ int ObjectStoreTool::export_file(ObjectStore *store, coll_t cid, ghobject_t &obj
     if (len > total)
       len = total;
 
-    ret = store->read(cid, obj, offset, len, rawdatabl);
+    ret = store->read(ch, obj, offset, len, rawdatabl);
     if (ret < 0)
       return ret;
     if (ret == 0)
@@ -556,7 +561,7 @@ int ObjectStoreTool::export_file(ObjectStore *store, coll_t cid, ghobject_t &obj
 
   //Handle attrs for this object
   map<string,bufferptr> aset;
-  ret = store->getattrs(cid, obj, aset);
+  ret = store->getattrs(ch, obj, aset);
   if (ret) return ret;
   attr_section as(aset);
   ret = write_section(TYPE_ATTRS, as, file_fd);
@@ -569,7 +574,7 @@ int ObjectStoreTool::export_file(ObjectStore *store, coll_t cid, ghobject_t &obj
 
   //Handle omap information
   bufferlist hdrbuf;
-  ret = store->omap_get_header(cid, obj, &hdrbuf, true);
+  ret = store->omap_get_header(ch, obj, &hdrbuf, true);
   if (ret < 0) {
     cerr << "omap_get_header: " << cpp_strerror(ret) << std::endl;
     return ret;
@@ -580,7 +585,7 @@ int ObjectStoreTool::export_file(ObjectStore *store, coll_t cid, ghobject_t &obj
   if (ret)
     return ret;
 
-  ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(cid, obj);
+  ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(ch, obj);
   if (!iter) {
     ret = -ENOENT;
     cerr << "omap_get_iterator: " << cpp_strerror(ret) << std::endl;
@@ -613,10 +618,10 @@ int ObjectStoreTool::export_file(ObjectStore *store, coll_t cid, ghobject_t &obj
 int ObjectStoreTool::export_files(ObjectStore *store, coll_t coll)
 {
   ghobject_t next;
-
+  auto ch = store->open_collection(coll);
   while (!next.is_max()) {
     vector<ghobject_t> objects;
-    int r = store->collection_list(coll, next, ghobject_t::get_max(), 300,
+    int r = store->collection_list(ch, next, ghobject_t::get_max(), 300,
       &objects, &next);
     if (r < 0)
       return r;
@@ -650,8 +655,9 @@ int set_inc_osdmap(ObjectStore *store, epoch_t e, bufferlist& bl, bool force) {
       return -EINVAL;
     }
   }
+  auto ch = store->open_collection(coll_t::meta());
   const ghobject_t inc_oid = OSD::get_inc_osdmap_pobject_name(e);
-  if (!store->exists(coll_t::meta(), inc_oid)) {
+  if (!store->exists(ch, inc_oid)) {
     cerr << "inc-osdmap (" << inc_oid << ") does not exist." << std::endl;
     if (!force) {
       return -ENOENT;
@@ -660,7 +666,6 @@ int set_inc_osdmap(ObjectStore *store, epoch_t e, bufferlist& bl, bool force) {
   }
   if (dry_run)
     return 0;
-  ObjectStore::CollectionHandle ch = store->open_collection(coll_t::meta());
   ObjectStore::Transaction t;
   t.write(coll_t::meta(), inc_oid, 0, bl.length(), bl);
   t.truncate(coll_t::meta(), inc_oid, bl.length());
@@ -675,7 +680,8 @@ int set_inc_osdmap(ObjectStore *store, epoch_t e, bufferlist& bl, bool force) {
 
 int get_inc_osdmap(ObjectStore *store, epoch_t e, bufferlist& bl)
 {
-  if (store->read(coll_t::meta(),
+  auto ch = store->open_collection(coll_t::meta());
+  if (store->read(ch,
                  OSD::get_inc_osdmap_pobject_name(e),
                  0, 0, bl) < 0) {
     return -ENOENT;
@@ -697,8 +703,9 @@ int set_osdmap(ObjectStore *store, epoch_t e, bufferlist& bl, bool force) {
       return -EINVAL;
     }
   }
+  auto ch = store->open_collection(coll_t::meta());
   const ghobject_t full_oid = OSD::get_osdmap_pobject_name(e);
-  if (!store->exists(coll_t::meta(), full_oid)) {
+  if (!store->exists(ch, full_oid)) {
     cerr << "osdmap (" << full_oid << ") does not exist." << std::endl;
     if (!force) {
       return -ENOENT;
@@ -708,7 +715,6 @@ int set_osdmap(ObjectStore *store, epoch_t e, bufferlist& bl, bool force) {
   if (dry_run)
     return 0;
   ObjectStore::Transaction t;
-  ObjectStore::CollectionHandle ch = store->open_collection(coll_t::meta());
   t.write(coll_t::meta(), full_oid, 0, bl.length(), bl);
   t.truncate(coll_t::meta(), full_oid, bl.length());
   int ret = store->apply_transaction(ch, std::move(t));
@@ -722,8 +728,9 @@ int set_osdmap(ObjectStore *store, epoch_t e, bufferlist& bl, bool force) {
 
 int get_osdmap(ObjectStore *store, epoch_t e, OSDMap &osdmap, bufferlist& bl)
 {
+  ObjectStore::CollectionHandle ch = store->open_collection(coll_t::meta());
   bool found = store->read(
-      coll_t::meta(), OSD::get_osdmap_pobject_name(e), 0, 0, bl) >= 0;
+    ch, OSD::get_osdmap_pobject_name(e), 0, 0, bl) >= 0;
   if (!found) {
     cerr << "Can't find OSDMap for pg epoch " << e << std::endl;
     return -ENOENT;
@@ -749,7 +756,7 @@ int ObjectStoreTool::do_export(ObjectStore *fs, coll_t coll, spg_t pgid,
 
   cerr << "Exporting " << pgid << " info " << info << std::endl;
 
-  int ret = get_log(fs, struct_ver, coll, pgid, info, log, missing);
+  int ret = get_log(fs, struct_ver, pgid, info, log, missing);
   if (ret > 0)
       return ret;
 
@@ -893,6 +900,7 @@ int get_attrs(
   attr_section as;
   as.decode(ebliter);
 
+  auto ch = store->open_collection(coll);
   if (debug)
     cerr << "\tattrs: len " << as.data.size() << std::endl;
   t->setattrs(coll, hoid, as.data);
@@ -911,7 +919,7 @@ int get_attrs(
        ghobject_t clone = hoid;
        clone.hobj.snap = p.first;
        set<snapid_t> snaps(p.second.begin(), p.second.end());
-       if (!store->exists(coll, clone)) {
+       if (!store->exists(ch, clone)) {
          // no clone, skip.  this is probably a cache pool.  this works
          // because we use a separate transaction per object and clones
          // come before head in the archive.
@@ -1878,6 +1886,7 @@ int get_snapset(ObjectStore *store, coll_t coll, ghobject_t &ghobj, SnapSet &ss,
 int do_remove_object(ObjectStore *store, coll_t coll,
                     ghobject_t &ghobj, bool all, bool force)
 {
+  auto ch = store->open_collection(coll);
   spg_t pg;
   coll.is_pg_prefix(&pg);
   OSDriver driver(
@@ -1887,7 +1896,7 @@ int do_remove_object(ObjectStore *store, coll_t coll,
   SnapMapper mapper(g_ceph_context, &driver, 0, 0, 0, pg.shard);
   struct stat st;
 
-  int r = store->stat(coll, ghobj, &st);
+  int r = store->stat(ch, ghobj, &st);
   if (r < 0) {
     cerr << "remove: " << cpp_strerror(r) << std::endl;
     return r;
@@ -1918,7 +1927,6 @@ int do_remove_object(ObjectStore *store, coll_t coll,
 
   cout << "remove " << ghobj << std::endl;
 
-  auto ch = store->open_collection(coll);
   if (!dry_run) {
     r = remove_object(coll, ghobj, mapper, &_t, &t);
     if (r < 0)
@@ -1945,8 +1953,9 @@ int do_remove_object(ObjectStore *store, coll_t coll,
 
 int do_list_attrs(ObjectStore *store, coll_t coll, ghobject_t &ghobj)
 {
+  auto ch = store->open_collection(coll);
   map<string,bufferptr> aset;
-  int r = store->getattrs(coll, ghobj, aset);
+  int r = store->getattrs(ch, ghobj, aset);
   if (r < 0) {
     cerr << "getattrs: " << cpp_strerror(r) << std::endl;
     return r;
@@ -1963,7 +1972,8 @@ int do_list_attrs(ObjectStore *store, coll_t coll, ghobject_t &ghobj)
 
 int do_list_omap(ObjectStore *store, coll_t coll, ghobject_t &ghobj)
 {
-  ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(coll, ghobj);
+  auto ch = store->open_collection(coll);
+  ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(ch, ghobj);
   if (!iter) {
     cerr << "omap_get_iterator: " << cpp_strerror(ENOENT) << std::endl;
     return -ENOENT;
@@ -1985,10 +1995,11 @@ int do_list_omap(ObjectStore *store, coll_t coll, ghobject_t &ghobj)
 
 int do_get_bytes(ObjectStore *store, coll_t coll, ghobject_t &ghobj, int fd)
 {
+  auto ch = store->open_collection(coll);
   struct stat st;
   mysize_t total;
 
-  int ret = store->stat(coll, ghobj, &st);
+  int ret = store->stat(ch, ghobj, &st);
   if (ret < 0) {
     cerr << "get-bytes: " << cpp_strerror(ret) << std::endl;
     return ret;
@@ -2006,7 +2017,7 @@ int do_get_bytes(ObjectStore *store, coll_t coll, ghobject_t &ghobj, int fd)
     if (len > total)
       len = total;
 
-    ret = store->read(coll, ghobj, offset, len, rawdatabl);
+    ret = store->read(ch, ghobj, offset, len, rawdatabl);
     if (ret < 0)
       return ret;
     if (ret == 0)
@@ -2072,9 +2083,10 @@ int do_set_bytes(ObjectStore *store, coll_t coll,
 
 int do_get_attr(ObjectStore *store, coll_t coll, ghobject_t &ghobj, string key)
 {
+  auto ch = store->open_collection(coll);
   bufferptr bp;
 
-  int r = store->getattr(coll, ghobj, key.c_str(), bp);
+  int r = store->getattr(ch, ghobj, key.c_str(), bp);
   if (r < 0) {
     cerr << "getattr: " << cpp_strerror(r) << std::endl;
     return r;
@@ -2137,12 +2149,13 @@ int do_rm_attr(ObjectStore *store, coll_t coll,
 
 int do_get_omap(ObjectStore *store, coll_t coll, ghobject_t &ghobj, string key)
 {
+  auto ch = store->open_collection(coll);
   set<string> keys;
   map<string, bufferlist> out;
 
   keys.insert(key);
 
-  int r = store->omap_get_values(coll, ghobj, keys, &out);
+  int r = store->omap_get_values(ch, ghobj, keys, &out);
   if (r < 0) {
     cerr << "omap_get_values: " << cpp_strerror(r) << std::endl;
     return r;
@@ -2219,9 +2232,10 @@ int do_rm_omap(ObjectStore *store, coll_t coll,
 
 int do_get_omaphdr(ObjectStore *store, coll_t coll, ghobject_t &ghobj)
 {
+  auto ch = store->open_collection(coll);
   bufferlist hdrbl;
 
-  int r = store->omap_get_header(coll, ghobj, &hdrbl, true);
+  int r = store->omap_get_header(ch, ghobj, &hdrbl, true);
   if (r < 0) {
     cerr << "omap_get_header: " << cpp_strerror(r) << std::endl;
     return r;
@@ -2293,8 +2307,9 @@ struct do_fix_lost : public action_on_object_t {
 
 int get_snapset(ObjectStore *store, coll_t coll, ghobject_t &ghobj, SnapSet &ss, bool silent = false)
 {
+  auto ch = store->open_collection(coll);
   bufferlist attr;
-  int r = store->getattr(coll, ghobj, SS_ATTR, attr);
+  int r = store->getattr(ch, ghobj, SS_ATTR, attr);
   if (r < 0) {
     if (!silent)
       cerr << "Error getting snapset on : " << make_pair(coll, ghobj) << ", "
@@ -2315,6 +2330,7 @@ int get_snapset(ObjectStore *store, coll_t coll, ghobject_t &ghobj, SnapSet &ss,
 
 int print_obj_info(ObjectStore *store, coll_t coll, ghobject_t &ghobj, Formatter* formatter)
 {
+  auto ch = store->open_collection(coll);
   int r = 0;
   formatter->open_object_section("obj");
   formatter->open_object_section("id");
@@ -2322,7 +2338,7 @@ int print_obj_info(ObjectStore *store, coll_t coll, ghobject_t &ghobj, Formatter
   formatter->close_section();
 
   bufferlist attr;
-  int gr = store->getattr(coll, ghobj, OI_ATTR, attr);
+  int gr = store->getattr(ch, ghobj, OI_ATTR, attr);
   if (gr < 0) {
     r = gr;
     cerr << "Error getting attr on : " << make_pair(coll, ghobj) << ", "
@@ -2342,7 +2358,7 @@ int print_obj_info(ObjectStore *store, coll_t coll, ghobject_t &ghobj, Formatter
     }
   }
   struct stat st;
-  int sr =  store->stat(coll, ghobj, &st, true);
+  int sr =  store->stat(ch, ghobj, &st, true);
   if (sr < 0) {
     r = sr;
     cerr << "Error stat on : " << make_pair(coll, ghobj) << ", "
@@ -2377,12 +2393,13 @@ int set_size(
   ObjectStore *store, coll_t coll, ghobject_t &ghobj, uint64_t setsize, Formatter* formatter,
   bool corrupt)
 {
+  auto ch = store->open_collection(coll);
   if (ghobj.hobj.is_snapdir()) {
     cerr << "Can't set the size of a snapdir" << std::endl;
     return -EINVAL;
   }
   bufferlist attr;
-  int r = store->getattr(coll, ghobj, OI_ATTR, attr);
+  int r = store->getattr(ch, ghobj, OI_ATTR, attr);
   if (r < 0) {
     cerr << "Error getting attr on : " << make_pair(coll, ghobj) << ", "
        << cpp_strerror(r) << std::endl;
@@ -2399,7 +2416,7 @@ int set_size(
     return r;
   }
   struct stat st;
-  r =  store->stat(coll, ghobj, &st, true);
+  r =  store->stat(ch, ghobj, &st, true);
   if (r < 0) {
     cerr << "Error stat on : " << make_pair(coll, ghobj) << ", "
          << cpp_strerror(r) << std::endl;
@@ -2671,10 +2688,11 @@ int dup(string srcpath, ObjectStore *src, string dstpath, ObjectStore *dst)
   i = 1;
   for (auto cid : collections) {
     cout << i++ << "/" << num << " " << cid << std::endl;
-    auto ch = dst->create_new_collection(cid);
+    auto ch = src->open_collection(cid);
+    auto dch = dst->create_new_collection(cid);
     {
       ObjectStore::Transaction t;
-      int bits = src->collection_bits(cid);
+      int bits = src->collection_bits(ch);
       if (bits < 0) {
         if (src->get_type() == "filestore" && cid.is_meta()) {
           bits = 0;
@@ -2685,7 +2703,7 @@ int dup(string srcpath, ObjectStore *src, string dstpath, ObjectStore *dst)
         }
       }
       t.create_collection(cid, bits);
-      dst->apply_transaction(ch, std::move(t));
+      dst->apply_transaction(dch, std::move(t));
     }
 
     ghobject_t pos;
@@ -2693,7 +2711,7 @@ int dup(string srcpath, ObjectStore *src, string dstpath, ObjectStore *dst)
     uint64_t bytes = 0, keys = 0;
     while (true) {
       vector<ghobject_t> ls;
-      r = src->collection_list(cid, pos, ghobject_t::get_max(), 1000, &ls, &pos);
+      r = src->collection_list(ch, pos, ghobject_t::get_max(), 1000, &ls, &pos);
       if (r < 0) {
        cerr << "collection_list on " << cid << " from " << pos << " got: "
             << cpp_strerror(r) << std::endl;
@@ -2717,13 +2735,13 @@ int dup(string srcpath, ObjectStore *src, string dstpath, ObjectStore *dst)
        t.touch(cid, oid);
 
        map<string,bufferptr> attrs;
-       src->getattrs(cid, oid, attrs);
+       src->getattrs(ch, oid, attrs);
        if (!attrs.empty()) {
          t.setattrs(cid, oid, attrs);
        }
 
        bufferlist bl;
-       src->read(cid, oid, 0, 0, bl);
+       src->read(ch, oid, 0, 0, bl);
        if (bl.length()) {
          t.write(cid, oid, 0, bl.length(), bl);
          bytes += bl.length();
@@ -2731,7 +2749,7 @@ int dup(string srcpath, ObjectStore *src, string dstpath, ObjectStore *dst)
 
        bufferlist header;
        map<string,bufferlist> omap;
-       src->omap_get(cid, oid, &header, &omap);
+       src->omap_get(ch, oid, &header, &omap);
        if (header.length()) {
          t.omap_setheader(cid, oid, header);
          ++keys;
@@ -2741,7 +2759,7 @@ int dup(string srcpath, ObjectStore *src, string dstpath, ObjectStore *dst)
          t.omap_setkeys(cid, oid, omap);
        }
 
-       dst->apply_transaction(ch, std::move(t));
+       dst->apply_transaction(dch, std::move(t));
       }
     }
     cout << "  " << std::setw(16) << n << " objects, "
@@ -3301,8 +3319,9 @@ int main(int argc, char **argv)
 
   bufferlist bl;
   OSDSuperblock superblock;
+  auto ch = fs->open_collection(coll_t::meta());
   bufferlist::iterator p;
-  ret = fs->read(coll_t::meta(), OSD_SUPERBLOCK_GOBJECT, 0, 0, bl);
+  ret = fs->read(ch, OSD_SUPERBLOCK_GOBJECT, 0, 0, bl);
   if (ret < 0) {
     cerr << "Failure to read OSD superblock: " << cpp_strerror(ret) << std::endl;
     goto out;
@@ -3929,7 +3948,7 @@ int main(int argc, char **argv)
     } else if (op == "log") {
       PGLog::IndexedLog log;
       pg_missing_t missing;
-      ret = get_log(fs, struct_ver, coll, pgid, info, log, missing);
+      ret = get_log(fs, struct_ver, pgid, info, log, missing);
       if (ret < 0)
           goto out;
 
index d3c48a072b894840593683b8edda84e9b49e01dd..09986593fa3ac34de9a656974ac947ccd8b97954 100644 (file)
@@ -240,6 +240,7 @@ int update_osdmap(ObjectStore& fs, OSDSuperblock& sb, MonitorDBStore& ms)
 
   unsigned nadded = 0;
 
+  auto ch = fs.open_collection(coll_t::meta());
   OSDMap osdmap;
   for (auto e = std::max(last_committed+1, sb.oldest_map);
        e <= sb.newest_map; e++) {
@@ -250,7 +251,7 @@ int update_osdmap(ObjectStore& fs, OSDSuperblock& sb, MonitorDBStore& ms)
     {
       const auto oid = OSD::get_inc_osdmap_pobject_name(e);
       bufferlist bl;
-      int nread = fs.read(coll_t::meta(), oid, 0, 0, bl);
+      int nread = fs.read(ch, oid, 0, 0, bl);
       if (nread <= 0) {
         cerr << "missing " << oid << std::endl;
         return -EINVAL;
@@ -285,7 +286,7 @@ int update_osdmap(ObjectStore& fs, OSDSuperblock& sb, MonitorDBStore& ms)
     {
       const auto oid = OSD::get_osdmap_pobject_name(e);
       bufferlist bl;
-      int nread = fs.read(coll_t::meta(), oid, 0, 0, bl);
+      int nread = fs.read(ch, oid, 0, 0, bl);
       if (nread <= 0) {
         cerr << "missing " << oid << std::endl;
         return -EINVAL;