int KernelDevice::flush()
{
- // serialize flushers, so that we can avoid weird io_since_flush
- // races (w/ multipler flushers).
- Mutex::Locker l(flush_lock);
- if (io_since_flush.read() == 0) {
+ bool ret = io_since_flush.compare_and_swap(1, 0);
+ if (!ret) {
dout(10) << __func__ << " no-op (no ios since last flush)" << dendl;
return 0;
}
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