]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/hobject: remove cmp_* comparators; add normal operators
authorSage Weil <sage@redhat.com>
Fri, 10 Feb 2017 23:39:53 +0000 (18:39 -0500)
committerSage Weil <sage@redhat.com>
Sat, 11 Feb 2017 15:45:16 +0000 (10:45 -0500)
Fix up callers.

Signed-off-by: Sage Weil <sage@redhat.com>
24 files changed:
src/common/hobject.cc
src/common/hobject.h
src/librados/librados.cc
src/os/filestore/DBObjectMap.cc
src/os/filestore/FileStore.cc
src/os/filestore/HashIndex.cc
src/os/filestore/HashIndex.h
src/os/memstore/MemStore.cc
src/osd/ECBackend.cc
src/osd/ExtentCache.h
src/osd/OSD.cc
src/osd/PG.cc
src/osd/PG.h
src/osd/PGLog.h
src/osd/PrimaryLogPG.cc
src/osd/PrimaryLogPG.h
src/osd/ReplicatedBackend.cc
src/osd/Session.cc
src/osd/Session.h
src/osdc/Objecter.cc
src/osdc/Objecter.h
src/test/objectstore/store_test.cc
src/test/osd/TestPGLog.cc
src/test/osd/types.cc

index 14acd4ba24f55a0528a8c09f57aae55a6734e0ca..a965c87d62241894bf627a2cec695c5273af46d7 100644 (file)
@@ -319,40 +319,7 @@ bool hobject_t::parse(const string &s)
   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;
@@ -606,27 +573,7 @@ bool ghobject_t::parse(const string& s)
   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;
@@ -636,7 +583,7 @@ int cmp_bitwise(const ghobject_t& l, const ghobject_t& r)
     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)
index 14a9ffc7c95d8dd8fba215bf5e34ced3d751c553..3b7f3b8ef02ee0d04540fc78c24b54be43d8d9f4 100644 (file)
@@ -289,21 +289,32 @@ public:
   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;
     }
   };
 
@@ -311,20 +322,14 @@ public:
     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>
@@ -373,62 +378,20 @@ inline bool operator!=(const T&, const hobject_t &rhs) {
   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 {
@@ -530,20 +493,31 @@ public:
   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;
     }
   };
 
@@ -551,10 +525,7 @@ public:
     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;
     }
   };
 };
@@ -573,31 +544,7 @@ ostream& operator<<(ostream& out, const ghobject_t& o);
 
 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
index 7b9816b4efa4917069df598b966c5f5fba1feabf..335fa4cd1b4adb26a7966bed862b526e6dd78e97 100644 (file)
@@ -4205,7 +4205,7 @@ extern "C" int rados_object_list_cursor_cmp(
 {
   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,
@@ -6073,7 +6073,7 @@ bool librados::ObjectCursor::operator<(const librados::ObjectCursor &rhs)
 {
   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)
index c17395c5a25ac7f4ed5e32832a0575e201f52437..73c113dc5de63e6912ee6d12f02367235ce6b02f 100644 (file)
@@ -889,10 +889,10 @@ int DBObjectMap::clone(const ghobject_t &oid,
   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 {
index 6c1c4c67419e1975260c6811dbfedd6e07464717..5e079f502debebf932df6734a35e8d7f2b332c5a 100644 (file)
@@ -4801,7 +4801,7 @@ int FileStore::collection_list(const coll_t& c,
   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);
index 6bbb6330333e5def90081af73ca39478fb777732..5026ed3934447c5adb42b8107596f683eb4f8c33 100644 (file)
@@ -903,7 +903,7 @@ int HashIndex::get_path_contents_by_hash_bitwise(
   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);
@@ -1004,12 +1004,12 @@ int HashIndex::list_by_hash_bitwise(
            *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);
        }
index add3c3559fcfd64258942a73e5a89bc321255909..4ffde1d34ae972d4ee143563cba94cc41f1fe07d 100644 (file)
@@ -359,20 +359,6 @@ private:
     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)
@@ -381,7 +367,7 @@ private:
        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;
     }
index 73ed1f720edd62436cb48668a907582c8b613663..d27557b87276192641ab4fa31c10abf0903aaa33 100644 (file)
@@ -476,7 +476,7 @@ int MemStore::collection_list(const coll_t& cid,
   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;
   }
index ddf238c83e02342c1dd11e8e9e11f0b689824c16..faecd1c3aa6fdad7fc2d5437ae1e387d68636b9d 100644 (file)
@@ -1475,7 +1475,7 @@ int ECBackend::get_min_avail_to_read_shards(
       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));
