]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: drop COW_HEAD extent flag
authorSage Weil <sage@redhat.com>
Wed, 4 May 2016 18:04:40 +0000 (14:04 -0400)
committerSage Weil <sage@redhat.com>
Wed, 4 May 2016 18:04:40 +0000 (14:04 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/os/bluestore/bluestore_types.cc
src/os/bluestore/bluestore_types.h

index 206c24eb591c774f2b6c817efd44ddf42f8e0d45..54258088b51e08895d9922b65204c0fa040a4d90 100644 (file)
@@ -5012,6 +5012,8 @@ int BlueStore::_do_allocate(
   bool allow_overlay,
   uint64_t *alloc_offset,
   uint64_t *alloc_length,
+  uint64_t *cow_head_extent,
+  uint64_t *cow_tail_extent,
   uint64_t *cow_rmw_head,
   uint64_t *cow_rmw_tail)
 {
@@ -5262,9 +5264,9 @@ int BlueStore::_do_allocate(
       assert(r == 0);
       assert(e.length <= length);  // bc length is a multiple of min_alloc_size
       if (offset == alloc_start && cow_head_op) {
-        // we set the COW flag to indicate that all or part of this new extent
-        // will be copied from the previous allocation.
-        e.flags |= bluestore_extent_t::FLAG_COW_HEAD;
+        // we set cow_head_extent to indicate that all or part of this
+        // new extent will be copied from the previous allocation.
+       *cow_head_extent = e.offset;
         cow_head_op->extent.offset = e.offset;
         dout(10) << __func__ << "  final head cow op extent "
                  << cow_head_op->extent << dendl;
@@ -5333,6 +5335,8 @@ int BlueStore::_do_write(
   map<uint64_t, bluestore_extent_t>::iterator bp;
   uint64_t length;
   uint64_t alloc_offset = 0, alloc_length = 0;
+  uint64_t cow_head_extent = 0;
+  uint64_t cow_tail_extent = 0;
   uint64_t cow_rmw_head = 0;
   uint64_t cow_rmw_tail = 0;
 
@@ -5343,6 +5347,7 @@ int BlueStore::_do_write(
 
   r = _do_allocate(txc, c, o, orig_offset, orig_length, fadvise_flags, true,
                   &alloc_offset, &alloc_length,
+                  &cow_head_extent, &cow_tail_extent,
                   &cow_rmw_head, &cow_rmw_tail);
   if (r < 0) {
     derr << __func__ << " allocate failed, " << cpp_strerror(r) << dendl;
@@ -5403,7 +5408,7 @@ int BlueStore::_do_write(
       uint64_t x_off = offset - bp->first;
       if (bp->first >= alloc_offset &&
          bp->first + bp->second.length <= alloc_offset + alloc_length &&
-         !bp->second.has_flag(bluestore_extent_t::FLAG_COW_HEAD)) {
+         cow_head_extent != bp->second.offset) {
        if (x_off > 0) {
          // extent is unwritten; zero up until x_off
          dout(20) << __func__ << " zero " << bp->second.offset << "~" << x_off
@@ -5420,7 +5425,6 @@ int BlueStore::_do_write(
                   << " x_off " << zx_off << dendl;
          bdev->aio_zero(bp->second.offset + zx_off, z_len, &txc->ioc);
        }
-       bp->second.clear_flag(bluestore_extent_t::FLAG_COW_HEAD);
       }
       dout(20) << __func__ << " write " << offset << "~" << length
               << " x_off " << x_off << dendl;
@@ -5465,9 +5469,8 @@ int BlueStore::_do_write(
       assert(offset == tail_start);
       assert((bp->first + bp->second.length <= alloc_offset ||
              bp->first >= alloc_offset + alloc_length) ||
-            bp->second.has_flag(bluestore_extent_t::FLAG_COW_HEAD) ||
+            cow_head_extent == bp->second.offset ||
             offset == bp->first);
-      bp->second.clear_flag(bluestore_extent_t::FLAG_COW_HEAD);
       _pad_zeros(txc, o, &bl, &offset, &length, block_size);
       uint64_t x_off = offset - bp->first;
       dout(20) << __func__ << " write " << offset << "~" << length
@@ -5495,7 +5498,7 @@ int BlueStore::_do_write(
       // prior extent wasn't allocated but we are still doing some COW.
       uint64_t z_end = offset & block_mask;
       if (z_end > bp->first &&
-         !bp->second.has_flag(bluestore_extent_t::FLAG_COW_HEAD)) {
+         cow_head_extent != bp->second.offset) {
        uint64_t z_len = z_end - bp->first;
        dout(20) << __func__ << " zero " << bp->first << "~" << z_len << dendl;
        bdev->aio_zero(bp->second.offset, z_len, &txc->ioc);
@@ -5522,7 +5525,6 @@ int BlueStore::_do_write(
                 << " x_off " << x_off << dendl;
        _do_overlay_trim(txc, o, offset, length);
        bdev->aio_write(bp->second.offset + x_off, bl, &txc->ioc, buffered);
-       bp->second.clear_flag(bluestore_extent_t::FLAG_COW_HEAD);
        bp->second.clear_flag(bluestore_extent_t::FLAG_COW_TAIL);
        ++bp;
        continue;
@@ -5564,7 +5566,6 @@ int BlueStore::_do_write(
       dout(20) << __func__ << " past eof, padding out tail block" << dendl;
       _pad_zeros_tail(txc, o, &bl, offset, &length, block_size);
     }
-    bp->second.clear_flag(bluestore_extent_t::FLAG_COW_HEAD);
     bp->second.clear_flag(bluestore_extent_t::FLAG_COW_TAIL);
     op->extent.offset = bp->second.offset + offset - bp->first;
     op->extent.length = length;
@@ -5590,8 +5591,7 @@ int BlueStore::_do_write(
   for (map<uint64_t,bluestore_extent_t>::iterator p = o->onode.block_map.begin();
        p != o->onode.block_map.end();
        ++p) {
-    if (p->second.has_flag(bluestore_extent_t::FLAG_COW_HEAD) ||
-       p->second.has_flag(bluestore_extent_t::FLAG_COW_TAIL)) {
+    if (p->second.has_flag(bluestore_extent_t::FLAG_COW_TAIL)) {
       derr << __func__ << " left behind a COW extent, out of sync with "
           << "_do_allocate" << dendl;
       _dump_onode(o, 0);
@@ -5700,7 +5700,6 @@ void BlueStore::_do_zero_tail_extent(
        dout(10) << __func__ << " wal zero tail partial block "
                 << x_off << "~" << x_len << " at " << op->extent
                 << dendl;
-       assert(!pp->second.has_flag(bluestore_extent_t::FLAG_COW_HEAD));
        assert(!pp->second.has_flag(bluestore_extent_t::FLAG_COW_TAIL));
       }
       if (offset > end_block) {
index 77cf1d5214eddb6a2223309969f3e7bea48801e2..7d1ff07e5677e811d5519a434934fc1d7d9ba64d 100644 (file)
@@ -885,6 +885,8 @@ private:
                   bool allow_overlay,
                   uint64_t *alloc_offset,
                   uint64_t *alloc_length,
+                  uint64_t *cow_head_extent,
+                  uint64_t *cow_tail_extent,
                   uint64_t *rmw_cow_head,
                   uint64_t *rmw_cow_tail);
   int _do_write(TransContext *txc,
index 1160313e0dbd10654421543216bf00811e040d6a..a76fbdfb25994989344c6142b532d8685370f8c6 100644 (file)
@@ -107,11 +107,6 @@ string bluestore_extent_t::get_flags_string(unsigned flags)
       s += '+';
     s += "shared";
   }
-  if (flags & FLAG_COW_HEAD) {
-    if (s.length())
-      s += '+';
-    s += "cow_head";
-  }
   if (flags & FLAG_COW_TAIL) {
     if (s.length())
       s += '+';
index 8ee8dd1ebe4611ccb851252b035ba49fc6e4c965..9529843efd3ec95e902d0bb19a29bbe3da055e4e 100644 (file)
@@ -58,7 +58,6 @@ WRITE_CLASS_ENCODER(bluestore_cnode_t)
 struct bluestore_extent_t {
   enum {
     FLAG_SHARED = 2,      ///< extent is shared by another object, and refcounted
-    FLAG_COW_HEAD = 4,    ///< extent has pending wal OP_COPY for head
     FLAG_COW_TAIL = 8,    ///< extent has pending wal OP_COPY for tail
   };
   static string get_flags_string(unsigned flags);