From 91f01bdbd610bf86f31f9ea06992b9d637c15c90 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Thu, 3 Dec 2015 07:53:42 -0500 Subject: [PATCH] librbd: partial revert of commit 9b0e359 Fixes: #13969 Signed-off-by: Jason Dillaman --- src/librbd/ImageWatcher.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index 75a82bd0f7270..30dca71acafc2 100644 --- a/src/librbd/ImageWatcher.cc +++ b/src/librbd/ImageWatcher.cc @@ -2,7 +2,6 @@ // vim: ts=8 sw=2 smarttab #include "librbd/ImageWatcher.h" #include "librbd/AioCompletion.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/ImageCtx.h" #include "librbd/internal.h" #include "librbd/ObjectMap.h" @@ -393,6 +392,7 @@ int ImageWatcher::release_lock() // ensure all maint operations are canceled m_image_ctx.cancel_async_requests(); + m_image_ctx.flush_async_operations(); int r; { @@ -402,8 +402,12 @@ int ImageWatcher::release_lock() // lock is being released notify_listeners_updated_lock(LOCK_UPDATE_STATE_RELEASING); - // AioImageRequestWQ will have blocked writes / flushed IO by this point - assert(m_image_ctx.aio_work_queue->writes_blocked()); + RWLock::WLocker md_locker(m_image_ctx.md_lock); + r = m_image_ctx.flush(); + if (r < 0) { + lderr(cct) << this << " failed to flush: " << cpp_strerror(r) << dendl; + goto err_cancel_unlock; + } } m_image_ctx.owner_lock.get_write(); @@ -426,6 +430,13 @@ int ImageWatcher::release_lock() } return 0; + +err_cancel_unlock: + m_image_ctx.owner_lock.get_write(); + if (m_lock_owner_state == LOCK_OWNER_STATE_RELEASING) { + m_lock_owner_state = LOCK_OWNER_STATE_LOCKED; + } + return r; } void ImageWatcher::assert_header_locked(librados::ObjectWriteOperation *op) { -- 2.39.5