From 60200eb0ff253daaacc80b2ea77f4110e9bf34bc Mon Sep 17 00:00:00 2001 From: sage Date: Fri, 1 Sep 2006 00:56:51 +0000 Subject: [PATCH] freelist git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@831 29311d96-e01e-0410-9327-a35deaab8ce9 --- ceph/ebofs/Allocator.h | 1 + ceph/ebofs/Ebofs.cc | 41 +++++++++++++++++++++++++++++++++++++++++ ceph/ebofs/Ebofs.h | 4 ++++ 3 files changed, 46 insertions(+) diff --git a/ceph/ebofs/Allocator.h b/ceph/ebofs/Allocator.h index 5229863476219..16acc47a92557 100644 --- a/ceph/ebofs/Allocator.h +++ b/ceph/ebofs/Allocator.h @@ -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) diff --git a/ceph/ebofs/Ebofs.cc b/ceph/ebofs/Ebofs.cc index 18c7b0e056bf7..7846fd5ae70c5 100644 --- a/ceph/ebofs/Ebofs.cc +++ b/ceph/ebofs/Ebofs.cc @@ -2707,6 +2707,47 @@ int Ebofs::collection_listattr(coll_t cid, vector& attrs) +void Ebofs::_export_freelist(bufferlist& bl) +{ + for (int b=0; b<=EBOFS_NUM_FREE_BUCKETS; b++) { + Table *tab; + if (b < EBOFS_NUM_FREE_BUCKETS) { + tab = free_tab[b]; + } else { + tab = limbo_tab; + } + + if (tab->get_num_keys() > 0) { + Table::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; bclear(); + limbo_tab->clear(); + + // import! + int num = bl.length() / sizeof(Extent); + Extent *p = (Extent*)bl.c_str(); + for (int i=0; i