Skip to content

Commit

Permalink
os/bluestore: do not precalculate/cache shard keys
Browse files Browse the repository at this point in the history
Note that we are generating it on demand now.  We can
probably do better, especially when in a loop.

Signed-off-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Dec 22, 2016
1 parent 566ad2d commit 1502fe1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
28 changes: 18 additions & 10 deletions src/os/bluestore/BlueStore.cc
Expand Up @@ -1629,7 +1629,7 @@ bool BlueStore::ExtentMap::update(KeyValueDB::Transaction t,
} else {

struct dirty_shard_t{
string* key = nullptr;
uint32_t offset;
bufferlist bl;
boost::intrusive::list_member_hook<> dirty_list_item;
};
Expand Down Expand Up @@ -1683,7 +1683,7 @@ bool BlueStore::ExtentMap::update(KeyValueDB::Transaction t,
p->shard_info->bytes = len;
p->shard_info->extents = nn;

encoded_shards[pos].key = &p->key;
encoded_shards[pos].offset = p->offset;
dirty_shards.push_back(encoded_shards[pos]);
p->dirty = false;
}
Expand All @@ -1692,8 +1692,10 @@ bool BlueStore::ExtentMap::update(KeyValueDB::Transaction t,
}
//schedule DB update for dirty shards
auto it = dirty_shards.begin();
while(it != dirty_shards.end()) {
t->set(PREFIX_OBJ, *(it->key), it->bl);
while (it != dirty_shards.end()) {
string key;
get_extent_shard_key(onode->key, it->offset, &key);
t->set(PREFIX_OBJ, key, it->bl);
++it;
}
}
Expand Down Expand Up @@ -2049,7 +2051,6 @@ void BlueStore::ExtentMap::init_shards(bool loaded, bool dirty)
shards.resize(onode->onode.extent_map_shards.size());
unsigned i = 0;
for (auto &s : onode->onode.extent_map_shards) {
get_extent_shard_key(onode->key, s.offset, &shards[i].key);
shards[i].offset = s.offset;
shards[i].shard_info = &s;
shards[i].loaded = loaded;
Expand Down Expand Up @@ -4460,7 +4461,9 @@ int BlueStore::fsck(bool deep)
}
for (auto& s : o->extent_map.shards) {
dout(20) << __func__ << " shard " << *s.shard_info << dendl;
expecting_shards.push_back(s.key);
string key;
get_extent_shard_key(o->key, s.offset, &key);
expecting_shards.push_back(key);
}
// lextents
uint64_t pos = 0;
Expand Down Expand Up @@ -6432,7 +6435,9 @@ void BlueStore::_txc_write_nodes(TransContext *txc, KeyValueDB::Transaction t)
if (reshard) {
dout(20) << __func__ << " resharding extents for " << o->oid << dendl;
for (auto &s : o->extent_map.shards) {
t->rmkey(PREFIX_OBJ, s.key);
string key;
get_extent_shard_key(o->key, s.offset, &key);
t->rmkey(PREFIX_OBJ, key);
}
o->extent_map.fault_range(db, 0, o->onode.size);
o->extent_map.reshard(min_alloc_size);
Expand Down Expand Up @@ -8393,7 +8398,9 @@ int BlueStore::_do_remove(
o->onode = bluestore_onode_t();
txc->removed(o);
for (auto &s : o->extent_map.shards) {
txc->t->rmkey(PREFIX_OBJ, s.key);
string key;
get_extent_shard_key(o->key, s.offset, &key);
txc->t->rmkey(PREFIX_OBJ, key);
}
txc->t->rmkey(PREFIX_OBJ, o->key);
o->extent_map.clear();
Expand Down Expand Up @@ -8935,8 +8942,9 @@ int BlueStore::_rename(TransContext *txc,
oldo->extent_map.fault_range(db, 0, oldo->onode.size);
get_object_key(new_oid, &new_okey);
for (auto &s : oldo->extent_map.shards) {
txc->t->rmkey(PREFIX_OBJ, s.key);
get_extent_shard_key(new_okey, s.offset, &s.key);
string key;
get_extent_shard_key(oldo->key, s.offset, &key);
txc->t->rmkey(PREFIX_OBJ, key);
s.dirty = true;
}

Expand Down
1 change: 0 additions & 1 deletion src/os/bluestore/BlueStore.h
Expand Up @@ -644,7 +644,6 @@ class BlueStore : public ObjectStore,
blob_map_t spanning_blob_map; ///< blobs that span shards

struct Shard {
string key; ///< kv key
uint32_t offset; ///< starting logical offset
bluestore_onode_t::shard_info *shard_info;
bool loaded = false; ///< true if shard is loaded
Expand Down

0 comments on commit 1502fe1

Please sign in to comment.