]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/osd_types: add pg_t::get_hobj_{start,end} methods
authorSage Weil <sage@redhat.com>
Mon, 17 Aug 2015 15:52:10 +0000 (11:52 -0400)
committerJohn Spray <john.spray@redhat.com>
Thu, 3 Dec 2015 14:57:38 +0000 (14:57 +0000)
Convenience methods to easily get the bounds of the object range
that are managed by a given PG.  Note that this is a function of
the pool pg_num because otherwise the pg_t id only gives us the
start position.

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/osd_types.cc
src/osd/osd_types.h

index 464cb197cb02f922b0921e03ff08f06e1b9ff52b..b60ff931277270d13720bb0212161637321bc4d3 100644 (file)
@@ -522,6 +522,30 @@ pg_t pg_t::get_parent() const
   return retval;
 }
 
+hobject_t pg_t::get_hobj_start() const
+{
+  return hobject_t(object_t(), string(), CEPH_NOSNAP, m_seed, m_pool,
+                  string());
+}
+
+hobject_t pg_t::get_hobj_end(unsigned pg_num) const
+{
+  // note: this assumes a bitwise sort; with the legacy nibblewise
+  // sort a PG did not always cover a single contiguous range of the
+  // (bit-reversed) hash range.
+  unsigned bits = get_split_bits(pg_num);
+  uint64_t rev_start = hobject_t::_reverse_bits(m_seed);
+  uint64_t rev_end = (rev_start | (0xffffffff >> bits)) + 1;
+  if (rev_end >= 0x100000000) {
+    assert(rev_end == 0x100000000);
+    return hobject_t::get_max();
+  } else {
+    return hobject_t(object_t(), string(), CEPH_NOSNAP,
+                  hobject_t::_reverse_bits(rev_end), m_pool,
+                  string());
+  }
+}
+
 void pg_t::dump(Formatter *f) const
 {
   f->dump_unsigned("pool", m_pool);
index 9810e6b76dc4962de5e184cfb1994506de23aca3..836f99144862e8aa3376f99f649435a5a8cdd390 100644 (file)
@@ -348,6 +348,9 @@ struct pg_t {
     return oid.match(bits, ps());
   }
 
+  hobject_t get_hobj_start() const;
+  hobject_t get_hobj_end(unsigned pg_num) const;
+
   void encode(bufferlist& bl) const {
     __u8 v = 1;
     ::encode(v, bl);