From: Sage Weil Date: Fri, 20 Sep 2019 13:10:59 +0000 (-0500) Subject: os/bluestore: fix objectstore_blackhole read-after-write X-Git-Tag: v15.1.0~1455^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6c2a8e472dc71b962d7de008e30631f125b148c3;p=ceph.git os/bluestore: fix objectstore_blackhole read-after-write 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 --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 872b29eb205f..ee9556a48374 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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(ch.get()); diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 48ddc1299c4a..8976c03b0278 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -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 diff --git a/src/os/bluestore/KernelDevice.cc b/src/os/bluestore/KernelDevice.cc index d3c5ecfd59b9..53a78cdbe188 100644 --- a/src/os/bluestore/KernelDevice.cc +++ b/src/os/bluestore/KernelDevice.cc @@ -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