]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BlueStore: fix wal tail block padding
authorSage Weil <sage@redhat.com>
Thu, 28 Jan 2016 02:45:27 +0000 (21:45 -0500)
committerSage Weil <sage@redhat.com>
Wed, 3 Feb 2016 20:16:24 +0000 (15:16 -0500)
If the wal write starts partway into the tail block, we need to allocate
less than a full block.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc

index e28e46a04cd9cc7e60f83d558cccf705d088a7f1..6574d4e673407bd6fb401fbaa3fb33a52f7b5fb8 100644 (file)
@@ -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);