From: Sage Weil Date: Wed, 4 May 2016 18:04:40 +0000 (-0400) Subject: os/bluestore: drop COW_HEAD extent flag X-Git-Tag: v11.0.0~655^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=86d8f8c55a03de82c7a1fc8c2ffe44e810dd23cb;p=ceph.git os/bluestore: drop COW_HEAD extent flag Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 206c24eb591c..54258088b51e 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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::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::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) { diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 77cf1d5214ed..7d1ff07e5677 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -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, diff --git a/src/os/bluestore/bluestore_types.cc b/src/os/bluestore/bluestore_types.cc index 1160313e0dbd..a76fbdfb2599 100644 --- a/src/os/bluestore/bluestore_types.cc +++ b/src/os/bluestore/bluestore_types.cc @@ -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 += '+'; diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h index 8ee8dd1ebe46..9529843efd3e 100644 --- a/src/os/bluestore/bluestore_types.h +++ b/src/os/bluestore/bluestore_types.h @@ -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);