]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/ObjectStore: pass bits to create_collection
authorSage Weil <sage@redhat.com>
Wed, 1 Apr 2015 00:32:36 +0000 (17:32 -0700)
committerSage Weil <sage@redhat.com>
Wed, 19 Aug 2015 21:03:53 +0000 (17:03 -0400)
This informs the backend how many bits of the hash range will be covered
by the collection.  Those bits are implicitly matched against the spg_t in
coll_t.

Signed-off-by: Sage Weil <sage@redhat.com>
16 files changed:
src/os/ObjectStore.h
src/os/Transaction.cc
src/osd/OSD.cc
src/osd/PG.cc
src/osd/PG.h
src/osd/ReplicatedPG.h
src/test/bench/small_io_bench_fs.cc
src/test/objectstore/DeterministicOpSequence.cc
src/test/objectstore/TestObjectStoreState.cc
src/test/objectstore/store_test.cc
src/test/objectstore/test_idempotent.cc
src/test/objectstore/workload_generator.cc
src/test/streamtest.cc
src/test/test_trans.cc
src/test/xattr_bench.cc
src/tools/ceph_objectstore_tool.cc

index f33e9985f71c314f4084ca483e393e7c3f9da6a4..eeb91bd94e28890316feaddb520d8bd328cf9e9c 100644 (file)
@@ -1190,7 +1190,7 @@ public:
       data.ops++;
     }
     /// Create the collection
-    void create_collection(coll_t cid) {
+    void create_collection(coll_t cid, int bits) {
       if (use_tbl) {
         __u32 op = OP_MKCOLL;
         ::encode(op, tbl);
@@ -1199,6 +1199,7 @@ public:
         Op* _op = _get_next_op();
         _op->op = OP_MKCOLL;
         _op->cid = _get_coll_id(cid);
+       _op->split_bits = bits;
       }
       data.ops++;
     }
index a5e6b515f3dbf9585a0cc095222282922c741a5c..714623f9eed4f3b3989ca2a1e40d3fae7412508e 100644 (file)
@@ -238,7 +238,7 @@ void ObjectStore::Transaction::_build_actions_from_tbl()
 
        ::decode(cid, p);
 
-       create_collection(cid);
+       create_collection(cid, 0);
       }
       break;
 
