]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
freelist
authorsage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Fri, 1 Sep 2006 00:56:51 +0000 (00:56 +0000)
committersage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Fri, 1 Sep 2006 00:56:51 +0000 (00:56 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@831 29311d96-e01e-0410-9327-a35deaab8ce9

ceph/ebofs/Allocator.h
ceph/ebofs/Ebofs.cc
ceph/ebofs/Ebofs.h

index 5229863476219ebc1e525a4856192c92f3a1278a..16acc47a92557cbc7effc26f03812a11fbc59a79 100644 (file)
@@ -52,6 +52,7 @@ protected:
 
   void dump_freelist();
 
+ public:
   int _release_loner(Extent& ex);  // release loner extent
   int _release_merge(Extent& ex);  // release any extent (searches for adjacent)
 
index 18c7b0e056bf71ccf2d537e576ed09f8b4db5be1..7846fd5ae70c589718dcc81af011526083108d21 100644 (file)
@@ -2707,6 +2707,47 @@ int Ebofs::collection_listattr(coll_t cid, vector<string>& attrs)
 
 
 
+void Ebofs::_export_freelist(bufferlist& bl)
+{
+  for (int b=0; b<=EBOFS_NUM_FREE_BUCKETS; b++) {
+       Table<block_t,block_t> *tab;
+       if (b < EBOFS_NUM_FREE_BUCKETS) {
+         tab = free_tab[b];
+       } else {
+         tab = limbo_tab;
+       }
+       
+       if (tab->get_num_keys() > 0) {
+         Table<block_t,block_t>::Cursor cursor(tab);
+         assert(tab->find(0, cursor) >= 0);
+         while (1) {
+               assert(cursor.current().value > 0);
+               
+               Extent ex(cursor.current().key, cursor.current().value);
+               dout(0) << "_export_freelist " << ex << endl;
+               bl.append((char*)&ex, sizeof(ex));
+               if (cursor.move_right() <= 0) break;
+         }
+       }
+  }
+}
+
+void Ebofs::_import_freelist(bufferlist& bl)
+{
+  // clear
+  for (int b=0; b<EBOFS_NUM_FREE_BUCKETS; b++) 
+       free_tab[b]->clear();
+  limbo_tab->clear();
+
+  // import!
+  int num = bl.length() / sizeof(Extent);
+  Extent *p = (Extent*)bl.c_str();
+  for (int i=0; i<num; i++) {
+       dout(0) << "_import_freelist " << p[i] << endl;
+       allocator._release_loner(p[i]);
+  }
+}
+
 void Ebofs::_get_frag_stat(FragmentationStat& st)
 {
   ebofs_lock.Lock();
index 43d52a931db776f43bbe6143126a8c84036579e5..c06510f9ee65330c7dd66532d0297eb9bfb8e31d 100644 (file)
@@ -276,6 +276,10 @@ class Ebofs : public ObjectStore {
   void _fake_writes(bool b) { fake_writes = b; }
   void _get_frag_stat(FragmentationStat& st);
 
+  void _import_freelist(bufferlist& bl);
+  void _export_freelist(bufferlist& bl);
+
+
 private:
   // private interface -- use if caller already holds lock
   int _read(object_t oid, off_t off, size_t len, bufferlist& bl);