]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: make frag string rendering simpler
authorSage Weil <sage.weil@dreamhost.com>
Wed, 23 Feb 2011 21:36:17 +0000 (13:36 -0800)
committerSage Weil <sage.weil@dreamhost.com>
Wed, 23 Feb 2011 21:36:17 +0000 (13:36 -0800)
Show actual bit prefix when rendering a frag_t.  That is,

$value/$numbits -> bits*

So,

0/0      -> *
000000/1 -> 0*
800000/1 -> 1*
800000/3 -> 100*

etc.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/include/frag.h

index 866c60b4d4cc7c0e579486fd168f29d3947ce710..2f9839b14270df59b4edeb103872f9ed4b88ca1a 100644 (file)
@@ -149,7 +149,17 @@ class frag_t {
 
 inline std::ostream& operator<<(std::ostream& out, frag_t hb)
 {
-  return out << std::hex << hb.value() << std::dec << "/" << hb.bits();
+  //return out << std::hex << hb.value() << std::dec << "/" << hb.bits();
+  unsigned num = hb.bits();
+  if (num) {
+    unsigned val = hb.value();
+    unsigned bit = 1 << hb.mask_shift();
+    while (num--) {
+      out << ((val & bit) ? '1':'0');
+      bit--;       
+    }
+  }
+  return out << '*';
 }
 
 inline void encode(frag_t f, bufferlist& bl) { encode_raw(f._enc, bl); }