]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: use explicit coll_t::make_string_coll() ctor
authorSage Weil <sage@redhat.com>
Mon, 22 Dec 2014 21:39:19 +0000 (13:39 -0800)
committerSage Weil <sage@redhat.com>
Fri, 19 Jun 2015 00:02:46 +0000 (17:02 -0700)
Call out those creating collections with strings.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/FileStore.cc
src/os/GenericObjectMap.cc
src/os/KeyValueStore.cc
src/os/KeyValueStore.h
src/osd/osd_types.h
src/test/bench/small_io_bench_fs.cc
src/test/bench/testfilestore_backend.cc
src/test/objectstore/store_test.cc

index d316ab0c74362706eed155f1b625e50676302f36..e41552d258f27b3321c72f99bdebf52e096f8579 100644 (file)
@@ -4511,7 +4511,7 @@ int FileStore::list_collections(vector<coll_t>& ls)
         (de->d_name[1] == '.' &&
          de->d_name[2] == '\0')))
       continue;
-    ls.push_back(coll_t(de->d_name));
+    ls.push_back(coll_t::make_string_collection(de->d_name));
   }
 
   if (r > 0) {
index eae774d86d5f56322f17668cc80c24143b194565..f9d268c4356a2ec6747f6d960c3d172bd4b6a620 100644 (file)
@@ -264,7 +264,7 @@ bool GenericObjectMap::parse_header_key(const string &long_name,
   }
 
   if (out_coll)
-    *out_coll = coll_t(coll);
+    *out_coll = coll_t::make_string_coll(coll);
 
   return true;
 }
index 7c9ba6d9ef9c5222a631a69ec0be4368ea3ea6b7..7afb41db016178bbf9dd35cfa5225e4e4e9b4f64 100644 (file)
@@ -2591,7 +2591,7 @@ int KeyValueStore::list_collections(vector<coll_t>& ls)
 
   for (vector<ghobject_t>::const_iterator iter = oids.begin();
        iter != oids.end(); ++iter) {
-    ls.push_back(coll_t(iter->hobj.oid.name));
+    ls.push_back(coll_t::make_string_coll(iter->hobj.oid.name));
   }
 
   return 0;
index ffd4648b9cb5cb8454c43dded3e5f966bc854ddd..d89983277aed461a8d2b3d6709057584df306c28 100644 (file)
@@ -224,10 +224,10 @@ class KeyValueStore : public ObjectStore,
   // A special coll used by store collection info, each obj in this coll
   // represent a coll_t
   static bool is_coll_obj(coll_t c) {
-    return c == coll_t("COLLECTIONS");
+    return c == coll_t::make_string_coll("COLLECTIONS");
   }
   static coll_t get_coll_for_coll() {
-    return coll_t("COLLECTIONS");
+    return coll_t::make_string_coll("COLLECTIONS");
   }
   static ghobject_t make_ghobject_for_coll(const coll_t &col) {
     return ghobject_t(hobject_t(sobject_t(col.to_str(), CEPH_NOSNAP)));
index 13c3931d54a97b7e9a779998f32c069fe09cc6e1..b21e68044d3f391e1793bf93542ea09666d1dbfe 100644 (file)
@@ -475,19 +475,25 @@ ostream& operator<<(ostream& out, const spg_t &pg);
 // ----------------------
 
 class coll_t {
+  explicit coll_t(const std::string &str_)
+    : str(str_)
+  { }
+
 public:
   coll_t()
     : str("meta")
   { }
 
-  explicit coll_t(const std::string &str_)
-    : str(str_)
-  { }
+  coll_t(const coll_t& other) : str(other.str) {}
 
   explicit coll_t(spg_t pgid, snapid_t snap = CEPH_NOSNAP)
     : str(pg_and_snap_to_str(pgid, snap))
   { }
 
+  static coll_t make_string_coll(const std::string& s) {
+    return coll_t(s);
+  }
+
   const std::string& to_str() const {
     return str;
   }
index 461e1b313e776125423ad254810ee4606990c371..129ba81d51f0171aca8d3ecb50ca50ff48995d4d 100644 (file)
@@ -172,7 +172,7 @@ int main(int argc, char **argv)
     coll << "collection_" << num;
     std::cout << "collection " << coll.str() << std::endl;
     ObjectStore::Transaction t;
-    t.create_collection(coll_t(coll.str()));
+    t.create_collection(coll_t::make_string_coll(coll.str()));
     fs.apply_transaction(t);
   }
   {
index 755b571161fc6337488b59d452ce5fed66d93e70..fdc3a64d33d053b18f76195a88aca607d6f6142f 100644 (file)
@@ -41,7 +41,7 @@ void TestFileStoreBackend::write(
   ObjectStore::Sequencer *osr = &(osrs.find(coll_str)->second);
 
 
-  coll_t c(coll_str);
+  coll_t c(coll_t::make_string_coll(coll_str));
   hobject_t h(sobject_t(oid.substr(sep+1), 0));
   t->write(c, h, offset, bl.length(), bl);
 
@@ -70,7 +70,7 @@ void TestFileStoreBackend::read(
   size_t sep = oid.find("/");
   assert(sep != string::npos);
   assert(sep + 1 < oid.size());
-  coll_t c(oid.substr(0, sep));
+  coll_t c(coll_t::make_string_coll(oid.substr(0, sep)));
   hobject_t h(sobject_t(oid.substr(sep+1), 0));
   os->read(c, h, offset, length, *bl);
   finisher.queue(on_complete);
index 2513ae048e5402fc5bc0b30454fe220fdbadc9d4..09e4432f3ff4bf86316b5ad56e5740488114360f 100644 (file)
@@ -396,7 +396,7 @@ TEST_P(StoreTest, SimpleCloneTest) {
 
 TEST_P(StoreTest, SimpleCloneRangeTest) {
   int r;
-  coll_t cid = coll_t("coll");
+  coll_t cid;
   {
     ObjectStore::Transaction t;
     t.create_collection(cid);
@@ -405,6 +405,7 @@ TEST_P(StoreTest, SimpleCloneRangeTest) {
     ASSERT_EQ(r, 0);
   }
   ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
+  hoid.hobj.pool = -1;
   bufferlist small, newdata;
   small.append("small");
   {
@@ -415,6 +416,7 @@ TEST_P(StoreTest, SimpleCloneRangeTest) {
     ASSERT_EQ(r, 0);
   }
   ghobject_t hoid2(hobject_t(sobject_t("Object 2", CEPH_NOSNAP)));
+  hoid2.hobj.pool = -1;
   {
     ObjectStore::Transaction t;
     t.clone_range(cid, hoid, hoid2, 10, 5, 0);