]> git.proxmox.com Git - ceph.git/blob - ceph/src/os/bluestore/BitMapAllocator.h
a39751d4cf6ad55e7bdf8ece26221d62d3d8f6c3
[ceph.git] / ceph / src / os / bluestore / BitMapAllocator.h
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"
11 #include "include/btree_interval_set.h"
12
13 class BitMapAllocator : public Allocator {
14 CephContext* cct;
15
16 int64_t m_block_size;
17 int64_t m_total_size;
18
19 BitAllocator *m_bit_alloc; // Bit allocator instance
20
21 void insert_free(uint64_t offset, uint64_t len);
22
23 int64_t allocate_dis(
24 uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size,
25 int64_t hint, mempool::bluestore_alloc::vector<AllocExtent> *extents);
26
27 public:
28 BitMapAllocator(CephContext* cct, int64_t device_size, int64_t block_size);
29 ~BitMapAllocator() override;
30
31 int reserve(uint64_t need) override;
32 void unreserve(uint64_t unused) override;
33
34 int64_t allocate(
35 uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size,
36 int64_t hint, mempool::bluestore_alloc::vector<AllocExtent> *extents) override;
37
38 void release(
39 uint64_t offset, uint64_t length) override;
40
41 uint64_t get_free() override;
42
43 void dump() override;
44
45 void init_add_free(uint64_t offset, uint64_t length) override;
46 void init_rm_free(uint64_t offset, uint64_t length) override;
47
48 void shutdown() override;
49 };
50
51 #endif