Skip to content

Commit

Permalink
Merge pull request ceph#55130 from ifed01/wip-ifed-better-shared-blob…
Browse files Browse the repository at this point in the history
…-repair

test/store_test: get rid off explicit offset specifications in shared

Reviewed-by: Pere Diaz Bou <[email protected]>
  • Loading branch information
yuriw authored Jul 31, 2024
2 parents 815fd8c + 482e5b8 commit d5af663
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/os/bluestore/BlueStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/os/bluestore/BlueStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
21 changes: 17 additions & 4 deletions src/test/objectstore/store_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit d5af663

Please sign in to comment.