From: Sage Weil Date: Thu, 23 Jul 2015 14:20:47 +0000 (-0400) Subject: use explicit ghobject_t comparators X-Git-Tag: v9.1.0~346^2~31 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=64e00ba9714a45ba3b6c74c6e640901a1f6669e3;p=ceph.git use explicit ghobject_t comparators Signed-off-by: Sage Weil --- diff --git a/src/os/DBObjectMap.cc b/src/os/DBObjectMap.cc index 43dba25f2f51..8ff7ef78fa57 100644 --- a/src/os/DBObjectMap.cc +++ b/src/os/DBObjectMap.cc @@ -887,10 +887,10 @@ int DBObjectMap::clone(const ghobject_t &oid, if (oid == target) return 0; - MapHeaderLock _l1(this, MIN(oid, target)); - MapHeaderLock _l2(this, MAX(oid, target)); + MapHeaderLock _l1(this, MIN_GHOBJ(oid, target, true)); + MapHeaderLock _l2(this, MAX_GHOBJ(oid, target, true)); MapHeaderLock *lsource, *ltarget; - if (oid > target) { + if (cmp_bitwise(oid, target) > 0) { lsource = &_l2; ltarget= &_l1; } else { diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index aace0544f545..2dcf51e8b8e0 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -4680,7 +4680,7 @@ int FileStore::collection_list(coll_t c, ghobject_t start, ghobject_t end, sep.hobj.pool = -1; sep.set_shard(shard); if (!c.is_temp() && !c.is_meta()) { - if (start < sep) { + if (cmp_bitwise(start, sep) < 0) { // bitwise vs nibble doesn't matter here dout(10) << __func__ << " first checking temp pool" << dendl; coll_t temp = c.get_temp(); int r = collection_list(temp, start, end, sort_bitwise, max, ls, next); diff --git a/src/os/GenericObjectMap.cc b/src/os/GenericObjectMap.cc index 207236a7547b..a397a05724cd 100644 --- a/src/os/GenericObjectMap.cc +++ b/src/os/GenericObjectMap.cc @@ -1101,14 +1101,14 @@ int GenericObjectMap::list_objects(const coll_t &cid, ghobject_t start, ghobject break; } - if (header.oid >= end) { + if (cmp_bitwise(header.oid, end) >= 0) { if (next) *next = ghobject_t::get_max(); break; } - assert(start <= header.oid); - assert(header.oid < end); + assert(cmp_bitwise(start, header.oid) <= 0); + assert(cmp_bitwise(header.oid, end) < 0); size++; diff --git a/src/os/MemStore.cc b/src/os/MemStore.cc index 781564438729..0683d6ab3daa 100644 --- a/src/os/MemStore.cc +++ b/src/os/MemStore.cc @@ -434,8 +434,8 @@ int MemStore::collection_list(coll_t cid, ghobject_t start, ghobject_t end, map::iterator p = c->object_map.lower_bound(start); while (p != c->object_map.end() && - ls->size() < (unsigned)max && - p->first < end) { + ls->size() < (unsigned)max && + cmp_bitwise(p->first, end) < 0) { ls->push_back(p->first); ++p; } diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index b21d6a7cc19f..7519e2ffee1e 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -329,24 +329,24 @@ TEST_P(StoreTest, Sort) { ASSERT_EQ(a, b); b.oid.name = "b"; ASSERT_NE(a, b); - ASSERT_LT(a, b); + ASSERT_TRUE(cmp_bitwise(a, b) < 0); a.pool = 1; b.pool = 2; - ASSERT_LT(a, b); + ASSERT_TRUE(cmp_bitwise(a, b) < 0); a.pool = 3; - ASSERT_GT(a, b); + ASSERT_TRUE(cmp_bitwise(a, b) > 0); } { ghobject_t a(hobject_t(sobject_t("a", CEPH_NOSNAP))); ghobject_t b(hobject_t(sobject_t("b", CEPH_NOSNAP))); a.hobj.pool = 1; b.hobj.pool = 1; - ASSERT_LT(a, b); + ASSERT_TRUE(cmp_bitwise(a, b) < 0); a.hobj.pool = -3; - ASSERT_LT(a, b); + ASSERT_TRUE(cmp_bitwise(a, b) < 0); a.hobj.pool = 1; b.hobj.pool = -3; - ASSERT_GT(a, b); + ASSERT_TRUE(cmp_bitwise(a, b) > 0); } } diff --git a/src/test/osd/types.cc b/src/test/osd/types.cc index 63b64486217e..b69a88a1c4e7 100644 --- a/src/test/osd/types.cc +++ b/src/test/osd/types.cc @@ -1378,14 +1378,14 @@ TEST(ghobject_t, cmp) { sep.set_shard(shard_id_t(1)); sep.hobj.pool = -1; cout << min << " < " << sep << std::endl; - ASSERT_LT(min, sep); + ASSERT_TRUE(cmp_bitwise(min, sep) < 0); sep.set_shard(shard_id_t::NO_SHARD); cout << "sep shard " << sep.shard_id << std::endl; ghobject_t o(hobject_t(object_t(), string(), CEPH_NOSNAP, 0x42, 1, string())); cout << "o " << o << std::endl; - ASSERT_GT(o, sep); + ASSERT_TRUE(cmp_bitwise(o, sep) > 0); } /*