]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/StupidAllocator: add reservation assertions
authorSage Weil <sage@redhat.com>
Wed, 23 Dec 2015 15:17:44 +0000 (10:17 -0500)
committerSage Weil <sage@redhat.com>
Fri, 1 Jan 2016 18:07:29 +0000 (13:07 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/StupidAllocator.cc
src/os/bluestore/StupidAllocator.h

index 2a1394a13e7a9f004c13f2a4fdb8fcfc8543ef9b..307c211583958e3399f7c3be950521a9de50bee6 100644 (file)
@@ -159,6 +159,8 @@ int StupidAllocator::allocate(
 
   num_free -= *length;
   num_reserved -= need_size;
+  assert(num_free >= 0);
+  assert(num_reserved >= 0);
   last_alloc = *offset + *length;
   return 0;
 }
@@ -232,6 +234,7 @@ void StupidAllocator::init_rm_free(uint64_t offset, uint64_t length)
   }
   assert(rm.empty());
   num_free -= length;
+  assert(num_free >= 0);
 }
 
 
index 76abc5d5fdd448210319bc7675d12e9d2c142409..cad115d417c0866af9e8285f5008e6ac347d8c60 100644 (file)
 class StupidAllocator : public Allocator {
   Mutex lock;
 
-  uint64_t num_free;     ///< total bytes in freelist
-  uint64_t num_uncommitted;
-  uint64_t num_committing;
-  uint64_t num_reserved; ///< reserved bytes
+  int64_t num_free;     ///< total bytes in freelist
+  int64_t num_uncommitted;
+  int64_t num_committing;
+  int64_t num_reserved; ///< reserved bytes
 
   vector<interval_set<uint64_t> > free;        ///< leading-edge copy
   interval_set<uint64_t> uncommitted; ///< released but not yet usable