From: Igor Fedotov Date: Tue, 19 Apr 2022 14:43:20 +0000 (+0300) Subject: test/store_test: enable sporadic full NCB recovery X-Git-Tag: v18.1.0~896^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9544de8147ab56b965c78e73c5ba8439f7845686;p=ceph.git test/store_test: enable sporadic full NCB recovery Signed-off-by: Igor Fedotov --- diff --git a/src/common/options/global.yaml.in b/src/common/options/global.yaml.in index 00eb445acda..fa2a803ee5e 100644 --- a/src/common/options/global.yaml.in +++ b/src/common/options/global.yaml.in @@ -4994,6 +4994,14 @@ options: desc: Remove allocation info from RocksDB and store the info in a new allocation file default: true with_legacy: true +- name: bluestore_debug_inject_allocation_from_file_failure + type: float + level: dev + desc: Enables random error injections when restoring allocation map from file. + long_desc: Specifies error injection probability for restoring allocation map from file + hence causing full recovery. Intended primarily for testing. + default: 0 + with_legacy: true - name: bluestore_fsck_on_umount_deep type: bool level: dev diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 873ed43bb51..013f27aa48b 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -22,6 +22,8 @@ #include #include +#include +#include #include "include/cpp-btree/btree_set.h" @@ -10050,7 +10052,7 @@ void BlueStore::inject_stray_shared_blob_key(uint64_t sbid) string key; get_shared_blob_key(sbid, &key); bluestore_shared_blob_t persistent(sbid); - persistent.ref_map.get(0xdead0000, 0x1000); + persistent.ref_map.get(0xdead0000, min_alloc_size); bufferlist bl; encode(persistent, bl); dout(20) << __func__ << " sbid " << sbid @@ -18613,6 +18615,14 @@ int calc_allocator_image_trailer_size() //----------------------------------------------------------------------------------- int BlueStore::__restore_allocator(Allocator* allocator, uint64_t *num, uint64_t *bytes) { + if (cct->_conf->bluestore_debug_inject_allocation_from_file_failure > 0) { + boost::mt11213b rng(time(NULL)); + boost::uniform_real<> ur(0, 1); + if (ur(rng) < cct->_conf->bluestore_debug_inject_allocation_from_file_failure) { + derr << __func__ << " failure injected." << dendl; + return -1; + } + } utime_t start_time = ceph_clock_now(); BlueFS::FileReader *p_temp_handle = nullptr; int ret = bluefs->open_for_read(allocator_dir, allocator_file, &p_temp_handle, false); diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index dd95a0bc108..5c339b9e809 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -10655,6 +10655,8 @@ int main(int argc, char **argv) { // set small cache sizes so we see trimming during Synthetic tests g_ceph_context->_conf.set_val_or_die("bluestore_cache_size_hdd", "4000000"); g_ceph_context->_conf.set_val_or_die("bluestore_cache_size_ssd", "4000000"); + g_ceph_context->_conf.set_val_or_die( + "bluestore_debug_inject_allocation_from_file_failure", "0.67"); // very short *_max prealloc so that we fall back to async submits g_ceph_context->_conf.set_val_or_die("bluestore_blobid_prealloc", "10");