]> git.proxmox.com Git - ceph.git/blob - ceph/src/os/bluestore/HybridAllocator.h
import 15.2.4
[ceph.git] / ceph / src / os / bluestore / HybridAllocator.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #pragma once
5
6 #include <mutex>
7
8 #include "AvlAllocator.h"
9 #include "BitmapAllocator.h"
10
11 class HybridAllocator : public AvlAllocator {
12 BitmapAllocator* bmap_alloc = nullptr;
13 public:
14 HybridAllocator(CephContext* cct, int64_t device_size, int64_t _block_size,
15 uint64_t max_mem,
16 const std::string& name) :
17 AvlAllocator(cct, device_size, _block_size, max_mem, name) {
18 }
19 int64_t allocate(
20 uint64_t want,
21 uint64_t unit,
22 uint64_t max_alloc_size,
23 int64_t hint,
24 PExtentVector *extents) override;
25 void release(const interval_set<uint64_t>& release_set) override;
26 uint64_t get_free() override;
27 double get_fragmentation() override;
28
29 void dump() override;
30 void dump(std::function<void(uint64_t offset, uint64_t length)> notify) override;
31 void init_rm_free(uint64_t offset, uint64_t length) override;
32 void shutdown() override;
33
34 protected:
35 // intended primarily for UT
36 BitmapAllocator* get_bmap() {
37 return bmap_alloc;
38 }
39 const BitmapAllocator* get_bmap() const {
40 return bmap_alloc;
41 }
42 private:
43
44 void _spillover_range(uint64_t start, uint64_t end) override;
45
46 // called when extent to be released/marked free
47 void _add_to_tree(uint64_t start, uint64_t size) override;
48 };