index 07a7feab568845be6fb340fefa8ffa127ba1ac3a..4354ba6c7e6960163f9f50bb94dbc882364a9ba6 100644 (file)
@@ -182,7 +182,7 @@ private:
     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 {
@@ -330,10 +330,10 @@ private:
   };
   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;
     }
   };
 
index 26df67911b8ffbd54d4a74f7cf6157b06a7969a0..5ac536a7e4dd1358c576880933c5628e38ed8558 100644 (file)
@@ -8903,7 +8903,7 @@ void OSD::handle_backoff(OpRequestRef& op, OSDMapRef& osdmap)
     // 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>
index e0000c30abd10c890c15889ed2bc65fd881ffba3..0b1b62528a97fffcf95f9ce8129c01eba0fd6b89 100644 (file)
@@ -567,7 +567,7 @@ bool PG::MissingLoc::add_source_info(
                         << 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
@@ -1742,7 +1742,7 @@ void PG::activate(ObjectStore::Transaction& t,
         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);
       }
       
@@ -2366,11 +2366,11 @@ void PG::release_backoffs(const hobject_t& begin, const hobject_t& end)
     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
@@ -2378,9 +2378,8 @@ void PG::release_backoffs(const hobject_t& begin, const hobject_t& end)
       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 {
@@ -3264,7 +3263,7 @@ void PG::append_log(
      * 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);
     }
   }
@@ -4431,8 +4430,8 @@ void PG::chunky_scrub(ThreadPool::TPHandle &handle)
        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;
          }
@@ -4442,8 +4441,8 @@ void PG::chunky_scrub(ThreadPool::TPHandle &handle)
                 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;
            }
index 07a674df79b4e388346144163597897634fec5a6..0daf3b8b74d1a3d9c5ec1ad253923983cf9290dd 100644 (file)
@@ -488,7 +488,7 @@ public:
        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);
       }
@@ -768,7 +768,7 @@ public:
     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();
       }
     }
@@ -1209,8 +1209,8 @@ public:
     // 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;
index 713d3d8ce356277955096454b6886388e7ec369e..022f0c156c23843da478ddc0476c9bc856e53abb 100644 (file)
@@ -753,7 +753,7 @@ protected:
     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;
@@ -1002,7 +1002,7 @@ public:
        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) {
@@ -1192,7 +1192,7 @@ public:
             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;
@@ -1240,7 +1240,7 @@ public:
            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;
@@ -1266,7 +1266,7 @@ public:
               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);
index 35a8c1997424da343272e31e715ba3f42c6bd5e9..2bc34cf9bc3eef3021016480aef2a6830579b386 100644 (file)
@@ -593,8 +593,8 @@ bool PrimaryLogPG::is_degraded_or_backfilling_object(const hobject_t& soid)
     // 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;
   }
@@ -1109,10 +1109,8 @@ void PrimaryLogPG::do_pg_op(OpRequestRef op)
         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;
@@ -1159,7 +1157,7 @@ void PrimaryLogPG::do_pg_op(OpRequestRef op)
              ++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;
@@ -1172,7 +1170,7 @@ void PrimaryLogPG::do_pg_op(OpRequestRef op)
           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;
          }
 
@@ -1346,7 +1344,7 @@ void PrimaryLogPG::do_pg_op(OpRequestRef op)
              ++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;
@@ -1356,7 +1354,7 @@ void PrimaryLogPG::do_pg_op(OpRequestRef op)
            ++ls_iter;
          }
 
-         if (cmp(candidate, next, get_sort_bitwise()) >= 0) {
+         if (candidate >= next) {
            break;
          }
            
@@ -1609,10 +1607,10 @@ void PrimaryLogPG::handle_backoff(OpRequestRef& op)
   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
@@ -1763,7 +1761,7 @@ hobject_t PrimaryLogPG::earliest_backfill() const
     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;
@@ -6896,14 +6894,14 @@ void PrimaryLogPG::apply_stats(
        ++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);
     }
   }
