]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
include/small_encoding: fix lba encoding with many low zeros 9868/head
authorSage Weil <sage@redhat.com>
Wed, 22 Jun 2016 14:28:28 +0000 (10:28 -0400)
committerSage Weil <sage@redhat.com>
Wed, 22 Jun 2016 14:28:51 +0000 (10:28 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/include/small_encoding.h
src/test/encoding.cc

index 5efca0cfb2bf819b98e2c74186e945618287ba07..e07afaf381e0c428f9ccdecc754db2d0ba329897 100644 (file)
@@ -183,6 +183,7 @@ inline void small_encode_lba(uint64_t v, bufferlist& bl) {
     pos = t + 1;
     word = (1 << t) - 1;
   } else {
+    v >>= 20;
     pos = 3;
     word = 0x3;
   }
index 5469c42109ac714766dea07c4e3e37aacc922638..b9b13f73d9dc59b3d8cbed8f6a390c38476a4451 100644 (file)
@@ -320,6 +320,7 @@ TEST(small_encoding, varint_lowz) {
     {0x7f0000, 2, 2, 2},
     {0xffff0000, 4, 4, 4},
     {0xffffffff, 5, 5, 5},
+    {0x41000000, 3, 4, 4},
     {0, 0, 0, 0}
   };
   for (unsigned i=0; v[i][1]; ++i) {
@@ -382,6 +383,7 @@ TEST(small_encoding, lba) {
     {0x3fffffff0000, 5},
     {0xfffffff00000, 4},
     {0x1fffffff00000, 5},
+    {0x41000000, 4},
     {0, 0}
   };
   for (unsigned i=0; v[i][1]; ++i) {