]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/cache/pwl: Fix pmem cache fragment issue 40493/head
authorYin Congmin <congmin.yin@intel.com>
Tue, 30 Mar 2021 14:47:33 +0000 (22:47 +0800)
committerYin Congmin <congmin.yin@intel.com>
Thu, 29 Apr 2021 14:12:31 +0000 (22:12 +0800)
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 <congmin.yin@intel.com>
src/librbd/cache/pwl/rwl/WriteLog.cc

index 4f563d739da14fe66789aaad4709ce39e2ad4439..a9b5e708b9e130a968acd26ba14368e54e346149 100644 (file)
@@ -897,6 +897,12 @@ void WriteLog<I>::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;