@@ -974,7 +974,7 @@ void ObjectStore::Transaction::generate_test_instances(list<ObjectStore::Transac
   t->clone(c, o1, o3);
   t->clone_range(c, o1, o2, 1, 12, 99);
 
-  t->create_collection(c);
+  t->create_collection(c, 12);
   t->collection_move_rename(c, o2, c2, o3);
   t->remove_collection(c);
   t->collection_setattr(c, string("this"), bl);
index 9767a209b417be8f08aae0bf82bfdc952891054f..96fae67a5ceb930b8a62d3a8266413abbc3b4a65 100644 (file)
@@ -1371,7 +1371,7 @@ int OSD::mkfs(CephContext *cct, ObjectStore *store, const string &dev,
       ::encode(sb, bl);
 
       ObjectStore::Transaction t;
-      t.create_collection(coll_t::meta());
+      t.create_collection(coll_t::meta(), 0);
       t.write(coll_t::meta(), OSD_SUPERBLOCK_POBJECT, 0, bl.length(), bl);
       ret = store->apply_transaction(t);
       if (ret) {
@@ -3197,7 +3197,7 @@ void OSD::handle_pg_peering_evt(
     switch (result) {
     case RES_NONE: {
       const pg_pool_t* pp = osdmap->get_pg_pool(pgid.pool());
-      PG::_create(*rctx.transaction, pgid);
+      PG::_create(*rctx.transaction, pgid, pgid.get_split_bits(pp->get_pg_num()));
       PG::_init(*rctx.transaction, pgid, pp);
 
       PG *pg = _create_lock_pg(
@@ -7055,7 +7055,7 @@ void OSD::handle_pg_create(OpRequestRef op)
     PG *pg = NULL;
     if (can_create_pg(pgid)) {
       const pg_pool_t* pp = osdmap->get_pg_pool(pgid.pool());
-      PG::_create(*rctx.transaction, pgid);
+      PG::_create(*rctx.transaction, pgid, pgid.get_split_bits(pp->get_pg_num()));
       PG::_init(*rctx.transaction, pgid, pp);
 
       pg_interval_map_t pi;
index 9746104a69441bec5f357d9ac85b092a3191c41f..9eca0b1dd464ef0219613eb4a351eac60142f8d2 100644 (file)
@@ -2700,10 +2700,10 @@ int PG::_prepare_write_info(map<string,bufferlist> *km,
   return 0;
 }
 
-void PG::_create(ObjectStore::Transaction& t, spg_t pgid)
+void PG::_create(ObjectStore::Transaction& t, spg_t pgid, int bits)
 {
   coll_t coll(pgid);
-  t.create_collection(coll);
+  t.create_collection(coll, bits);
 }
 
 void PG::_init(ObjectStore::Transaction& t, spg_t pgid, const pg_pool_t *pool)
index fbfa6db424b9b27605759db4648e039254d0ca35..542bbf0d7512f8d4997c4790c8041f297afbbecf 100644 (file)
@@ -2138,7 +2138,7 @@ public:
   // pg on-disk state
   void do_pending_flush();
 
-  static void _create(ObjectStore::Transaction& t, spg_t pgid);
+  static void _create(ObjectStore::Transaction& t, spg_t pgid, int bits);
   static void _init(ObjectStore::Transaction& t,
                    spg_t pgid, const pg_pool_t *pool);
 
index 02ea5265232e78d2a64280bd063e1efed6f291ee..b7f455af289a359f122089f4cbc00b17a8ada08a 100644 (file)
@@ -1467,7 +1467,7 @@ public:
     const pg_pool_t *pool,
     ObjectStore::Transaction *t) {
     coll_t target = coll_t(child);
-    PG::_create(*t, child);
+    PG::_create(*t, child, split_bits);
     t->split_collection(
       coll,
       split_bits,
index a72d0a7f54e75dbbb0dc7caa32e869940e405da7..83b085ca53bb00091136e3c37f56f753d8563511 100644 (file)
@@ -171,12 +171,12 @@ int main(int argc, char **argv)
     spg_t pgid(pg_t(num, 0), shard_id_t::NO_SHARD);
     std::cout << "collection " << pgid << std::endl;
     ObjectStore::Transaction t;
-    t.create_collection(coll_t(pgid));
+    t.create_collection(coll_t(pgid), 0);
     fs.apply_transaction(t);
   }
   {
     ObjectStore::Transaction t;
-    t.create_collection(coll_t());
+    t.create_collection(coll_t(), 0);
     fs.apply_transaction(t);
   }
 
index 829d3927b03982051a7efd59744e9a9a0c06bdfe..03209a7900b8c949fdc32a7fc53be0f3c2d5cb39 100644 (file)
@@ -444,7 +444,7 @@ void DeterministicOpSequence::_do_coll_create(coll_t cid, uint32_t pg_num, uint6
 {
   ObjectStore::Transaction t;
   note_txn(&t);
-  t.create_collection(cid);
+  t.create_collection(cid, 32);
   bufferlist hint;
   ::encode(pg_num, hint);
   ::encode(num_objs, hint);
index edfd0f4724596f637557b8436efcc2ce46316933..7693fc7530d17e33099f66ed6abf1888feb89567 100644 (file)
@@ -36,7 +36,7 @@ void TestObjectStoreState::init(int colls, int objs)
   ObjectStore::Transaction *t;
   t = new ObjectStore::Transaction;
 
-  t->create_collection(coll_t::meta());
+  t->create_collection(coll_t::meta(), 0);
   m_store->apply_transaction(*t);
 
   wait_for_ready();
@@ -49,7 +49,7 @@ void TestObjectStoreState::init(int colls, int objs)
         << " meta " << entry->m_meta_obj << dendl;
 
     t = new ObjectStore::Transaction;
-    t->create_collection(entry->m_coll);
+    t->create_collection(entry->m_coll, 32);
     bufferlist hint;
     uint32_t pg_num = colls;
     uint64_t num_objs = uint64_t(objs / colls);
index 7519e2ffee1ef8efd414febc796efe9567e93683..6f7b52592a6bdaf6efa1a3c3c9e9b610df43e0cf 100644 (file)
@@ -97,7 +97,7 @@ TEST_P(StoreTest, SimpleMetaColTest) {
   int r = 0;
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     cerr << "create collection" << std::endl;
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
@@ -111,7 +111,7 @@ TEST_P(StoreTest, SimpleMetaColTest) {
   }
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     cerr << "add collection" << std::endl;
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
@@ -130,7 +130,7 @@ TEST_P(StoreTest, SimplePGColTest) {
   int r = 0;
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 4);
     cerr << "create collection" << std::endl;
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
@@ -144,7 +144,7 @@ TEST_P(StoreTest, SimplePGColTest) {
   }
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 4);
     cerr << "add collection" << std::endl;
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
@@ -183,7 +183,7 @@ TEST_P(StoreTest, SimpleColPreHashTest) {
   {
     // Create a collection along with a hint
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 5);
     cerr << "create collection" << std::endl;
     bufferlist hint;
     ::encode(pg_num, hint);
@@ -214,7 +214,7 @@ TEST_P(StoreTest, SimpleObjectTest) {
   coll_t cid;
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     cerr << "Creating collection " << cid << std::endl;
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
@@ -260,7 +260,7 @@ TEST_P(StoreTest, SimpleListTest) {
   coll_t cid(spg_t(pg_t(0, 1), shard_id_t(1)));
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     cerr << "Creating collection " << cid << std::endl;
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
@@ -352,10 +352,11 @@ TEST_P(StoreTest, Sort) {
 
 TEST_P(StoreTest, MultipoolListTest) {
   int r;
-  coll_t cid = coll_t(spg_t(pg_t(1, 1), shard_id_t::NO_SHARD));
+  int poolid = 4373;
+  coll_t cid = coll_t(spg_t(pg_t(0, poolid), shard_id_t::NO_SHARD));
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     cerr << "Creating collection " << cid << std::endl;
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
@@ -412,7 +413,7 @@ TEST_P(StoreTest, SimpleCloneTest) {
   coll_t cid;
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     cerr << "Creating collection " << cid << std::endl;
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
@@ -485,7 +486,7 @@ TEST_P(StoreTest, SimpleCloneRangeTest) {
   coll_t cid;
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     cerr << "Creating collection " << cid << std::endl;
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
@@ -543,7 +544,7 @@ TEST_P(StoreTest, SimpleObjectLongnameTest) {
   coll_t cid;
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     cerr << "Creating collection " << cid << std::endl;
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
@@ -575,7 +576,7 @@ TEST_P(StoreTest, ManyObjectTest) {
   set<ghobject_t, ghobject_t::BitwiseComparator> created;
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
   }
@@ -821,7 +822,7 @@ public:
 
   int init() {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     return store->apply_transaction(t);
   }
 
@@ -1323,7 +1324,7 @@ TEST_P(StoreTest, HashCollisionTest) {
   int r;
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
   }
@@ -1404,7 +1405,7 @@ TEST_P(StoreTest, ScrubTest) {
   int r;
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
   }
@@ -1501,7 +1502,7 @@ TEST_P(StoreTest, OMapTest) {
   int r;
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
   }
@@ -1633,7 +1634,7 @@ TEST_P(StoreTest, XattrTest) {
   int r;
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     t.touch(cid, hoid);
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
@@ -1710,12 +1711,12 @@ void colsplittest(
   unsigned num_objects,
   unsigned common_suffix_size
   ) {
-  coll_t cid(spg_t(pg_t(5,2),shard_id_t::NO_SHARD));
-  coll_t tid(spg_t(pg_t(3,2),shard_id_t::NO_SHARD));
+  coll_t cid(spg_t(pg_t(0,52),shard_id_t::NO_SHARD));
+  coll_t tid(spg_t(pg_t(1<<common_suffix_size,52),shard_id_t::NO_SHARD));
   int r = 0;
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, common_suffix_size);
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
   }
@@ -1736,8 +1737,8 @@ void colsplittest(
   }
   {
     ObjectStore::Transaction t;
-    t.create_collection(tid);
-    t.split_collection(cid, common_suffix_size+1, 0, tid);
+    t.create_collection(tid, common_suffix_size + 1);
+    t.split_collection(cid, common_suffix_size+1, 1<<common_suffix_size, tid);
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
   }
@@ -1798,7 +1799,7 @@ TEST_P(StoreTest, TwoHash) {
   int r;
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
   }
@@ -1867,7 +1868,7 @@ TEST_P(StoreTest, MoveRename) {
   int r;
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     t.touch(cid, oid);
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
@@ -1947,7 +1948,7 @@ TEST_P(StoreTest, BigRGWObjectName) {
   int r;
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     t.touch(cid, oidhead);
     t.collection_move_rename(cid, oidhead, cid, oid);
     t.touch(cid, oidhead);
@@ -1990,7 +1991,7 @@ TEST_P(StoreTest, SetAllocHint) {
   int r;
   {
     ObjectStore::Transaction t;
-    t.create_collection(cid);
+    t.create_collection(cid, 0);
     t.touch(cid, hoid);
     r = store->apply_transaction(t);
     ASSERT_EQ(r, 0);
index a13783c784872966439644c4740cfae2e9e21102..dc685e09c96646e96935893f237d53796493ca08 100644 (file)
@@ -68,14 +68,14 @@ int main(int argc, char **argv) {
   boost::scoped_ptr<KeyValueDB> db(_db);
   boost::scoped_ptr<ObjectStore> store(new FileStore(store_path, store_dev));
 
-  coll_t coll(spg_t(pg_t(1,2),shard_id_t::NO_SHARD));
+  coll_t coll(spg_t(pg_t(0,12),shard_id_t::NO_SHARD));
 
   if (start_new) {
     std::cerr << "mkfs" << std::endl;
     assert(!store->mkfs());
     ObjectStore::Transaction t;
     assert(!store->mount());
-    t.create_collection(coll);
+    t.create_collection(coll, 0);
     store->apply_transaction(t);
   } else {
     assert(!store->mount());
index 4ef5384fc0206a4fdc1f40e32a7dd223494e9e5d..25047b574585268d594c7a8057e747392fe5d31d 100644 (file)
@@ -379,7 +379,7 @@ TestObjectStoreState::coll_entry_t
   m_collections.insert(make_pair(entry->m_id, entry));
 
   dout(2) << __func__ << " id " << entry->m_id << " coll " << entry->m_coll << dendl;
-  t->create_collection(entry->m_coll);
+  t->create_collection(entry->m_coll, 32);
   dout(2) << __func__ << " meta " << coll_t::meta() << "/" << entry->m_meta_obj << dendl;
   t->touch(coll_t::meta(), entry->m_meta_obj);
   return entry;
index 7639a7668f8cbeb7f6f599091535b640e3f60135..775b087e8ecff0b2abad64684d5e89cd4877820f 100644 (file)
@@ -144,7 +144,7 @@ int main(int argc, const char **argv)
   }
 
   ObjectStore::Transaction ft;
-  ft.create_collection(coll_t());
+  ft.create_collection(coll_t(), 0);
   fs->apply_transaction(ft);
 
   utime_t now = ceph_clock_now(g_ceph_context);
index aa81840ba26d8687b8ed08524d61bcaafdd1cc80..d482a9a9604e72930ffa42e0be70c714c4927c88 100644 (file)
@@ -59,7 +59,7 @@ int main(int argc, const char **argv)
   char buf[1 << 20];
   bufferlist bl;
   bl.append(buf, sizeof(buf));
-  t.create_collection(coll_t());
+  t.create_collection(coll_t(), 0);
 
   for (int i=0; i<mb; i++) {
     char f[30];
index 6cf3edd90964d7e911d4aa0caaaa9ac12da382ea..f2e89958415adb8dfc0fbc79ea0abacf93247f0d 100644 (file)
@@ -93,8 +93,8 @@ uint64_t do_run(ObjectStore *store, int attrsize, int numattrs,
   ObjectStore::Transaction t;
   map<coll_t, pair<set<string>, ObjectStore::Sequencer*> > collections;
   for (int i = 0; i < 3*THREADS; ++i) {
-    coll_t coll(spg_t(pg_t(i, run), shard_id_t::NO_SHARD));
-    t.create_collection(coll);
+    coll_t coll(spg_t(pg_t(0, i + 1000*run), shard_id_t::NO_SHARD));
+    t.create_collection(coll, 0);
     set<string> objects;
     for (int i = 0; i < transsize; ++i) {
       stringstream obj_str;
index 1a767fb0a62790dc91203fc1bfce59fc911a0700..796261a0542140314e8627250abde7eebf382332 100644 (file)
@@ -1343,7 +1343,8 @@ int ObjectStoreTool::do_import(ObjectStore *store, OSDSuperblock& sb,
 
   if (!dry_run) {
     ObjectStore::Transaction *t = new ObjectStore::Transaction;
-    PG::_create(*t, pgid);
+    PG::_create(*t, pgid,
+               pgid.get_split_bits(curmap.get_pg_pool(pgid.pool())->get_pg_num()));
     PG::_init(*t, pgid, NULL);
 
     // mark this coll for removal until we're done