]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BitAllocator: fix bug of checking required blocks 13470/head
authorwangzhengyong <wangzhengyong@cmss.chinamobile.com>
Thu, 16 Feb 2017 08:41:56 +0000 (16:41 +0800)
committerwangzhengyong <wangzhengyong@cmss.chinamobile.com>
Fri, 17 Feb 2017 06:39:08 +0000 (14:39 +0800)
Signed-off-by: wangzhengyong@cmss.chinamobile.com
src/os/bluestore/BitAllocator.cc

index 4b19ac1ffd84343c0a61844e6a6d72e2f515a3ea..9e754bc0ef889be3735423bbca770f031567e579 100644 (file)
@@ -791,6 +791,13 @@ bool BitMapAreaIN::child_check_n_lock(BitMapArea *child, int64_t required)
     return false;
   }
 
+  int64_t child_used_blocks = child->get_used_blocks();
+  int64_t child_total_blocks = child->size();
+  if ((child_total_blocks - child_used_blocks) < required) {
+    child->unlock();
+    return false;
+  }
+
   return true;
 }
 
@@ -1101,6 +1108,14 @@ bool BitMapAreaLeaf::child_check_n_lock(BitMapArea *child, int64_t required, boo
     child->unlock();
     return false;
   }
+
+  int64_t child_used_blocks = child->get_used_blocks();
+  int64_t child_total_blocks = child->size();
+  if ((child_total_blocks - child_used_blocks) < required) {
+    child->unlock();
+    return false;
+  }
+
   return true;
 }
 
@@ -1338,6 +1353,12 @@ bool BitAllocator::child_check_n_lock(BitMapArea *child, int64_t required)
     return false;
   }
 
+  int64_t child_used_blocks = child->get_used_blocks();
+  int64_t child_total_blocks = child->size();
+  if ((child_total_blocks - child_used_blocks) < required) {
+    child->unlock();
+    return false;
+  }
 
   return true;
 }