@@ -10770,7 +10768,7 @@ uint64_t PrimaryLogPG::recover_replicas(uint64_t max, ThreadPool::TPHandle &hand
       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;
@@ -10827,7 +10825,7 @@ hobject_t PrimaryLogPG::earliest_peer_backfill() const
     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;
@@ -10953,14 +10951,12 @@ uint64_t PrimaryLogPG::recover_backfill(
        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());
@@ -10979,7 +10975,7 @@ uint64_t PrimaryLogPG::recover_backfill(
       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();
@@ -11010,7 +11006,7 @@ uint64_t PrimaryLogPG::recover_backfill(
     // 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();
@@ -11107,8 +11103,7 @@ uint64_t PrimaryLogPG::recover_backfill(
           // 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);
@@ -11172,8 +11167,8 @@ uint64_t PrimaryLogPG::recover_backfill(
     }
   }
 
-  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();
@@ -11190,8 +11185,7 @@ uint64_t PrimaryLogPG::recover_backfill(
     // 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!
   }
 
@@ -11217,17 +11211,17 @@ uint64_t PrimaryLogPG::recover_backfill(
   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;
@@ -11253,7 +11247,7 @@ uint64_t PrimaryLogPG::recover_backfill(
     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;
@@ -11365,8 +11359,8 @@ void PrimaryLogPG::update_range(
       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;
@@ -12010,8 +12004,8 @@ bool PrimaryLogPG::agent_work(int start_max, int agent_flush_quota)
   // 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;
@@ -12603,7 +12597,7 @@ bool PrimaryLogPG::_range_available_for_scrub(
   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, "
index a0b0ec3d013503672aa99f31c4a90557dfb03c92..6863a556df81dd58548c6e5b4b1494744cdae96a 100644 (file)
@@ -395,8 +395,8 @@ public:
     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;
index 51b50e10b6646a04c9b40f6fb609632dd124f8d0..976aa7f91178ec7084c09cb80b82933033d8e091 100644 (file)
@@ -1292,7 +1292,7 @@ void ReplicatedBackend::calc_head_subsets(
     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;
@@ -1360,7 +1360,7 @@ void ReplicatedBackend::calc_clone_subsets(
     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;
@@ -1381,7 +1381,7 @@ void ReplicatedBackend::calc_clone_subsets(
     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;
index 8f93ea95ae96731d07e36bfd72016b100a0bbcdb..39591fa89700f293299fab62704c1f8bc3f7c983 100644 (file)
@@ -47,8 +47,8 @@ void Session::ack_backoff(
   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();
index 63a73c30073e6b8acf7da4bb6dbc188f562676cd..c6c80011599cdde2c1f5235dfe57780f262aa400 100644 (file)
@@ -169,14 +169,14 @@ struct Session : public RefCountedObject {
       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);
            }
          }
index f592811b6fcc23cc0a97e19bf031411bed668567..c38a363c35e28f9772eb004ece65ebf661960fd7 100644 (file)
@@ -3075,15 +3075,15 @@ void Objecter::_send_op(Op *op, MOSDOp *m)
   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;
@@ -5012,7 +5012,7 @@ void Objecter::enumerate_objects(
 {
   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;
@@ -5103,7 +5103,7 @@ void Objecter::_enumerate_reply(
   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
@@ -5131,7 +5131,7 @@ void Objecter::_enumerate_reply(
                     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;
index 8682a61d7ad41a6489fdb57a2346178b5b5cbf77..95d665a7a2d3260f9012813c35f0dc30628096b7 100644 (file)
@@ -1236,8 +1236,8 @@ public:
 
     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;
index 4035b6d411c2b8acfbe5aac312bfe9b456b35b84..dbfd4f98830b40b76503ab9db71dd2631132da78 100644 (file)
@@ -91,7 +91,7 @@ bool sorted(const vector<ghobject_t> &in) {
   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;
     }
@@ -2329,24 +2329,24 @@ TEST_P(StoreTest, Sort) {
     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);
   }
 }
 
index e00449ca860e0b9049159bcbab7de51e63d16787..f1b12629c6157048fed192ceaabace571f80a465 100644 (file)
@@ -490,8 +490,9 @@ TEST_F(PGLogTest, merge_old_entry) {
     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());
index 419c637177bc3540c747c158d5e8e34db22873ab..d1d600789d8854a5c792536b661dff8f4ca15029 100644 (file)
@@ -1442,14 +1442,14 @@ TEST(ghobject_t, cmp) {
   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) {