From b92062e38ef25d5574403a3fe9205746583430f9 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 27 Jan 2017 11:07:22 -0500 Subject: [PATCH] os/bluestore: replace needs_reshard flag with a range Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 16 ++++++++++------ src/os/bluestore/BlueStore.h | 20 ++++++++++++++++++-- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 965b5afc917..0e081fe7e4f 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -1753,7 +1753,7 @@ bool BlueStore::ExtentMap::update(KeyValueDB::Transaction t, bool force) { auto cct = onode->c->store->cct; //used by dout - assert(!needs_reshard); + assert(!needs_reshard()); if (onode->onode.extent_map_shards.empty()) { if (inline_bl.length() == 0) { unsigned n; @@ -1848,9 +1848,10 @@ bool BlueStore::ExtentMap::update(KeyValueDB::Transaction t, void BlueStore::ExtentMap::reshard() { - auto cct = onode->c->store->cct; //used by dout + auto cct = onode->c->store->cct; // used by dout - needs_reshard = false; + dout(10) << __func__ << " 0x[" << std::hex << needs_reshard_begin << "," + << needs_reshard_end << ")" << std::dec << dendl; // un-span all blobs auto p = spanning_blob_map.begin(); @@ -1864,6 +1865,7 @@ void BlueStore::ExtentMap::reshard() dout(20) << __func__ << " <= 1 extent, going inline" << dendl; shards.clear(); onode->onode.extent_map_shards.clear(); + clear_needs_reshard(); return; } @@ -1989,6 +1991,8 @@ void BlueStore::ExtentMap::reshard() } } } + + clear_needs_reshard(); } bool BlueStore::ExtentMap::encode_some( @@ -2482,8 +2486,8 @@ BlueStore::Extent *BlueStore::ExtentMap::set_lextent( } Extent *le = new Extent(logical_offset, blob_offset, length, b); extent_map.insert(*le); - if (!needs_reshard && spans_shard(logical_offset, length)) { - needs_reshard = true; + if (spans_shard(logical_offset, length)) { + request_reshard(logical_offset, logical_offset + length); } return le; } @@ -6854,7 +6858,7 @@ void BlueStore::_txc_write_nodes(TransContext *txc, KeyValueDB::Transaction t) // finalize onodes for (auto o : txc->onodes) { // finalize extent_map shards - bool reshard = o->extent_map.needs_reshard; + bool reshard = o->extent_map.needs_reshard(); if (!reshard) { reshard = o->extent_map.update(t, false); } diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 160a96f2754..90260feb206 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -671,7 +671,23 @@ public: bufferlist inline_bl; ///< cached encoded map, if unsharded; empty=>dirty - bool needs_reshard = false; ///< true if we must reshard + uint32_t needs_reshard_begin = 0; + uint32_t needs_reshard_end = 0; + + bool needs_reshard() const { + return needs_reshard_end > needs_reshard_begin; + } + void clear_needs_reshard() { + needs_reshard_begin = needs_reshard_end = 0; + } + void request_reshard(uint32_t begin, uint32_t end) { + if (begin < needs_reshard_begin) { + needs_reshard_begin = begin; + } + if (end > needs_reshard_end) { + needs_reshard_end = end; + } + } struct DeleteDisposer { void operator()(Extent *e) { delete e; } @@ -686,7 +702,7 @@ public: extent_map.clear_and_dispose(DeleteDisposer()); shards.clear(); inline_bl.clear(); - needs_reshard = false; + clear_needs_reshard(); } bool encode_some(uint32_t offset, uint32_t length, bufferlist& bl, -- 2.39.5