os/bluestore: Modify maybe_unshare_on_remove

Use Blob* as key for processing 'expect' shared blobs.
Opens access to bluestore_blob_t.

Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
This commit is contained in:
Adam Kupczyk 2026-06-01 10:50:18 +00:00
parent e3d24c9827
commit 1cebcd999d

View File

@ -18349,16 +18349,17 @@ int BlueStore::_maybe_unshare_on_remove(
// that is not yet loaded! We must have had inspected it to even check nrefs.
dout(20) << __func__ << " checking for unshareable blobs on " << h
<< " " << h->oid << dendl;
map<SharedBlob*,bluestore_extent_ref_map_t> expect;
map<const Blob*, bluestore_extent_ref_map_t> expect;
for (auto& e : h->extent_map.extent_map) {
const bluestore_blob_t& b = e.blob->get_blob();
SharedBlob *sb = e.blob->get_shared_blob().get();
const Blob* B = e.blob.get();
const bluestore_blob_t& b = B->get_blob();
SharedBlob *sb = B->get_shared_blob().get();
if (b.is_shared() &&
sb->loaded &&
maybe_unshared_blobs.count(sb)) {
if (b.is_compressed()) {
b.map(0, b.get_ondisk_size(), [&](uint64_t off, uint64_t len) {
expect[sb].get(off, len);
expect[B].get(off, len);
return 0;
});
// Do not account second time.
@ -18366,7 +18367,7 @@ int BlueStore::_maybe_unshare_on_remove(
} else {
// todo: it seems to be an overkill to go through map()
b.map(e.blob_offset, e.length, [&](uint64_t off, uint64_t len) {
expect[sb].get(off, len);
expect[B].get(off, len);
return 0;
});
}
@ -18376,11 +18377,11 @@ int BlueStore::_maybe_unshare_on_remove(
// expect has now refs set exactly as .head is using it
vector<SharedBlob*> unshared_blobs;
unshared_blobs.reserve(expect.size());
for (auto& p : expect) {
dout(20) << " ? " << *p.first << " vs " << p.second << dendl;
if (p.first->persistent->ref_map == p.second) {
for (const auto& [B, expect_refs] : expect) {
SharedBlob* sb = B->get_shared_blob().get();
dout(20) << __func__ << " ? " << *sb << " vs " << expect_refs << dendl;
if (sb->persistent->ref_map == expect_refs) {
// yup, .head is only one that is using the shared blob now
SharedBlob *sb = p.first;
dout(20) << __func__ << " unsharing " << *sb << dendl;
unshared_blobs.push_back(sb);
txc->unshare_blob(sb);