]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/Allocator: init_rm_free
authorSage Weil <sage@redhat.com>
Thu, 10 Dec 2015 21:08:32 +0000 (16:08 -0500)
committerSage Weil <sage@redhat.com>
Fri, 1 Jan 2016 18:06:52 +0000 (13:06 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/Allocator.h
src/os/bluestore/StupidAllocator.cc
src/os/bluestore/StupidAllocator.h

index 5c120a2f6a9f3ab9cd0b4275a644a86119601101..fea26ab8a5aae1f28b3ef3724451742623689dd4 100644 (file)
@@ -13,8 +13,8 @@
 #define CEPH_OS_NEWSTORE_ALLOCATOR_H
 
 #include "kv/KeyValueDB.h"
-
 #include <ostream>
+#include "include/assert.h"
 
 class FreelistManager;
 
@@ -37,6 +37,9 @@ public:
   virtual void dump(std::ostream& out) = 0;
 
   virtual void init_add_free(uint64_t offset, uint64_t length) = 0;
+  virtual void init_rm_free(uint64_t offset, uint64_t length) = 0;
+
+  virtual uint64_t get_free() = 0;
 
   virtual void shutdown() = 0;
 
index 2727f8c8a440ba90984fc517aa0d14ab887c803a..6f29d3ce9cdaa335bd11514ab9b2611c20069e05 100644 (file)
@@ -164,6 +164,12 @@ int StupidAllocator::release(
   return 0;
 }
 
+uint64_t StupidAllocator::get_free()
+{
+  Mutex::Locker l(lock);
+  return num_free;
+}
+
 void StupidAllocator::dump(ostream& out)
 {
   Mutex::Locker l(lock);
@@ -199,6 +205,24 @@ void StupidAllocator::init_add_free(uint64_t offset, uint64_t length)
   num_free += length;
 }
 
+void StupidAllocator::init_rm_free(uint64_t offset, uint64_t length)
+{
+  dout(10) << __func__ << " " << offset << "~" << length << dendl;
+  interval_set<uint64_t> rm;
+  for (unsigned i = 0; i < free.size() && !rm.empty(); ++i) {
+    interval_set<uint64_t> overlap;
+    overlap.intersection_of(rm, free[i]);
+    if (!overlap.empty()) {
+      dout(20) << __func__ << " bin " << i << " rm " << overlap << dendl;
+      free[i].subtract(overlap);
+      rm.subtract(overlap);
+    }
+  }
+  assert(rm.empty());
+  num_free -= length;
+}
+
+
 void StupidAllocator::shutdown()
 {
   dout(1) << __func__ << dendl;
index ffaec2aebef3d173cf76da93900943140ef9fc36..b37c03507c78415dca74f672ae10cf881e751410 100644 (file)
@@ -41,9 +41,13 @@ public:
   void commit_start();
   void commit_finish();
 
+  uint64_t get_free();
+
   void dump(ostream& out);
 
   void init_add_free(uint64_t offset, uint64_t length);
+  void init_rm_free(uint64_t offset, uint64_t length);
+
   void shutdown();
 };