From f8436f1dc5fe39a9167c86015de279e832c2e67a Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 22 Dec 2014 16:39:38 -0800 Subject: shard_id_t: change NO_SHARD to sort before 0 (min instead of max) The min ghobject has shard NO_SHARD, and is the default constructed value. That initial value is assumed in uncounted ways across the code base when users do ghobject_t foo; foo.this = that; such that changing it is dangerous. It is safer to change the shard_id_t sort order such that NO_SHARD is signed instead of unsigned. The value doesn't actually change (still 0xff), but the sorting does. Note that only a single comparison triggers a signed/unsigned warning from this change, and it assumes that the shard is not NO_SHARD (ec pool) and we case it to preserve the old behavior anyway. In PGBackend we change the minimum value for the objects_list_partial() method to start with NO_SHARD. Signed-off-by: Sage Weil --- src/osd/PGBackend.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/osd/PGBackend.cc') diff --git a/src/osd/PGBackend.cc b/src/osd/PGBackend.cc index 319110cd0dd..64423dee1f3 100644 --- a/src/osd/PGBackend.cc +++ b/src/osd/PGBackend.cc @@ -109,7 +109,7 @@ int PGBackend::objects_list_partial( // make sure the result list has the marker object ( // it might have multiple generations though, which would // be filtered). - ghobject_t _next(begin, 0, shard_id_t(0)); + ghobject_t _next(begin, 0, shard_id_t::NO_SHARD); ls->reserve(max); int r = 0; while (!_next.is_max() && ls->size() < (unsigned)min) { -- cgit v1.2.3