From: Adam Kupczyk Date: Mon, 1 Jun 2026 10:50:18 +0000 (+0000) Subject: os/bluestore: Modify maybe_unshare_on_remove X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1cebcd999d5f97134cf954bc8b6b9682a700b13e;p=ceph.git 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 --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 18ea2d849723..df32b4dcbd92 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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 expect; + map 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 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);