private:
string key;
+ class hobject_t_max {};
+
public:
const string &get_key() const {
return key;
build_hash_cache();
}
+ hobject_t(const hobject_t &rhs) = default;
+ hobject_t(hobject_t &&rhs) = default;
+ hobject_t(hobject_t_max &&singleon) : hobject_t() {
+ max = true;
+ }
+ hobject_t &operator=(const hobject_t &rhs) = default;
+ hobject_t &operator=(hobject_t &&rhs) = default;
+ hobject_t &operator=(hobject_t_max &&singleton) {
+ *this = hobject_t();
+ max = true;
+ return *this;
+ }
+
+ // maximum sorted value.
+ static hobject_t_max get_max() {
+ return hobject_t_max();
+ }
+
hobject_t(object_t oid, const string& key, snapid_t snap, uint32_t hash,
int64_t pool, string nspace)
: oid(oid), snap(snap), hash(hash), max(false),
set_hash(std::hash<sobject_t>()(o));
}
- // maximum sorted value.
- static hobject_t get_max() {
- hobject_t h;
- h.max = true;
- return h;
- }
bool is_max() const {
return max;
}
WRITE_EQ_OPERATORS_7(hobject_t, hash, oid, get_key(), snap, pool, max, nspace)
+template <typename T>
+struct always_false {
+ using value = std::false_type;
+};
+
+template <typename T>
+inline bool operator==(const hobject_t &lhs, const T&) {
+ static_assert(always_false<T>::value::value, "Do not compare to get_max()");
+ return lhs.is_max();
+}
+template <typename T>
+inline bool operator==(const T&, const hobject_t &rhs) {
+ static_assert(always_false<T>::value::value, "Do not compare to get_max()");
+ return rhs.is_max();
+}
+template <typename T>
+inline bool operator!=(const hobject_t &lhs, const T&) {
+ static_assert(always_false<T>::value::value, "Do not compare to get_max()");
+ return !lhs.is_max();
+}
+template <typename T>
+inline bool operator!=(const T&, const hobject_t &rhs) {
+ static_assert(always_false<T>::value::value, "Do not compare to get_max()");
+ 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) {
else
return cmp_nibblewise(l, r);
}
+template <typename T>
+static inline int cmp(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(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_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) {
<< dendl;
continue;
}
- if (oinfo.last_backfill != hobject_t::get_max() &&
+ if (!oinfo.last_backfill.is_max() &&
oinfo.last_backfill_bitwise != sort_bitwise) {
dout(10) << "search_for_missing " << soid << " " << need
<< " also missing on osd." << fromosd
} else {
assert(peer_missing.count(*i));
missing_loc.add_active_missing(peer_missing[*i]);
- if (!peer_missing[*i].have_missing() && peer_info[*i].last_backfill == hobject_t::get_max())
+ if (!peer_missing[*i].have_missing() && peer_info[*i].last_backfill.is_max())
complete_shards.insert(*i);
}
}
break;
}
- if (cmp(scrubber.end, hobject_t::get_max(), get_sort_bitwise()) < 0) {
+ if (!(scrubber.end.is_max())) {
scrubber.state = PG::Scrubber::NEW_CHUNK;
requeue_scrub();
done = true;