From: Jason Dillaman Date: Tue, 24 Feb 2015 17:53:45 +0000 (-0500) Subject: librbd: flush context potentially completing too early X-Git-Tag: v0.93~5^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dde882cd7a389616ebade40b054bd1984176be45;p=ceph.git librbd: flush context potentially completing too early If the async operation associated with a flush request completes, only complete the flush contexts if no previous operations are still in flight. Otherwise, move the flush contexts to an older in-flight async operation. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/AsyncOperation.cc b/src/librbd/AsyncOperation.cc index cdb131067956..2f0ef81e4181 100644 --- a/src/librbd/AsyncOperation.cc +++ b/src/librbd/AsyncOperation.cc @@ -17,14 +17,26 @@ void AsyncOperation::start_op(ImageCtx &image_ctx) { ldout(m_image_ctx->cct, 20) << this << " " << __func__ << dendl; Mutex::Locker l(m_image_ctx->async_ops_lock); - m_image_ctx->async_ops.push_back(&m_xlist_item); + m_image_ctx->async_ops.push_front(&m_xlist_item); } void AsyncOperation::finish_op() { ldout(m_image_ctx->cct, 20) << this << " " << __func__ << dendl; { Mutex::Locker l(m_image_ctx->async_ops_lock); + xlist::iterator iter(&m_xlist_item); + ++iter; assert(m_xlist_item.remove_myself()); + + // linked list stored newest -> oldest ops + if (!iter.end()) { + ldout(m_image_ctx->cct, 20) << "moving flush contexts to previous op: " + << *iter << dendl; + (*iter)->m_flush_contexts.insert((*iter)->m_flush_contexts.end(), + m_flush_contexts.begin(), + m_flush_contexts.end()); + return; + } } while (!m_flush_contexts.empty()) { diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 9fbc04ca4892..2637d64acc15 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -708,6 +708,6 @@ namespace librbd { ldout(cct, 20) << "flush async operations: " << on_finish << " " << "count=" << async_ops.size() << dendl; - async_ops.back()->add_flush_context(on_finish); + async_ops.front()->add_flush_context(on_finish); } }