]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #ifndef CEPH_OS_BLUESTORE_BITMAPALLOCATOR_H | |
5 | #define CEPH_OS_BLUESTORE_BITMAPALLOCATOR_H | |
6 | ||
7 | #include <mutex> | |
8 | ||
9 | #include "Allocator.h" | |
10 | #include "BitAllocator.h" | |
7c673cae FG |
11 | |
12 | class BitMapAllocator : public Allocator { | |
13 | CephContext* cct; | |
14 | ||
15 | int64_t m_block_size; | |
31f18b77 | 16 | int64_t m_total_size; |
7c673cae FG |
17 | |
18 | BitAllocator *m_bit_alloc; // Bit allocator instance | |
19 | ||
20 | void insert_free(uint64_t offset, uint64_t len); | |
21 | ||
22 | int64_t allocate_dis( | |
23 | uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size, | |
24 | int64_t hint, mempool::bluestore_alloc::vector<AllocExtent> *extents); | |
25 | ||
26 | public: | |
27 | BitMapAllocator(CephContext* cct, int64_t device_size, int64_t block_size); | |
28 | ~BitMapAllocator() override; | |
29 | ||
30 | int reserve(uint64_t need) override; | |
31 | void unreserve(uint64_t unused) override; | |
32 | ||
33 | int64_t allocate( | |
34 | uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size, | |
35 | int64_t hint, mempool::bluestore_alloc::vector<AllocExtent> *extents) override; | |
36 | ||
37 | void release( | |
38 | uint64_t offset, uint64_t length) override; | |
39 | ||
40 | uint64_t get_free() override; | |
41 | ||
42 | void dump() override; | |
43 | ||
44 | void init_add_free(uint64_t offset, uint64_t length) override; | |
45 | void init_rm_free(uint64_t offset, uint64_t length) override; | |
46 | ||
47 | void shutdown() override; | |
48 | }; | |
49 | ||
50 | #endif |