From: Jason Dillaman Date: Wed, 9 Mar 2016 23:00:04 +0000 (-0500) Subject: librbd: complete cache reads on cache's dedicate thread X-Git-Tag: v0.94.7~15^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F8011%2Fhead;p=ceph.git librbd: complete cache reads on cache's dedicate thread If a snapshot is created out-of-band, the next IO will result in the cache being flushed. If pending writeback data performs a copy-on-write, the read from the parent will be blocked. Fixes: #15032 Signed-off-by: Jason Dillaman (cherry picked from commit f9e5ae80e3b0799b5a7e1d3f93b2d85a4baff20f) --- diff --git a/src/librbd/AioCompletion.cc b/src/librbd/AioCompletion.cc index 6222531bedac..efbc84945ffb 100644 --- a/src/librbd/AioCompletion.cc +++ b/src/librbd/AioCompletion.cc @@ -177,9 +177,10 @@ namespace librbd { void C_CacheRead::complete(int r) { if (!m_enqueued) { // cache_lock creates a lock ordering issue -- so re-execute this context - // outside the cache_lock + // outside the cache_lock. use the writeback handler's dedicated thread + // to avoid blocking a dependent operation m_enqueued = true; - m_image_ctx.op_work_queue->queue(this, r); + m_image_ctx.writeback_handler->queue(this, r); return; } Context::complete(r); diff --git a/src/librbd/LibrbdWriteback.cc b/src/librbd/LibrbdWriteback.cc index ac778eec5455..ee14f001dbd5 100644 --- a/src/librbd/LibrbdWriteback.cc +++ b/src/librbd/LibrbdWriteback.cc @@ -102,6 +102,10 @@ namespace librbd { delete m_finisher; } + void LibrbdWriteback::queue(Context *ctx, int r) { + m_finisher->queue(ctx, r); + } + void LibrbdWriteback::read(const object_t& oid, uint64_t object_no, const object_locator_t& oloc, uint64_t off, uint64_t len, snapid_t snapid, @@ -114,7 +118,7 @@ namespace librbd { { if (!m_ictx->object_map.object_may_exist(object_no)) { - m_finisher->queue(req, -ENOENT); + queue(req, -ENOENT); return; } } diff --git a/src/librbd/LibrbdWriteback.h b/src/librbd/LibrbdWriteback.h index b5578ae62f5c..5b65504c83da 100644 --- a/src/librbd/LibrbdWriteback.h +++ b/src/librbd/LibrbdWriteback.h @@ -23,6 +23,8 @@ namespace librbd { LibrbdWriteback(ImageCtx *ictx, Mutex& lock); virtual ~LibrbdWriteback(); + void queue(Context *ctx, int r); + // Note that oloc, trunc_size, and trunc_seq are ignored virtual void read(const object_t& oid, uint64_t object_no, const object_locator_t& oloc, uint64_t off, uint64_t len,