]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/seastore/cache: clean up LRU
authorXinyu Huang <xinyu.huang@intel.com>
Thu, 30 Dec 2021 08:43:08 +0000 (16:43 +0800)
committerXinyu Huang <xinyu.huang@intel.com>
Fri, 31 Dec 2021 03:16:53 +0000 (11:16 +0800)
Signed-off-by: Xinyu Huang <xinyu.huang@intel.com>
src/crimson/os/seastore/cache.cc
src/crimson/os/seastore/cache.h
src/crimson/os/seastore/transaction_manager.cc

index 6f7f6833f38d828a32fc1647cbadae184bb5a1b6..8eacead9899afc0c8cc5cb3422203ba4510b2b8c 100644 (file)
@@ -34,7 +34,6 @@ Cache::Cache(
 Cache::~Cache()
 {
   LOG_PREFIX(Cache::~Cache);
-  lru.clear();
   for (auto &i: extents) {
     ERROR("extent {} still alive", i);
   }
@@ -618,9 +617,9 @@ void Cache::add_extent(CachedExtentRef ref)
 
   if (ref->is_dirty()) {
     add_to_dirty(ref);
-  } else if (!ref->is_placeholder()) {
-    lru.add_to_lru(*ref);
-  } 
+  } else {
+    touch_extent(*ref);
+  }
   DEBUG("extent {}", *ref);
 }
 
index 4d0225ead1e584b47c016a09a8192b11d6151510..c262760ce9b790cf45cb6eccc74c6e0f422b779a 100644 (file)
@@ -725,16 +725,6 @@ private:
        remove_from_lru(lru.front());
       }
     }
-  public:
-    LRU(size_t capacity) : capacity(capacity) {}
-
-    size_t get_current_contents_bytes() const {
-      return contents;
-    }
-
-    size_t get_current_contents_extents() const {
-      return lru.size();
-    }
 
     void add_to_lru(CachedExtent &extent) {
       assert(
@@ -750,6 +740,17 @@ private:
       trim_to_capacity();
     }
 
+  public:
+    LRU(size_t capacity) : capacity(capacity) {}
+
+    size_t get_current_contents_bytes() const {
+      return contents;
+    }
+
+    size_t get_current_contents_extents() const {
+      return lru.size();
+    }
+
     void remove_from_lru(CachedExtent &extent) {
       assert(extent.is_clean());
       assert(!extent.is_pending());
@@ -787,7 +788,7 @@ private:
     }
 
     ~LRU() {
-      assert(lru.empty());
+      clear();
     }
   } lru;
 
index 255b082ee991db598eb921edbc7fa957b9d64192..a04c45ef17b32a50300d95948f59437246563da5 100644 (file)
@@ -470,9 +470,7 @@ TransactionManager::get_extent_if_live_ret TransactionManager::get_extent_if_liv
   });
 }
 
-TransactionManager::~TransactionManager() {
-  cache->clear_lru();
-}
+TransactionManager::~TransactionManager() {}
 
 void TransactionManager::register_metrics()
 {