include/small_encoding: fix lba encoding with many low zeros

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2016-06-22 10:28:28 -04:00
parent 6dd0a8dcd9
commit 3c8c882c31
2 changed files with 3 additions and 0 deletions

View 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;
}

View 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) {