From: Yin Congmin Date: Tue, 30 Mar 2021 14:47:33 +0000 (+0800) Subject: librbd/cache/pwl: Fix pmem cache fragment issue X-Git-Tag: v16.2.7~50^2~22 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fac39e019c3fd84910d5de6a1c4daaa6d306ebd5;p=ceph.git librbd/cache/pwl: Fix pmem cache fragment issue I/O may hang due to pmem cache fragment issue when blocks are diffrent in size. Call pmdk API(pmemobj_defrag) to solve. Fixes: https://tracker.ceph.com/issues/49879 Signed-off-by: Yin Congmin (cherry picked from commit b53392a15380b57d6111cb2926083393627f1ed7) --- diff --git a/src/librbd/cache/pwl/rwl/WriteLog.cc b/src/librbd/cache/pwl/rwl/WriteLog.cc index 56bf3851c7b9..e22cb62da1b3 100644 --- a/src/librbd/cache/pwl/rwl/WriteLog.cc +++ b/src/librbd/cache/pwl/rwl/WriteLog.cc @@ -920,6 +920,12 @@ void WriteLog::reserve_cache(C_BlockIORequestT *req, << *req << dendl; alloc_succeeds = false; no_space = true; /* Entries need to be retired */ + + if (this->m_free_log_entries == this->m_total_log_entries - 1) { + /* When the cache is empty, there is still no space to allocate. + * Defragment. */ + pmemobj_defrag(m_log_pool, NULL, 0, NULL); + } break; } else { buffer.allocated = true;