diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 374adb7a67569..0d7a2daa055c7 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -11042,6 +11042,12 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair) return repair ? errors + warnings - (int)repaired : errors; } +int BlueStore::get_shared_blob(const string& key, + bufferlist& bl) +{ + return db->get(PREFIX_SHARED_BLOB, key, &bl); +}; + /// methods to inject various errors fsck can repair void BlueStore::inject_broken_shared_blob_key(const string& key, const bufferlist& bl) diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index ffe6c37b3a52e..601b59bed7a93 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -3374,6 +3374,8 @@ class BlueStore : public ObjectStore, } /// methods to inject various errors fsck can repair + int get_shared_blob(const std::string& key, + ceph::buffer::list& bl); void inject_broken_shared_blob_key(const std::string& key, const ceph::buffer::list& bl); void inject_no_shared_blob_key(); diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index a12acc0600012..450df045b636d 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -10191,13 +10191,26 @@ TEST_P(StoreTestSpecificAUSize, BluestoreRepairSharedBlobTest) { bstore->umount(); bstore->mount(); { + bufferlist bl; string key; _key_encode_u64(1, &key); bluestore_shared_blob_t sb(1); - sb.ref_map.get(0x822000, block_size); - sb.ref_map.get(0x824000, block_size); - sb.ref_map.get(0x824000, block_size); - bufferlist bl; + int r = bstore->get_shared_blob(key, bl); + ASSERT_EQ(r, 0); + decode(sb, bl); + cout << sb.ref_map << std::endl; + ASSERT_EQ(sb.ref_map.ref_map.size(), 2); + auto it = sb.ref_map.ref_map.begin(); + ASSERT_EQ(it->second.refs, 1); + ASSERT_EQ(it->second.length, block_size); + it++; + ASSERT_EQ(it->second.refs, 1); + ASSERT_EQ(it->second.length, block_size); + + sb.ref_map.get(it->first, block_size); + cout << sb.ref_map << std::endl; + + bl.clear(); encode(sb, bl); bstore->inject_broken_shared_blob_key(key, bl); }