]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: add sanity check when try to trim onode from cache
authorxie xingguo <xie.xingguo@zte.com.cn>
Mon, 27 Jun 2016 01:29:50 +0000 (09:29 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Mon, 27 Jun 2016 13:37:10 +0000 (21:37 +0800)
We have verified that the onode size to be trimmed is positive ahead,
so "p" shall never point to onode_lru.begin() below here.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc

index fa3518f44fb2b3b530206bad50550a506df2dd97..478375e258d9b22a7b09c122e3a9563588d8d503 100644 (file)
@@ -529,6 +529,7 @@ void BlueStore::LRUCache::trim(uint64_t onode_max, uint64_t buffer_max)
     return; // don't even try
 
   auto p = onode_lru.end();
+  assert(p != onode_lru.begin());
   --p;
   while (num > 0) {
     Onode *o = &*p;
@@ -747,8 +748,8 @@ void BlueStore::TwoQCache::trim(uint64_t onode_max, uint64_t buffer_max)
     return; // don't even try
 
   auto p = onode_lru.end();
-  if (num)
-    --p;
+  assert(p != onode_lru.begin());
+  --p;
   while (num > 0) {
     Onode *o = &*p;
     int refs = o->nref.load();