]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: fix objectstore_blackhole read-after-write
authorSage Weil <sage@redhat.com>
Fri, 20 Sep 2019 13:10:59 +0000 (08:10 -0500)
committerSage Weil <sage@redhat.com>
Sun, 22 Sep 2019 21:58:33 +0000 (16:58 -0500)
Instead of tossing out transactions from queue_transactions (which prevents
us from reading back the results), instead (1) stop doing any write IO, and
(2) stop trimming the cache.

Fixes: https://tracker.ceph.com/issues/40684
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/os/bluestore/KernelDevice.cc

index 872b29eb205f79660f9c0f172ed9936c944e73a7..ee9556a483746364d209a30be7d07fd2251b34c1 100644 (file)
@@ -12099,16 +12099,6 @@ int BlueStore::queue_transactions(
   ObjectStore::Transaction::collect_contexts(
     tls, &on_applied, &on_commit, &on_applied_sync);
 
-  if (cct->_conf->objectstore_blackhole) {
-    dout(0) << __func__ << " objectstore_blackhole = TRUE, dropping transaction"
-           << dendl;
-    for (auto& l : { on_applied, on_commit, on_applied_sync }) {
-      for (auto c : l) {
-       delete c;
-      }
-    }
-    return 0;
-  }
   auto start = mono_clock::now();
 
   Collection *c = static_cast<Collection*>(ch.get());
index 48ddc1299c4adf98549c809d8f718c6606dfca5d..8976c03b0278b627fd83a5dbecdce657346d6781 100644 (file)
@@ -1152,6 +1152,10 @@ public:
 
     virtual void _trim_to(uint64_t max) = 0;
     void _trim() {
+      if (cct->_conf->objectstore_blackhole) {
+       // do not trim if we are throwing away IOs a layer down
+       return;
+      }
       _trim_to(max);
     }
     void trim() {
@@ -1160,7 +1164,9 @@ public:
     }
     void flush() {
       std::lock_guard l(lock);
-     _trim_to(0);
+      // we should not be shutting down after the blackhole is enabled
+      assert(!cct->_conf->objectstore_blackhole);
+      _trim_to(0);
     }
 
 #ifdef DEBUG_CACHE
index d3c5ecfd59b9ecde4d0b141f486e1e4c585f3939..53a78cdbe18819a693084adef209d1a1926e530a 100644 (file)
@@ -825,6 +825,11 @@ int KernelDevice::write(
           << (buffered ? " (buffered)" : " (direct)")
           << dendl;
   ceph_assert(is_valid_io(off, len));
+  if (cct->_conf->objectstore_blackhole) {
+    lderr(cct) << __func__ << " objectstore_blackhole=true, throwing out IO"
+              << dendl;
+    return 0;
+  }
 
   if ((!buffered || bl.get_num_buffers() >= IOV_MAX) &&
       bl.rebuild_aligned_size_and_memory(block_size, block_size, IOV_MAX)) {
@@ -849,6 +854,11 @@ int KernelDevice::aio_write(
           << (buffered ? " (buffered)" : " (direct)")
           << dendl;
   ceph_assert(is_valid_io(off, len));
+  if (cct->_conf->objectstore_blackhole) {
+    lderr(cct) << __func__ << " objectstore_blackhole=true, throwing out IO"
+              << dendl;
+    return 0;
+  }
 
   if ((!buffered || bl.get_num_buffers() >= IOV_MAX) &&
       bl.rebuild_aligned_size_and_memory(block_size, block_size, IOV_MAX)) {
@@ -928,6 +938,11 @@ int KernelDevice::aio_write(
 int KernelDevice::discard(uint64_t offset, uint64_t len)
 {
   int r = 0;
+  if (cct->_conf->objectstore_blackhole) {
+    lderr(cct) << __func__ << " objectstore_blackhole=true, throwing out IO"
+              << dendl;
+    return 0;
+  }
   if (support_discard) {
       dout(10) << __func__
               << " 0x" << std::hex << offset << "~" << len << std::dec