From df6365ca211573cd24f71ce4b0bded1bc961a9af Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 27 Jan 2017 12:00:15 -0500 Subject: [PATCH] os/bluestore: ExtentMap: factor old shard key removal into reshard() Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 32 +++++++++++++++++--------------- src/os/bluestore/BlueStore.h | 4 +++- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index a22230cd7206e..88b24fa9b5e21 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -1854,13 +1854,28 @@ void BlueStore::ExtentMap::update(KeyValueDB::Transaction t, } } -void BlueStore::ExtentMap::reshard() +void BlueStore::ExtentMap::reshard( + KeyValueDB *db, + KeyValueDB::Transaction t) { auto cct = onode->c->store->cct; // used by dout dout(10) << __func__ << " 0x[" << std::hex << needs_reshard_begin << "," << needs_reshard_end << ")" << std::dec << dendl; + fault_range(db, 0, OBJECT_MAX_SIZE); + + // remove old keys + string key; + for (auto &s : shards) { + generate_extent_shard_key_and_apply( + onode->key, s.offset, &key, + [&](const string& final_key) { + t->rmkey(PREFIX_OBJ, final_key); + } + ); + } + // un-span all blobs auto p = spanning_blob_map.begin(); while (p != spanning_blob_map.end()) { @@ -6872,20 +6887,7 @@ void BlueStore::_txc_write_nodes(TransContext *txc, KeyValueDB::Transaction t) o->extent_map.update(t, false); } if (o->extent_map.needs_reshard()) { - dout(20) << __func__ << " resharding extents for " << o->oid - << " over 0x[" << std::hex << o->extent_map.needs_reshard_begin - << "," << o->extent_map.needs_reshard_end << ")" << std::dec - << dendl; - string key; - for (auto &s : o->extent_map.shards) { - generate_extent_shard_key_and_apply(o->key, s.offset, &key, - [&](const string& final_key) { - t->rmkey(PREFIX_OBJ, final_key); - } - ); - } - o->extent_map.fault_range(db, 0, o->onode.size); - o->extent_map.reshard(); + o->extent_map.reshard(db, t); o->extent_map.update(t, true); if (o->extent_map.needs_reshard()) { dout(20) << __func__ << " warning: still wants reshard, check options?" diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 2c0af85a999f7..6136d4b561e32 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -721,7 +721,9 @@ public: } void update(KeyValueDB::Transaction t, bool force); - void reshard(); + void reshard( + KeyValueDB *db, + KeyValueDB::Transaction t); /// initialize Shards from the onode void init_shards(bool loaded, bool dirty); -- 2.39.5