From: Xiaoxi Chen Date: Sat, 25 Apr 2015 03:56:09 +0000 (+0800) Subject: Kill collection_list X-Git-Tag: v9.1.0~421^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c5dc4047e261e36ee457a3ec9f11a4122f85e2d9;p=ceph.git Kill collection_list use collection_list_impl as well. Signed-off-by: Xiaoxi Chen --- diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 1f3ecabfa296..0e0abe0e724a 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -4646,6 +4646,9 @@ int FileStore::collection_list_impl(coll_t c, ghobject_t start, ghobject_t end, if (start.is_max()) return 0; + ghobject_t temp_next; + if (!next) + next = &temp_next; // figure out the pool id. we need this in order to generate a // meaningful 'next' value. int64_t pool = -1; @@ -4716,31 +4719,6 @@ int FileStore::collection_list_impl(coll_t c, ghobject_t start, ghobject_t end, return 0; } -int FileStore::collection_list(coll_t c, vector& ls) -{ - tracepoint(objectstore, collection_list_enter, c.c_str()); - - if (!c.is_temp() && !c.is_meta()) { - coll_t temp = c.get_temp(); - int r = collection_list(temp, ls); - if (r < 0) - return r; - } - - Index index; - int r = get_index(c, &index); - if (r < 0) - return r; - - assert(NULL != index.index); - RWLock::RLocker l((index.index)->access_lock); - - r = index->collection_list(&ls); - assert(!m_filestore_fail_eio || r != -EIO); - tracepoint(objectstore, collection_list_exit, r); - return r; -} - int FileStore::omap_get(coll_t c, const ghobject_t &hoid, bufferlist *header, map *out) diff --git a/src/os/FileStore.h b/src/os/FileStore.h index bb08ecaef720..5f5e8ab69b83 100644 --- a/src/os/FileStore.h +++ b/src/os/FileStore.h @@ -625,7 +625,6 @@ public: int collection_stat(coll_t c, struct stat *st); bool collection_exists(coll_t c); bool collection_empty(coll_t c); - int collection_list(coll_t c, vector& oid); // omap (see ObjectStore.h for documentation) int omap_get(coll_t c, const ghobject_t &oid, bufferlist *header, diff --git a/src/os/KeyValueStore.cc b/src/os/KeyValueStore.cc index 8868920f2c42..b69833aaf8e0 100644 --- a/src/os/KeyValueStore.cc +++ b/src/os/KeyValueStore.cc @@ -2510,11 +2510,6 @@ int KeyValueStore::collection_list_impl(coll_t c, ghobject_t start, return r; } -int KeyValueStore::collection_list(coll_t c, vector& ls) -{ - return collection_list_impl(c, ghobject_t(), ghobject_t::get_max(), 0, 0, &ls, 0); -} - int KeyValueStore::collection_version_current(coll_t c, uint32_t *version) { *version = COLLECTION_VERSION; diff --git a/src/os/KeyValueStore.h b/src/os/KeyValueStore.h index 3cb6bc014b87..51078b63e0ba 100644 --- a/src/os/KeyValueStore.h +++ b/src/os/KeyValueStore.h @@ -618,7 +618,6 @@ class KeyValueStore : public ObjectStore, int list_collections(vector& ls); bool collection_exists(coll_t c); bool collection_empty(coll_t c); - int collection_list(coll_t c, vector& oid); int collection_list_impl(coll_t c, ghobject_t start, ghobject_t end, int max, snapid_t snap, vector *ls, ghobject_t *next); diff --git a/src/os/MemStore.cc b/src/os/MemStore.cc index bfebdbd0e060..8b4b01d117db 100644 --- a/src/os/MemStore.cc +++ b/src/os/MemStore.cc @@ -421,21 +421,6 @@ bool MemStore::collection_empty(coll_t cid) return c->object_map.empty(); } -int MemStore::collection_list(coll_t cid, vector& o) -{ - dout(10) << __func__ << " " << cid << dendl; - CollectionRef c = get_collection(cid); - if (!c) - return -ENOENT; - RWLock::RLocker l(c->lock); - - for (map::iterator p = c->object_map.begin(); - p != c->object_map.end(); - ++p) - o.push_back(p->first); - return 0; -} - int MemStore::collection_list_impl(coll_t cid, ghobject_t start, ghobject_t end, int max, snapid_t snap, vector *ls, ghobject_t *next) @@ -447,7 +432,7 @@ int MemStore::collection_list_impl(coll_t cid, ghobject_t start, ghobject_t end, map::iterator p = c->object_map.lower_bound(start); while (p != c->object_map.end() && - (max == -1 || ls->size() < (unsigned)max) && + ls->size() < (unsigned)max && p->first < end) { ls->push_back(p->first); ++p; diff --git a/src/os/MemStore.h b/src/os/MemStore.h index 97f41429da2a..63e30b2f90c5 100644 --- a/src/os/MemStore.h +++ b/src/os/MemStore.h @@ -306,7 +306,6 @@ public: int list_collections(vector& ls); bool collection_exists(coll_t c); bool collection_empty(coll_t c); - int collection_list(coll_t cid, vector& o); int collection_list_impl(coll_t cid, ghobject_t start, ghobject_t end, int max, snapid_t snap, vector *ls, ghobject_t *next); diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index e0a517787f19..441ba537feae 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -2028,15 +2028,6 @@ public: */ virtual bool collection_empty(coll_t c) = 0; - /** - * collection_list - get all objects of a collection in sorted order - * - * @param c collection name - * @param o [out] list of objects - * @returns 0 on success, negative error code on failure - */ - virtual int collection_list(coll_t c, vector& o) = 0; - /** * list contents of a collection that fall in the range [start, end) and no more than a specified many result * diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index b5b6d630ed44..3334593a552c 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2506,10 +2506,9 @@ void OSD::clear_temp_objects() ghobject_t next; while (1) { vector objects; - store->collection_list_partial(*p, next, - store->get_ideal_list_min(), - store->get_ideal_list_max(), - 0, &objects, &next); + store->collection_list_impl(*p, next, ghobject_t::get_max(), + store->get_ideal_list_max(), + 0, &objects, &next); if (objects.empty()) break; vector::iterator q; @@ -2547,7 +2546,7 @@ void OSD::recursive_remove_collection(ObjectStore *store, spg_t pgid, coll_t tmp SnapMapper mapper(&driver, 0, 0, 0, pgid.shard); vector objects; - store->collection_list(tmp, objects); + store->collection_list_impl(tmp, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &objects, 0); // delete them. unsigned removed = 0; diff --git a/src/test/objectstore/FileStoreDiff.cc b/src/test/objectstore/FileStoreDiff.cc index ad4f62bff73e..a40437a522e8 100644 --- a/src/test/objectstore/FileStoreDiff.cc +++ b/src/test/objectstore/FileStoreDiff.cc @@ -132,13 +132,13 @@ bool FileStoreDiff::diff_objects(FileStore *a_store, FileStore *b_store, coll_t int err; std::vector b_objects, a_objects; - err = b_store->collection_list(coll, b_objects); + err = b_store->collection_list_impl(coll, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &b_objects, NULL); if (err < 0) { dout(0) << "diff_objects list on verify coll " << coll.to_str() << " returns " << err << dendl; return true; } - err = a_store->collection_list(coll, a_objects); + err = a_store->collection_list_impl(coll, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &a_objects, NULL); if (err < 0) { dout(0) << "diff_objects list on store coll " << coll.to_str() << " returns " << err << dendl; diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index e13518855075..fdf64b8164ed 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -585,7 +585,7 @@ TEST_P(StoreTest, ManyObjectTest) { set listed; vector objects; - r = store->collection_list(cid, objects); + r = store->collection_list_impl(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &objects, 0); ASSERT_EQ(r, 0); cerr << "objects.size() is " << objects.size() << std::endl; @@ -1117,7 +1117,7 @@ public: ASSERT_GT(available_objects.count(*i), (unsigned)0); } - int r = store->collection_list(cid, objects); + int r = store->collection_list_impl(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &objects, 0); ASSERT_EQ(r, 0); objects_set2.insert(objects.begin(), objects.end()); ASSERT_EQ(objects_set2.size(), available_objects.size()); @@ -1313,7 +1313,7 @@ TEST_P(StoreTest, HashCollisionTest) { } } vector objects; - r = store->collection_list(cid, objects); + r = store->collection_list_impl(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &objects, 0); ASSERT_EQ(r, 0); set listed(objects.begin(), objects.end()); cerr << "listed.size() is " << listed.size() << " and created.size() is " << created.size() << std::endl; @@ -1408,7 +1408,7 @@ TEST_P(StoreTest, ScrubTest) { } vector objects; - r = store->collection_list(cid, objects); + r = store->collection_list_impl(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &objects, 0); ASSERT_EQ(r, 0); set listed(objects.begin(), objects.end()); cerr << "listed.size() is " << listed.size() << " and created.size() is " << created.size() << std::endl; @@ -1706,7 +1706,7 @@ void colsplittest( ObjectStore::Transaction t; vector objects; - r = store->collection_list(cid, objects); + r = store->collection_list_impl(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &objects, 0); ASSERT_EQ(r, 0); ASSERT_EQ(objects.size(), num_objects); for (vector::iterator i = objects.begin(); @@ -1717,7 +1717,7 @@ void colsplittest( } objects.clear(); - r = store->collection_list(tid, objects); + r = store->collection_list_impl(tid, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &objects, 0); ASSERT_EQ(r, 0); ASSERT_EQ(objects.size(), num_objects); for (vector::iterator i = objects.begin(); @@ -1925,7 +1925,7 @@ TEST_P(StoreTest, BigRGWObjectName) { { vector objects; - r = store->collection_list(cid, objects); + r = store->collection_list_impl(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, 0, &objects, 0); ASSERT_EQ(r, 0); ASSERT_EQ(objects.size(), 1u); ASSERT_EQ(objects[0], oid2); diff --git a/src/test/os/TestFlatIndex.cc b/src/test/os/TestFlatIndex.cc index 7cebec76e1a9..ea1d24f3766c 100644 --- a/src/test/os/TestFlatIndex.cc +++ b/src/test/os/TestFlatIndex.cc @@ -51,7 +51,7 @@ TEST(FlatIndex, collection) { const std::string object_name(10, 'A'); ghobject_t hoid(hobject_t(object_t(object_name), key, CEPH_NOSNAP, hash, pool, "")); vector ls; - ASSERT_THROW(index.collection_list_partial(hoid, 0, 0, 0, &ls, &hoid), FailedAssertion); + ASSERT_THROW(index.collection_list_partial(hoid, ghobject_t::get_max(), 0, 0, &ls, &hoid), FailedAssertion); } TEST(FlatIndex, created_unlink) { diff --git a/src/test/os/TestLFNIndex.cc b/src/test/os/TestLFNIndex.cc index 49b592adb53e..60ea6130685e 100644 --- a/src/test/os/TestLFNIndex.cc +++ b/src/test/os/TestLFNIndex.cc @@ -78,7 +78,6 @@ protected: virtual int _collection_list_partial( const ghobject_t &start, const ghobject_t &end, - int min_count, int max_count, vector *ls, ghobject_t *next