From: Sage Weil Date: Thu, 28 Jan 2016 02:45:27 +0000 (-0500) Subject: os/bluestore/BlueStore: fix wal tail block padding X-Git-Tag: v10.0.4~35^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f1bf983e43c0d24151fe9b75b091b7144d15f9f5;p=ceph.git os/bluestore/BlueStore: fix wal tail block padding If the wal write starts partway into the tail block, we need to allocate less than a full block. Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index e28e46a04cd9..6574d4e67340 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -4911,9 +4911,17 @@ void BlueStore::_pad_zeros_tail( uint64_t end = offset + *length; unsigned back_copy = end % block_size; assert(back_copy); // or we wouldn't have been called - uint64_t back_pad = block_size - back_copy; - assert(back_copy <= *length); - bufferptr tail(block_size); + uint64_t tail_len; + if (back_copy <= *length) { + // we start at or before the block boundary + tail_len = block_size; + } else { + // we start partway into the tail block + back_copy = *length; + tail_len = block_size - (offset % block_size); + } + uint64_t back_pad = tail_len - back_copy; + bufferptr tail(tail_len); memcpy(tail.c_str(), bl->get_contiguous(*length - back_copy, back_copy), back_copy); memset(tail.c_str() + back_copy, 0, back_pad);