From: Sage Weil Date: Mon, 17 Aug 2015 15:52:10 +0000 (-0400) Subject: osd/osd_types: add pg_t::get_hobj_{start,end} methods X-Git-Tag: v10.0.3~215^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fc8ea3f2d6e56da6ca0bed1774a65fe70a065e36;p=ceph.git osd/osd_types: add pg_t::get_hobj_{start,end} methods 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 --- diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 464cb197cb0..b60ff931277 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -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); diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 9810e6b76dc..836f9914486 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -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);