From: Adam Kupczyk Date: Sun, 27 Nov 2022 11:26:27 +0000 (+0000) Subject: os/bluestore: Adapt split_cache X-Git-Tag: v19.0.0~486^2~26 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b04e96953a36880eb6ec559ba31cae7307a6a6d1;p=ceph.git os/bluestore: Adapt split_cache Adapt split_cache to new situation. Now buffers are attached to Blob, and we need always move them, regardless that we already moved relevant SharedBlob. Signed-off-by: Adam Kupczyk --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 2adbaf1c1932..b22cba711f66 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -4216,19 +4216,23 @@ void BlueStore::Collection::split_cache( // move over shared blobs and buffers. cover shared blobs from // both extent map and spanning blob map (the full extent map // may not be faulted in) - vector bvec; - for (auto& e : o->extent_map.extent_map) { - bvec.push_back(e.blob.get()); - } - for (auto& b : o->extent_map.spanning_blob_map) { - bvec.push_back(b.second.get()); - } - for (auto b : bvec) { + + auto rehome_blob = [&](Blob* b) { + for (auto& i : b->bc.buffer_map) { + if (!i.second->is_writing()) { + ldout(store->cct, 1) << __func__ << " moving " << *i.second + << dendl; + dest->cache->_move(cache, i.second.get()); + } else { + ldout(store->cct, 1) << __func__ << " not moving " << *i.second + << dendl; + } + } SharedBlob* sb = b->shared_blob.get(); if (sb->coll == dest) { ldout(store->cct, 20) << __func__ << " already moved " << *sb << dendl; - continue; + return; } ldout(store->cct, 20) << __func__ << " moving " << *sb << dendl; if (sb->get_sbid()) { @@ -4238,14 +4242,30 @@ void BlueStore::Collection::split_cache( dest->shared_blob_set.add(dest, sb); } sb->coll = dest; - if (dest->cache != cache) { - for (auto& i : b->bc.buffer_map) { - if (!i.second->is_writing()) { - ldout(store->cct, 20) << __func__ << " moving " << *i.second - << dendl; - dest->cache->_move(cache, i.second.get()); - } - } + }; + + for (auto& e : o->extent_map.extent_map) { + e.blob->last_encoded_id = -1; + } + for (auto& b : o->extent_map.spanning_blob_map) { + b.second->last_encoded_id = -1; + } + for (auto& e : o->extent_map.extent_map) { + Blob* tb = e.blob.get(); + if (tb->last_encoded_id == -1) { + rehome_blob(tb); + tb->last_encoded_id = 0; + } + } + for (auto& b : o->extent_map.spanning_blob_map) { + Blob* tb = b.second.get(); + if (tb->last_encoded_id == -1) { + // Having blob in spanning but not mapped is an error. + // It will be dropped during encode_some(), + // but in the meantime we want cache to be consistent. + ldout(store->cct, 10) << __func__ << " spanning blob not in map " << *tb << dendl; + rehome_blob(tb); + tb->last_encoded_id = 0; } } }