Fix up callers.
Signed-off-by: Sage Weil <sage@redhat.com>
return true;
}
-int cmp_nibblewise(const hobject_t& l, const hobject_t& r)
-{
- if (l.max < r.max)
- return -1;
- if (l.max > r.max)
- return 1;
- if (l.pool < r.pool)
- return -1;
- if (l.pool > r.pool)
- return 1;
- if (l.get_nibblewise_key() < r.get_nibblewise_key())
- return -1;
- if (l.get_nibblewise_key() > r.get_nibblewise_key())
- return 1;
- if (l.nspace < r.nspace)
- return -1;
- if (l.nspace > r.nspace)
- return 1;
- if (l.get_effective_key() < r.get_effective_key())
- return -1;
- if (l.get_effective_key() > r.get_effective_key())
- return 1;
- if (l.oid < r.oid)
- return -1;
- if (l.oid > r.oid)
- return 1;
- if (l.snap < r.snap)
- return -1;
- if (l.snap > r.snap)
- return 1;
- return 0;
-}
-
-int cmp_bitwise(const hobject_t& l, const hobject_t& r)
+int cmp(const hobject_t& l, const hobject_t& r)
{
if (l.max < r.max)
return -1;
return true;
}
-int cmp_nibblewise(const ghobject_t& l, const ghobject_t& r)
-{
- if (l.max < r.max)
- return -1;
- if (l.max > r.max)
- return 1;
- if (l.shard_id < r.shard_id)
- return -1;
- if (l.shard_id > r.shard_id)
- return 1;
- int ret = cmp_nibblewise(l.hobj, r.hobj);
- if (ret != 0)
- return ret;
- if (l.generation < r.generation)
- return -1;
- if (l.generation > r.generation)
- return 1;
- return 0;
-}
-
-int cmp_bitwise(const ghobject_t& l, const ghobject_t& r)
+int cmp(const ghobject_t& l, const ghobject_t& r)
{
if (l.max < r.max)
return -1;
return -1;
if (l.shard_id > r.shard_id)
return 1;
- int ret = cmp_bitwise(l.hobj, r.hobj);
+ int ret = cmp(l.hobj, r.hobj);
if (ret != 0)
return ret;
if (l.generation < r.generation)
void decode(json_spirit::Value& v);
void dump(Formatter *f) const;
static void generate_test_instances(list<hobject_t*>& o);
- friend int cmp_nibblewise(const hobject_t& l, const hobject_t& r);
- friend int cmp_bitwise(const hobject_t& l, const hobject_t& r);
+ friend int cmp(const hobject_t& l, const hobject_t& r);
+ friend bool operator>(const hobject_t& l, const hobject_t& r) {
+ return cmp(l, r) > 0;
+ }
+ friend bool operator>=(const hobject_t& l, const hobject_t& r) {
+ return cmp(l, r) >= 0;
+ }
+ friend bool operator<(const hobject_t& l, const hobject_t& r) {
+ return cmp(l, r) < 0;
+ }
+ friend bool operator<=(const hobject_t& l, const hobject_t& r) {
+ return cmp(l, r) <= 0;
+ }
friend bool operator==(const hobject_t&, const hobject_t&);
friend bool operator!=(const hobject_t&, const hobject_t&);
friend struct ghobject_t;
struct NibblewiseComparator {
bool operator()(const hobject_t& l, const hobject_t& r) const {
- return cmp_nibblewise(l, r) < 0;
+ return cmp(l, r) < 0;
}
};
struct BitwiseComparator {
bool operator()(const hobject_t& l, const hobject_t& r) const {
- return cmp_bitwise(l, r) < 0;
+ return cmp(l, r) < 0;
}
};
bool bitwise;
explicit Comparator(bool b) : bitwise(b) {}
bool operator()(const hobject_t& l, const hobject_t& r) const {
- if (bitwise)
- return cmp_bitwise(l, r) < 0;
- else
- return cmp_nibblewise(l, r) < 0;
+ return cmp(l, r) < 0;
}
};
struct ComparatorWithDefault {
bool bitwise;
explicit ComparatorWithDefault(bool b=true) : bitwise(b) {}
bool operator()(const hobject_t& l, const hobject_t& r) const {
- if (bitwise)
- return cmp_bitwise(l, r) < 0;
- else
- return cmp_nibblewise(l, r) < 0;
+ return cmp(l, r) < 0;
}
};
template <typename T>
return !rhs.is_max();
}
-extern int cmp_nibblewise(const hobject_t& l, const hobject_t& r);
-extern int cmp_bitwise(const hobject_t& l, const hobject_t& r);
-static inline int cmp(const hobject_t& l, const hobject_t& r, bool sort_bitwise) {
- if (sort_bitwise)
- return cmp_bitwise(l, r);
- else
- return cmp_nibblewise(l, r);
-}
+extern int cmp(const hobject_t& l, const hobject_t& r);
template <typename T>
-static inline int cmp(const hobject_t &l, const T&, bool sort_bitwise) {
+static inline int cmp(const hobject_t &l, const T&) {
static_assert(always_false<T>::value::value, "Do not compare to get_max()");
return l.is_max() ? 0 : -1;
}
template <typename T>
-static inline int cmp(const T&, const hobject_t&r, bool sort_bitwise) {
- static_assert(always_false<T>::value::value, "Do not compare to get_max()");
- return r.is_max() ? 0 : 1;
-}
-template <typename T>
-static inline int cmp_nibblewise(const hobject_t &l, const T&, bool sort_bitwise) {
- static_assert(always_false<T>::value::value, "Do not compare to get_max()");
- return l.is_max() ? 0 : -1;
-}
-template <typename T>
-static inline int cmp_nibblewise(const T&, const hobject_t&r, bool sort_bitwise) {
- static_assert(always_false<T>::value::value, "Do not compare to get_max()");
- return r.is_max() ? 0 : 1;
-}
-template <typename T>
-static inline int cmp_bitwise(const hobject_t &l, const T&, bool sort_bitwise) {
- static_assert(always_false<T>::value::value, "Do not compare to get_max()");
- return l.is_max() ? 0 : -1;
-}
-template <typename T>
-static inline int cmp_bitwise(const T&, const hobject_t&r, bool sort_bitwise) {
+static inline int cmp(const T&, const hobject_t&r) {
static_assert(always_false<T>::value::value, "Do not compare to get_max()");
return r.is_max() ? 0 : 1;
}
-// these are convenient
-static inline hobject_t MAX_HOBJ(const hobject_t& l, const hobject_t& r, bool bitwise) {
- if (cmp(l, r, bitwise) >= 0)
- return l;
- else
- return r;
-}
-
-static inline hobject_t MIN_HOBJ(const hobject_t& l, const hobject_t& r, bool bitwise) {
- if (cmp(l, r, bitwise) <= 0)
- return l;
- else
- return r;
-}
-
typedef version_t gen_t;
struct ghobject_t {
size_t encoded_size() const;
void dump(Formatter *f) const;
static void generate_test_instances(list<ghobject_t*>& o);
- friend int cmp_nibblewise(const ghobject_t& l, const ghobject_t& r);
- friend int cmp_bitwise(const ghobject_t& l, const ghobject_t& r);
+ friend int cmp(const ghobject_t& l, const ghobject_t& r);
+ friend bool operator>(const ghobject_t& l, const ghobject_t& r) {
+ return cmp(l, r) > 0;
+ }
+ friend bool operator>=(const ghobject_t& l, const ghobject_t& r) {
+ return cmp(l, r) >= 0;
+ }
+ friend bool operator<(const ghobject_t& l, const ghobject_t& r) {
+ return cmp(l, r) < 0;
+ }
+ friend bool operator<=(const ghobject_t& l, const ghobject_t& r) {
+ return cmp(l, r) <= 0;
+ }
friend bool operator==(const ghobject_t&, const ghobject_t&);
friend bool operator!=(const ghobject_t&, const ghobject_t&);
struct NibblewiseComparator {
bool operator()(const ghobject_t& l, const ghobject_t& r) const {
- return cmp_nibblewise(l, r) < 0;
+ return cmp(l, r) < 0;
}
};
struct BitwiseComparator {
bool operator()(const ghobject_t& l, const ghobject_t& r) const {
- return cmp_bitwise(l, r) < 0;
+ return cmp(l, r) < 0;
}
};
bool bitwise;
explicit Comparator(bool b) : bitwise(b) {}
bool operator()(const ghobject_t& l, const ghobject_t& r) const {
- if (bitwise)
- return cmp_bitwise(l, r) < 0;
- else
- return cmp_nibblewise(l, r) < 0;
+ return cmp(l, r) < 0;
}
};
};
WRITE_EQ_OPERATORS_4(ghobject_t, max, shard_id, hobj, generation)
-extern int cmp_nibblewise(const ghobject_t& l, const ghobject_t& r);
-extern int cmp_bitwise(const ghobject_t& l, const ghobject_t& r);
-static inline int cmp(const ghobject_t& l, const ghobject_t& r,
- bool sort_bitwise) {
- if (sort_bitwise)
- return cmp_bitwise(l, r);
- else
- return cmp_nibblewise(l, r);
-}
-
-// these are convenient
-static inline ghobject_t MAX_GHOBJ(const ghobject_t& l, const ghobject_t& r,
- bool bitwise) {
- if (cmp(l, r, bitwise) >= 0)
- return l;
- else
- return r;
-}
+extern int cmp(const ghobject_t& l, const ghobject_t& r);
-static inline ghobject_t MIN_GHOBJ(const ghobject_t& l, const ghobject_t& r,
- bool bitwise) {
- if (cmp(l, r, bitwise) <= 0)
- return l;
- else
- return r;
-}
#endif
{
hobject_t *lhs = (hobject_t*)lhs_cur;
hobject_t *rhs = (hobject_t*)rhs_cur;
- return cmp_bitwise(*lhs, *rhs);
+ return cmp(*lhs, *rhs);
}
extern "C" int rados_object_list(rados_ioctx_t io,
{
const hobject_t lhs_hobj = (c_cursor == nullptr) ? hobject_t() : *((hobject_t*)c_cursor);
const hobject_t rhs_hobj = (rhs.c_cursor == nullptr) ? hobject_t() : *((hobject_t*)(rhs.c_cursor));
- return cmp_bitwise(lhs_hobj, rhs_hobj) == -1;
+ return lhs_hobj < rhs_hobj;
}
librados::ObjectCursor::ObjectCursor(const librados::ObjectCursor &rhs)
if (oid == target)
return 0;
- MapHeaderLock _l1(this, MIN_GHOBJ(oid, target, true));
- MapHeaderLock _l2(this, MAX_GHOBJ(oid, target, true));
+ MapHeaderLock _l1(this, std::min(oid, target));
+ MapHeaderLock _l2(this, std::max(oid, target));
MapHeaderLock *lsource, *ltarget;
- if (cmp_bitwise(oid, target) > 0) {
+ if (oid > target) {
lsource = &_l2;
ltarget= &_l1;
} else {
sep.hobj.pool = -1;
sep.set_shard(shard);
if (!c.is_temp() && !c.is_meta()) {
- if (cmp_bitwise(start, sep) < 0) { // bitwise vs nibble doesn't matter here
+ if (start < sep) {
dout(10) << __func__ << " first checking temp pool" << dendl;
coll_t temp = c.get_temp();
int r = collection_list(temp, start, end, max, ls, next);
for (map<string, ghobject_t>::iterator i = rev_objects.begin();
i != rev_objects.end();
++i) {
- if (next_object && cmp_bitwise(i->second, *next_object) < 0)
+ if (next_object && i->second < *next_object)
continue;
string hash_prefix = get_path_str(i->second);
hash_prefixes->insert(hash_prefix);
*next = j->second;
return 0;
}
- if (cmp_bitwise(j->second, end) >= 0) {
+ if (j->second >= end) {
if (next)
*next = j->second;
return 0;
}
- if (!next || cmp_bitwise(j->second, *next) >= 0) {
+ if (!next || j->second >= *next) {
dout(20) << __func__ << " prefix " << *i << " ob " << j->second << dendl;
out->push_back(j->second);
}
return str;
}
- struct CmpPairNibblewise {
- bool operator()(const pair<string, ghobject_t>& l,
- const pair<string, ghobject_t>& r)
- {
- if (l.first < r.first)
- return true;
- if (l.first > r.first)
- return false;
- if (cmp_nibblewise(l.second, r.second) < 0)
- return true;
- return false;
- }
- };
-
struct CmpPairBitwise {
bool operator()(const pair<string, ghobject_t>& l,
const pair<string, ghobject_t>& r)
return true;
if (l.first > r.first)
return false;
- if (cmp_bitwise(l.second, r.second) < 0)
+ if (cmp(l.second, r.second) < 0)
return true;
return false;
}
map<ghobject_t,ObjectRef,ghobject_t::BitwiseComparator>::iterator p = c->object_map.lower_bound(start);
while (p != c->object_map.end() &&
ls->size() < (unsigned)max &&
- cmp_bitwise(p->first, end) < 0) {
+ p->first < end) {
ls->push_back(p->first);
++p;
}
assert(!shards.count(i->shard));
const pg_info_t &info = get_parent()->get_shard_info(*i);
const pg_missing_t &missing = get_parent()->get_shard_missing(*i);
- if (cmp(hoid, info.last_backfill, get_parent()->sort_bitwise()) < 0 &&
+ if (hoid < info.last_backfill &&
!missing.is_missing(hoid)) {
have.insert(i->shard);
shards.insert(make_pair(i->shard, *i));
set extent_set;
bool operator<(const object_extent_set &rhs) const {
- return cmp_bitwise(oid, rhs.oid) < 0;
+ return oid < rhs.oid;
}
struct uint_cmp {
};
struct Cmp {
bool operator()(const hobject_t &oid, const object_extent_set &rhs) const {
- return cmp_bitwise(oid, rhs.oid) < 0;
+ return oid < rhs.oid;
}
bool operator()(const object_extent_set &lhs, const hobject_t &oid) const {
- return cmp_bitwise(lhs.oid, oid) < 0;
+ return lhs.oid < oid;
}
};
// advance
pos = _pgid.get_hobj_end(osdmap->get_pg_pool(pos.pool)->get_pg_num());
dout(20) << __func__ << " next pg " << pos << dendl;
- } while (cmp_bitwise(pos, m->end) < 0);
+ } while (pos < m->end);
}
template<typename T, int MSGTYPE>
<< dendl;
continue;
}
- if (cmp(p->first, oinfo.last_backfill, sort_bitwise) >= 0) {
+ if (p->first >= oinfo.last_backfill) {
// FIXME: this is _probably_ true, although it could conceivably
// be in the undefined region! Hmm!
ldout(pg->cct, 10) << "search_for_missing " << soid << " " << need
for (list<pg_log_entry_t>::iterator p = m->log.log.begin();
p != m->log.log.end();
++p)
- if (cmp(p->soid, pi.last_backfill, get_sort_bitwise()) <= 0)
+ if (p->soid <= pi.last_backfill)
pm.add_next_event(*p);
}
Mutex::Locker l(backoff_lock);
auto p = backoffs.lower_bound(begin);
while (p != backoffs.end()) {
- int r = cmp_bitwise(p->first, end);
+ int r = cmp(p->first, end);
dout(20) << __func__ << " ? " << r << " " << p->first
<< " " << p->second << dendl;
// note: must still examine begin=end=p->first case
- if (r > 0 || (r == 0 && cmp_bitwise(begin, end) < 0)) {
+ if (r > 0 || (r == 0 && begin < end)) {
break;
}
dout(20) << __func__ << " checking " << p->first
auto q = p->second.begin();
while (q != p->second.end()) {
dout(20) << __func__ << " checking " << *q << dendl;
- int r = cmp_bitwise((*q)->begin, begin);
- if (r == 0 || (r > 0 &&
- cmp_bitwise((*q)->end, end) < 0)) {
+ int r = cmp((*q)->begin, begin);
+ if (r == 0 || (r > 0 && (*q)->end < end)) {
bv.push_back(*q);
q = p->second.erase(q);
} else {
* here past last_backfill. It's ok for the same reason as
* above */
if (transaction_applied &&
- (cmp(p->soid, info.last_backfill, get_sort_bitwise()) > 0)) {
+ p->soid > info.last_backfill) {
pg_log.roll_forward(&handler);
}
}
for (auto p = projected_log.log.rbegin();
p != projected_log.log.rend();
++p) {
- if (cmp(p->soid, scrubber.start, get_sort_bitwise()) >= 0 &&
- cmp(p->soid, scrubber.end, get_sort_bitwise()) < 0) {
+ if (p->soid >= scrubber.start &&
+ p->soid < scrubber.end) {
scrubber.subset_last_update = p->version;
break;
}
pg_log.get_log().log.rbegin();
p != pg_log.get_log().log.rend();
++p) {
- if (cmp(p->soid, scrubber.start, get_sort_bitwise()) >= 0 &&
- cmp(p->soid, scrubber.end, get_sort_bitwise()) < 0) {
+ if (p->soid >= scrubber.start &&
+ p->soid < scrubber.end) {
scrubber.subset_last_update = p->version;
break;
}
auto pinfoiter = pinfo.find(i.first);
assert(pinfoiter != pinfo.end());
if (item->need <= pinfoiter->second.last_update &&
- cmp(hoid, pinfoiter->second.last_backfill, sort_bitwise) <= 0 &&
+ hoid <= pinfoiter->second.last_backfill &&
!i.second.is_missing(hoid))
mliter->second.insert(i.first);
}
void trim_to(const hobject_t &soid) {
trim();
while (!objects.empty() &&
- cmp(objects.begin()->first, soid, sort_bitwise) <= 0) {
+ objects.begin()->first <= soid) {
pop_front();
}
}
// classic (non chunk) scrubs block all writes
// chunky scrubs only block writes to a range
bool write_blocked_by_scrub(const hobject_t &soid, bool sort_bitwise) {
- if (cmp(soid, start, sort_bitwise) >= 0 &&
- cmp(soid, end, sort_bitwise) < 0)
+ if (soid >= start &&
+ soid < end)
return true;
return false;
ldpp_dout(dpp, 20) << __func__ << ": merging hoid " << hoid
<< " entries: " << entries << dendl;
- if (cmp(hoid, info.last_backfill, info.last_backfill_bitwise) > 0) {
+ if (hoid > info.last_backfill) {
ldpp_dout(dpp, 10) << __func__ << ": hoid " << hoid << " after last_backfill"
<< dendl;
return;
ldpp_dout(dpp, 20) << "update missing, append " << *p << dendl;
log->add(*p);
}
- if (cmp(p->soid, last_backfill, last_backfill_bitwise) <= 0 &&
+ if (p->soid <= last_backfill &&
!p->is_error()) {
missing.add_next_event(*p);
if (rollbacker) {
i != log.log.rend();
++i) {
if (!debug_verify_stored_missing && i->version <= info.last_complete) break;
- if (cmp(i->soid, info.last_backfill, info.last_backfill_bitwise) > 0)
+ if (i->soid > info.last_backfill)
continue;
if (i->is_error())
continue;
if (checked.count(i.first))
continue;
if (i.second.need > log.tail ||
- cmp(i.first, info.last_backfill, info.last_backfill_bitwise) > 0) {
+ i.first > info.last_backfill) {
lderr(dpp->get_cct()) << __func__ << ": invalid missing set entry found "
<< i.first
<< dendl;
i != divergent_priors.rend();
++i) {
if (i->first <= info.last_complete) break;
- if (cmp(i->second, info.last_backfill, info.last_backfill_bitwise) > 0)
+ if (i->second > info.last_backfill)
continue;
if (did.count(i->second)) continue;
did.insert(i->second);
// Object is degraded if after last_backfill AND
// we are backfilling it
if (is_backfill_targets(peer) &&
- cmp(peer_info[peer].last_backfill, soid, get_sort_bitwise()) <= 0 &&
- cmp(last_backfill_started, soid, get_sort_bitwise()) >= 0 &&
+ peer_info[peer].last_backfill <= soid &&
+ last_backfill_started >= soid &&
backfills_in_flight.count(soid))
return true;
}
dout(10) << " pgnls lower_bound " << lower_bound
<< " pg_end " << pg_end << dendl;
if (get_sort_bitwise() &&
- ((!lower_bound.is_max() &&
- cmp_bitwise(lower_bound, pg_end) >= 0) ||
- (lower_bound != hobject_t() &&
- cmp_bitwise(lower_bound, pg_start) < 0))) {
+ ((!lower_bound.is_max() && lower_bound >= pg_end) ||
+ (lower_bound != hobject_t() && lower_bound < pg_start))) {
// this should only happen with a buggy client.
dout(10) << "outside of PG bounds " << pg_start << " .. "
<< pg_end << dendl;
++ls_iter;
++missing_iter;
}
- } else if (cmp(mcand, lcand, get_sort_bitwise()) < 0) {
+ } else if (mcand < lcand) {
candidate = mcand;
assert(!mcand.is_max());
++missing_iter;
dout(10) << " pgnls candidate 0x" << std::hex << candidate.get_hash()
<< " vs lower bound 0x" << lower_bound.get_hash() << dendl;
- if (cmp(candidate, next, get_sort_bitwise()) >= 0) {
+ if (candidate >= next) {
break;
}
++ls_iter;
++missing_iter;
}
- } else if (cmp(mcand, lcand, get_sort_bitwise()) < 0) {
+ } else if (mcand < lcand) {
candidate = mcand;
assert(!mcand.is_max());
++missing_iter;
++ls_iter;
}
- if (cmp(candidate, next, get_sort_bitwise()) >= 0) {
+ if (candidate >= next) {
break;
}
session->put(); // get_priv takes a ref, and so does the SessionRef
hobject_t begin = info.pgid.pgid.get_hobj_start();
hobject_t end = info.pgid.pgid.get_hobj_end(pool.info.get_pg_num());
- if (cmp_bitwise(begin, m->begin) < 0) {
+ if (begin < m->begin) {
begin = m->begin;
}
- if (cmp_bitwise(end, m->end) > 0) {
+ if (end > m->end) {
end = m->end;
}
dout(10) << __func__ << " backoff ack id " << m->id
pg_shard_t bt = *i;
map<pg_shard_t, pg_info_t>::const_iterator iter = peer_info.find(bt);
assert(iter != peer_info.end());
- if (cmp(iter->second.last_backfill, e, get_sort_bitwise()) < 0)
+ if (iter->second.last_backfill < e)
e = iter->second.last_backfill;
}
return e;
++i) {
pg_shard_t bt = *i;
pg_info_t& pinfo = peer_info[bt];
- if (cmp(soid, pinfo.last_backfill, get_sort_bitwise()) <= 0)
+ if (soid <= pinfo.last_backfill)
pinfo.stats.stats.add(delta_stats);
- else if (cmp(soid, last_backfill_started, get_sort_bitwise()) <= 0)
+ else if (soid <= last_backfill_started)
pending_backfill_updates[soid].stats.add(delta_stats);
}
if (is_primary() && scrubber.active) {
- if (cmp(soid, scrubber.start, get_sort_bitwise()) < 0) {
+ if (soid < scrubber.start) {
scrub_cstat.add(delta_stats);
}
}
handle.reset_tp_timeout();
const hobject_t soid(p->second);
- if (cmp(soid, pi->second.last_backfill, get_sort_bitwise()) > 0) {
+ if (soid > pi->second.last_backfill) {
if (!recovering.count(soid)) {
derr << __func__ << ": object added to missing set for backfill, but "
<< "is not in recovering, error!" << dendl;
map<pg_shard_t, BackfillInterval>::const_iterator iter =
peer_backfill_info.find(peer);
assert(iter != peer_backfill_info.end());
- if (cmp(iter->second.begin, e, get_sort_bitwise()) < 0)
+ if (iter->second.begin < e)
e = iter->second.begin;
}
return e;
i != backfill_targets.end();
++i) {
peer_backfill_info[*i].trim_to(
- MAX_HOBJ(peer_info[*i].last_backfill, last_backfill_started,
- get_sort_bitwise()));
+ std::max(peer_info[*i].last_backfill, last_backfill_started));
}
backfill_info.trim_to(last_backfill_started);
while (ops < max) {
- if (cmp(backfill_info.begin, earliest_peer_backfill(),
- get_sort_bitwise()) <= 0 &&
+ if (backfill_info.begin <= earliest_peer_backfill() &&
!backfill_info.extends_to_end() && backfill_info.empty()) {
hobject_t next = backfill_info.end;
backfill_info.reset(next, get_sort_bitwise());
BackfillInterval& pbi = peer_backfill_info[bt];
dout(20) << " peer shard " << bt << " backfill " << pbi << dendl;
- if (cmp(pbi.begin, backfill_info.begin, get_sort_bitwise()) <= 0 &&
+ if (pbi.begin <= backfill_info.begin &&
!pbi.extends_to_end() && pbi.empty()) {
dout(10) << " scanning peer osd." << bt << " from " << pbi.end << dendl;
epoch_t e = get_osdmap()->get_epoch();
// the set of targets for which that object applies.
hobject_t check = earliest_peer_backfill();
- if (cmp(check, backfill_info.begin, get_sort_bitwise()) < 0) {
+ if (check < backfill_info.begin) {
set<pg_shard_t> check_targets;
for (set<pg_shard_t>::iterator i = backfill_targets.begin();
// Only include peers that we've caught up to their backfill line
// otherwise, they only appear to be missing this object
// because their pbi.begin > backfill_info.begin.
- if (cmp(backfill_info.begin, pinfo.last_backfill,
- get_sort_bitwise()) > 0)
+ if (backfill_info.begin > pinfo.last_backfill)
missing_targs.push_back(bt);
else
skip_targs.push_back(bt);
}
}
- hobject_t backfill_pos = MIN_HOBJ(backfill_info.begin, earliest_peer_backfill(),
- get_sort_bitwise());
+ hobject_t backfill_pos =
+ std::min(backfill_info.begin, earliest_peer_backfill());
for (set<hobject_t, hobject_t::BitwiseComparator>::iterator i = add_to_stat.begin();
i != add_to_stat.end();
// ordered before any subsequent updates
send_remove_op(to_remove[i].get<0>(), to_remove[i].get<1>(), to_remove[i].get<2>());
- if (cmp(to_remove[i].get<0>(), last_backfill_started,
- get_sort_bitwise()) <= 0)
+ if (to_remove[i].get<0>() <= last_backfill_started)
pending_backfill_updates[to_remove[i].get<0>()]; // add empty stat!
}
for (map<hobject_t, pg_stat_t, hobject_t::Comparator>::iterator i =
pending_backfill_updates.begin();
i != pending_backfill_updates.end() &&
- cmp(i->first, next_backfill_to_complete, get_sort_bitwise()) < 0;
+ i->first < next_backfill_to_complete;
pending_backfill_updates.erase(i++)) {
dout(20) << " pending_backfill_update " << i->first << dendl;
- assert(cmp(i->first, new_last_backfill, get_sort_bitwise()) > 0);
+ assert(i->first > new_last_backfill);
for (set<pg_shard_t>::iterator j = backfill_targets.begin();
j != backfill_targets.end();
++j) {
pg_shard_t bt = *j;
pg_info_t& pinfo = peer_info[bt];
//Add stats to all peers that were missing object
- if (cmp(i->first, pinfo.last_backfill, get_sort_bitwise()) > 0)
+ if (i->first > pinfo.last_backfill)
pinfo.stats.add(i->second);
}
new_last_backfill = i->first;
pg_shard_t bt = *i;
pg_info_t& pinfo = peer_info[bt];
- if (cmp(new_last_backfill, pinfo.last_backfill, get_sort_bitwise()) > 0) {
+ if (new_last_backfill > pinfo.last_backfill) {
pinfo.set_last_backfill(new_last_backfill, get_sort_bitwise());
epoch_t e = get_osdmap()->get_epoch();
MOSDPGBackfill *m = NULL;
dout(10) << __func__ << ": updating from version " << e.version
<< dendl;
const hobject_t &soid = e.soid;
- if (cmp(soid, bi->begin, get_sort_bitwise()) >= 0 &&
- cmp(soid, bi->end, get_sort_bitwise()) < 0) {
+ if (soid >= bi->begin &&
+ soid < bi->end) {
if (e.is_update()) {
dout(10) << __func__ << ": " << e.soid << " updated to version "
<< e.version << dendl;
// See if we've made a full pass over the object hash space
// This might check at most ls_max objects a second time to notice that
// we've checked every objects at least once.
- if (cmp(agent_state->position, agent_state->start, get_sort_bitwise()) < 0 &&
- cmp(next, agent_state->start, get_sort_bitwise()) >= 0) {
+ if (agent_state->position < agent_state->start &&
+ next >= agent_state->start) {
dout(20) << __func__ << " wrap around " << agent_state->start << dendl;
if (total_started == 0)
need_delay = true;
next.second = object_contexts.lookup(begin);
next.first = begin;
bool more = true;
- while (more && cmp(next.first, end, get_sort_bitwise()) < 0) {
+ while (more && next.first < end) {
if (next.second && next.second->is_blocked()) {
next.second->requeue_scrub_on_unblock = true;
dout(10) << __func__ << ": scrub delayed, "
assert(peer_info.count(peer));
bool should_send =
hoid.pool != (int64_t)info.pgid.pool() ||
- cmp(hoid, last_backfill_started, get_sort_bitwise()) <= 0 ||
- cmp(hoid, peer_info[peer].last_backfill, get_sort_bitwise()) <= 0;
+ hoid <= last_backfill_started ||
+ hoid <= peer_info[peer].last_backfill;
if (!should_send)
assert(is_backfill_targets(peer));
return should_send;
c.snap = snapset.clones[j];
prev.intersection_of(snapset.clone_overlap[snapset.clones[j]]);
if (!missing.is_missing(c) &&
- cmp(c, last_backfill, get_parent()->sort_bitwise()) < 0 &&
+ c < last_backfill &&
get_parent()->try_lock_for_read(c, manager)) {
dout(10) << "calc_head_subsets " << head << " has prev " << c
<< " overlap " << prev << dendl;
c.snap = snapset.clones[j];
prev.intersection_of(snapset.clone_overlap[snapset.clones[j]]);
if (!missing.is_missing(c) &&
- cmp(c, last_backfill, get_parent()->sort_bitwise()) < 0 &&
+ c < last_backfill &&
get_parent()->try_lock_for_read(c, manager)) {
dout(10) << "calc_clone_subsets " << soid << " has prev " << c
<< " overlap " << prev << dendl;
c.snap = snapset.clones[j];
next.intersection_of(snapset.clone_overlap[snapset.clones[j-1]]);
if (!missing.is_missing(c) &&
- cmp(c, last_backfill, get_parent()->sort_bitwise()) < 0 &&
+ c < last_backfill &&
get_parent()->try_lock_for_read(c, manager)) {
dout(10) << "calc_clone_subsets " << soid << " has next " << c
<< " overlap " << next << dendl;
auto p = backoffs.lower_bound(begin);
while (p != backoffs.end()) {
// note: must still examine begin=end=p->first case
- int r = cmp_bitwise(p->first, end);
- if (r > 0 || (r == 0 && cmp_bitwise(begin, end) < 0)) {
+ int r = cmp(p->first, end);
+ if (r > 0 || (r == 0 && begin < end)) {
break;
}
auto q = p->second.begin();
assert(backoff_count == (int)backoffs.size());
auto p = backoffs.lower_bound(oid);
if (p != backoffs.begin() &&
- cmp_bitwise(p->first, oid) > 0) {
+ p->first > oid) {
--p;
}
if (p != backoffs.end()) {
- int r = cmp_bitwise(oid, p->first);
+ int r = cmp(oid, p->first);
if (r == 0 || r > 0) {
for (auto& q : p->second) {
- if (r == 0 || cmp_bitwise(oid, q->end) < 0) {
+ if (r == 0 || oid < q->end) {
return &(*q);
}
}
auto q = op->session->backoffs.lower_bound(hoid);
if (q != op->session->backoffs.begin()) {
--q;
- if (cmp_bitwise(hoid, q->second.end) >= 0) {
+ if (hoid >= q->second.end) {
++q;
}
}
if (q != op->session->backoffs.end()) {
ldout(cct, 20) << __func__ << " ? " << q->first << " [" << q->second.begin
<< "," << q->second.end << ")" << dendl;
- int r = cmp_bitwise(hoid, q->second.begin);
- if (r == 0 || (r > 0 && cmp_bitwise(hoid, q->second.end) < 0)) {
+ int r = cmp(hoid, q->second.begin);
+ if (r == 0 || (r > 0 && hoid < q->second.end)) {
ldout(cct, 10) << __func__ << " backoff on " << hoid << ", queuing "
<< op << " tid " << op->tid << dendl;
return;
{
assert(result);
- if (!end.is_max() && cmp_bitwise(start, end) > 0) {
+ if (!end.is_max() && start > end) {
lderr(cct) << __func__ << ": start " << start << " > end " << end << dendl;
on_finish->complete(-EINVAL);
return;
ldout(cct, 20) << __func__ << ": response.entries.size "
<< response.entries.size() << ", response.entries "
<< response.entries << dendl;
- if (cmp_bitwise(response.handle, end) <= 0) {
+ if (response.handle <= end) {
*next = response.handle;
} else {
ldout(cct, 10) << __func__ << ": adjusted next down to end " << end
hash,
pool_id,
response.entries.back().nspace);
- if (cmp_bitwise(last, end) < 0)
+ if (last < end)
break;
ldout(cct, 20) << __func__ << " dropping item " << last
<< " >= end " << end << dendl;
bool contained_by(const hobject_t& begin, const hobject_t& end) {
hobject_t h = get_hobj();
- int r = cmp_bitwise(h, begin);
- return r == 0 || (r > 0 && cmp_bitwise(h, end) < 0);
+ int r = cmp(h, begin);
+ return r == 0 || (r > 0 && h < end);
}
void dump(Formatter *f) const;
for (vector<ghobject_t>::const_iterator i = in.begin();
i != in.end();
++i) {
- if (cmp(start, *i, true) > 0) {
+ if (start > *i) {
cout << start << " should follow " << *i << std::endl;
return false;
}
ASSERT_EQ(a, b);
b.oid.name = "b";
ASSERT_NE(a, b);
- ASSERT_TRUE(cmp_bitwise(a, b) < 0);
+ ASSERT_TRUE(a < b);
a.pool = 1;
b.pool = 2;
- ASSERT_TRUE(cmp_bitwise(a, b) < 0);
+ ASSERT_TRUE(a < b);
a.pool = 3;
- ASSERT_TRUE(cmp_bitwise(a, b) > 0);
+ ASSERT_TRUE(a > b);
}
{
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_TRUE(cmp_bitwise(a, b) < 0);
+ ASSERT_TRUE(a < b);
a.hobj.pool = -3;
- ASSERT_TRUE(cmp_bitwise(a, b) < 0);
+ ASSERT_TRUE(a < b);
a.hobj.pool = 1;
b.hobj.pool = -3;
- ASSERT_TRUE(cmp_bitwise(a, b) > 0);
+ ASSERT_TRUE(a > b);
}
}
list<hobject_t> remove_snap;
info.last_backfill = hobject_t();
- info.last_backfill.set_hash(1);
+ info.last_backfill.set_hash(100);
oe.soid.set_hash(2);
+ ASSERT_GT(oe.soid, info.last_backfill);
EXPECT_FALSE(is_dirty());
EXPECT_TRUE(remove_snap.empty());
sep.set_shard(shard_id_t(1));
sep.hobj.pool = -1;
cout << min << " < " << sep << std::endl;
- ASSERT_TRUE(cmp_bitwise(min, sep) < 0);
+ ASSERT_TRUE(min < sep);
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_TRUE(cmp_bitwise(o, sep) > 0);
+ ASSERT_TRUE(o > sep);
}
TEST(ghobject_t, parse) {