]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: only direct write into unused blob space
authorSage Weil <sage@redhat.com>
Thu, 19 May 2016 12:47:44 +0000 (08:47 -0400)
committerSage Weil <sage@redhat.com>
Wed, 1 Jun 2016 15:38:52 +0000 (11:38 -0400)
We can only do a direct write into an already-allocated blob once, if that
range hasn't yet been used.  Once it has been used, it is much to complex
to keep track of when all references to it have committed to disk before
reusing it, so we don't try to handle that case at all.

Since the range has never been used, we can assert that there are no
references to it.

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

index b246156178d53ea09748ba740ad1ba0ff876f044..382d3c4dcafcbd1ed1190467420f213b0f79d569 100644 (file)
@@ -5427,14 +5427,14 @@ void BlueStore::_do_write_small(
     uint64_t b_off = offset - head_pad - bstart;
     uint64_t b_len = length + head_pad + tail_pad;
     if (b->get_ondisk_length() >= b_off + b_len &&
-       b->is_unreferenced(b_off, b_len) &&
+       b->is_unused(b_off, b_len) &&
        (!b->has_csum_data() || (b_off % b->get_csum_block_size() == 0 &&
                                 b_len % b->get_csum_block_size() == 0))) {
-#warning this is currently racy; we may be pipelined with an op that derefs this range.  once we have a buffer cache the problem will go away.
-      dout(20) << __func__ << "  write to unreferenced 0x" << std::hex
+      dout(20) << __func__ << "  write to unused 0x" << std::hex
               << b_off << "~0x" << b_len
               << " pad 0x" << head_pad << " + 0x" << tail_pad
               << std::dec << " of mutable " << blob << ": " << b << dendl;
+      assert(b->is_unreferenced(b_off, b_len));
       b->map_bl(b_off, padded,
                [&](uint64_t offset, uint64_t length, bufferlist& t) {
                  bdev->aio_write(offset, t,