From e62d891df8b2a37f1f032aced5054e038fb6b7ab Mon Sep 17 00:00:00 2001 From: Yin Congmin Date: Thu, 18 Mar 2021 21:33:07 +0800 Subject: [PATCH] librbd/cache/pwl: fix bug of flush request blocked by deferd IO Flush requests do not need to be queued behind the defer_io queue, should be issued immediately. Otherwise, there will be a deadlock scenario in which dirty data is waiting for flush req, flush req is waiting for defer_io empty, and defer_io is waiting for dirty data persistence to release space. So this sometimes occur when the cache is small but the IO is large or the queue depth is large. Signed-off-by: Yin Congmin (cherry picked from commit 6583182f624386bfbb7375fb227dfb77b0a3209d) --- src/librbd/cache/pwl/AbstractWriteLog.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/librbd/cache/pwl/AbstractWriteLog.cc b/src/librbd/cache/pwl/AbstractWriteLog.cc index a658b60b2fe47..76e8e478e2bf7 100644 --- a/src/librbd/cache/pwl/AbstractWriteLog.cc +++ b/src/librbd/cache/pwl/AbstractWriteLog.cc @@ -818,9 +818,11 @@ void AbstractWriteLog::write(Extents &&image_extents, ceph_assert(m_initialized); - /* Split images because PMDK doesn't support allocating too big extent - * TODO: If the bluestore allocator is implemented as a library, - * the split operation is not necessary + /* Split images because PMDK's space management is not perfect, there are + * fragment problems. The larger the block size difference of the block, + * the easier the fragmentation problem will occur, resulting in the + * remaining space can not be allocated in large size. We plan to manage + * pmem space and allocation by ourselves in the future. */ Extents split_image_extents; uint64_t max_extent_size = get_max_extent(); @@ -1430,6 +1432,11 @@ void AbstractWriteLog::alloc_and_dispatch_io_req(C_BlockIORequestT *req) { std::lock_guard locker(m_lock); dispatch_here = m_deferred_ios.empty(); + // Only flush req's total_bytes is the max uint64 + if ((req->image_extents_summary.total_bytes == + std::numeric_limits::max())) { + dispatch_here = true; + } } if (dispatch_here) { dispatch_here = req->alloc_resources(); -- 2.39.5