From 15c099879c3ebd42ac31d42e110ca34d864431ce Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 2 Feb 2016 17:38:27 -0500 Subject: [PATCH] os/bluestore/KernelDevice: crash even when there is no io If we set bdev_inject_crash, ensure we crash even if the device is idle. Signed-off-by: Sage Weil --- src/os/bluestore/KernelDevice.cc | 13 ++++++++++++- src/os/bluestore/KernelDevice.h | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/os/bluestore/KernelDevice.cc b/src/os/bluestore/KernelDevice.cc index c6165a596ec3e..cbd6f3f61d5f1 100644 --- a/src/os/bluestore/KernelDevice.cc +++ b/src/os/bluestore/KernelDevice.cc @@ -41,7 +41,8 @@ KernelDevice::KernelDevice(aio_callback_t cb, void *cbpriv) aio_callback(cb), aio_callback_priv(cbpriv), aio_stop(false), - aio_thread(this) + aio_thread(this), + injecting_crash(0) { zeros = buffer::create_page_aligned(1048576); zeros.zero(); @@ -175,6 +176,7 @@ int KernelDevice::flush() dout(10) << __func__ << " start" << dendl; io_since_flush.set(0); if (g_conf->bdev_inject_crash) { + ++injecting_crash; // sleep for a moment to give other threads a chance to submit or // wait on io that races with a flush. derr << __func__ << " injecting crash. first we sleep..." << dendl; @@ -222,6 +224,7 @@ void KernelDevice::_aio_stop() void KernelDevice::_aio_thread() { dout(10) << __func__ << " start" << dendl; + int inject_crash_count = 0; while (!aio_stop) { dout(40) << __func__ << " polling" << dendl; int max = 16; @@ -257,6 +260,12 @@ void KernelDevice::_aio_thread() } } reap_ioc(); + if (g_conf->bdev_inject_crash) { + ++inject_crash_count; + if (inject_crash_count * g_conf->bdev_aio_poll_ms / 1000 > + g_conf->bdev_inject_crash + g_conf->bdev_inject_crash_flush_delay) + assert(0 == "bdev_inject_crash trigger from aio thread"); + } } dout(10) << __func__ << " end" << dendl; } @@ -376,6 +385,7 @@ int KernelDevice::aio_write( // generate a real io so that aio_wait behaves properly, but make it // a read instead of write, and toss the result. aio.pread(off, len); + ++injecting_crash; } else { bl.prepare_iov(&aio.iov); for (unsigned i=0; ibdev_inject_crash == 0) { derr << __func__ << " bdev_inject_crash: dropping io " << off << "~" << len << dendl; + ++injecting_crash; return 0; } vector iov; diff --git a/src/os/bluestore/KernelDevice.h b/src/os/bluestore/KernelDevice.h index 55526eaaa587f..4ced2022d1c57 100644 --- a/src/os/bluestore/KernelDevice.h +++ b/src/os/bluestore/KernelDevice.h @@ -15,6 +15,8 @@ #ifndef CEPH_OS_BLUESTORE_KERNELDEVICE_H #define CEPH_OS_BLUESTORE_KERNELDEVICE_H +#include + #include "os/fs/FS.h" #include "include/interval_set.h" @@ -49,6 +51,8 @@ class KernelDevice : public BlockDevice { } } aio_thread; + std::atomic_int injecting_crash; + void _aio_thread(); int _aio_start(); void _aio_stop(); -- 2.39.5