]> git.proxmox.com Git - ceph.git/blob - ceph/src/os/bluestore/HybridAllocator.h
update ceph source to reef 18.1.2
[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 std::string_view name) :
17 AvlAllocator(cct, device_size, _block_size, max_mem, name) {
18 }
19 const char* get_type() const override
20 {
21 return "hybrid";
22 }
23 int64_t allocate(
24 uint64_t want,
25 uint64_t unit,
26 uint64_t max_alloc_size,
27 int64_t hint,
28 PExtentVector *extents) override;
29 void release(const interval_set<uint64_t>& release_set) override;
30 uint64_t get_free() override;
31 double get_fragmentation() override;
32
33 void dump() override;
34 void foreach(
35 std::function<void(uint64_t offset, uint64_t length)> notify) override;
36 void init_rm_free(uint64_t offset, uint64_t length) override;
37 void shutdown() override;
38
39 protected:
40 // intended primarily for UT
41 BitmapAllocator* get_bmap() {
42 return bmap_alloc;
43 }
44 const BitmapAllocator* get_bmap() const {
45 return bmap_alloc;
46 }
47 private:
48
49 void _spillover_range(uint64_t start, uint64_t end) override;
50
51 // called when extent to be released/marked free
52 void _add_to_tree(uint64_t start, uint64_t size) override;
53 };