]> git.proxmox.com Git - ceph.git/blob - ceph/src/os/bluestore/HybridAllocator.h
import ceph quincy 17.2.6
[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 dump(std::function<void(uint64_t offset, uint64_t length)> notify) override;
35 void init_rm_free(uint64_t offset, uint64_t length) override;
36 void shutdown() override;
37
38 protected:
39 // intended primarily for UT
40 BitmapAllocator* get_bmap() {
41 return bmap_alloc;
42 }
43 const BitmapAllocator* get_bmap() const {
44 return bmap_alloc;
45 }
46 private:
47
48 void _spillover_range(uint64_t start, uint64_t end) override;
49
50 // called when extent to be released/marked free
51 void _add_to_tree(uint64_t start, uint64_t size) override;
52 };