]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/store_test: enable sporadic full NCB recovery
authorIgor Fedotov <ifedotov@suse.com>
Tue, 19 Apr 2022 14:43:20 +0000 (17:43 +0300)
committerIgor Fedotov <igor.fedotov@croit.io>
Mon, 3 Oct 2022 13:09:51 +0000 (16:09 +0300)
Signed-off-by: Igor Fedotov <igor.fedotov@croit.io>
src/common/options/global.yaml.in
src/os/bluestore/BlueStore.cc
src/test/objectstore/store_test.cc

index 00eb445acda7358ce753ff800bbe86a17ae5d10c..fa2a803ee5e96566c058262726df7f7bf01d1180 100644 (file)
@@ -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
index 873ed43bb51640e9e286387e02d4a071806a98d0..013f27aa48b528567a923762fd4151d7172666ca 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <boost/container/flat_set.hpp>
 #include <boost/algorithm/string.hpp>
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/random/uniform_real.hpp>
 
 #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);
index dd95a0bc10875b68b86e78cf06441f413d428fdc..5c339b9e809305c75086698b94d56fda49946df3 100644 (file)
@@ -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");