From: Jason Dillaman Date: Tue, 1 Sep 2015 14:17:02 +0000 (-0400) Subject: librbd: flush journal entries prior to releasing lock X-Git-Tag: v10.0.1~52^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=10deea8d7c617599a3898313244f8a14606044c1;p=ceph.git librbd: flush journal entries prior to releasing lock Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/Journal.cc b/src/librbd/Journal.cc index ca4221e11a756..37e311e46e280 100644 --- a/src/librbd/Journal.cc +++ b/src/librbd/Journal.cc @@ -545,6 +545,9 @@ void Journal::handle_lock_updated(ImageWatcher::LockUpdateState state) { // prevent new write ops but allow pending ops to flush to the journal block_writes(); } + if (m_state == STATE_RECORDING) { + flush_journal(); + } } else if ((state == ImageWatcher::LOCK_UPDATE_STATE_NOT_SUPPORTED || state == ImageWatcher::LOCK_UPDATE_STATE_UNLOCKED) && m_state != STATE_UNINITIALIZED && @@ -600,6 +603,19 @@ void Journal::unblock_writes() { } } +void Journal::flush_journal() { + assert(m_lock.is_locked()); + + CephContext *cct = m_image_ctx.cct; + ldout(cct, 20) << this << " " << __func__ << dendl; + + m_lock.Unlock(); + C_SaferCond cond_ctx; + m_journaler->flush(&cond_ctx); + cond_ctx.wait(); + m_lock.Lock(); +} + void Journal::transition_state(State state) { CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << this << " " << __func__ << ": new state=" << state << dendl; diff --git a/src/librbd/Journal.h b/src/librbd/Journal.h index 392960507c942..f6368b27f136b 100644 --- a/src/librbd/Journal.h +++ b/src/librbd/Journal.h @@ -199,6 +199,7 @@ private: void block_writes(); void unblock_writes(); + void flush_journal(); void transition_state(State state); void wait_for_state_transition(); };