1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#ifndef CEPH_OS_BLUESTORE_FREELISTMANAGER_H
#define CEPH_OS_BLUESTORE_FREELISTMANAGER_H
#include <string>
#include <vector>
#include <mutex>
#include <ostream>
#include "kv/KeyValueDB.h"
#include "bluestore_types.h"
class FreelistManager {
bool null_manager = false;
public:
CephContext* cct;
explicit FreelistManager(CephContext* cct) : cct(cct) {}
virtual ~FreelistManager() {}
static FreelistManager *create(
CephContext* cct,
std::string type,
std::string prefix);
static void setup_merge_operators(KeyValueDB *db, const std::string &type);
virtual int create(uint64_t size, uint64_t granularity,
uint64_t zone_size, uint64_t first_sequential_zone,
KeyValueDB::Transaction txn) = 0;
virtual int init(KeyValueDB *kvdb, bool db_in_read_only,
std::function<int(const std::string&, std::string*)> cfg_reader) = 0;
virtual void sync(KeyValueDB* kvdb) = 0;
virtual void shutdown() = 0;
virtual void dump(KeyValueDB *kvdb) = 0;
virtual void enumerate_reset() = 0;
virtual bool enumerate_next(KeyValueDB *kvdb, uint64_t *offset, uint64_t *length) = 0;
virtual void allocate(
uint64_t offset, uint64_t length,
KeyValueDB::Transaction txn) = 0;
virtual void release(
uint64_t offset, uint64_t length,
KeyValueDB::Transaction txn) = 0;
virtual uint64_t get_size() const = 0;
virtual uint64_t get_alloc_units() const = 0;
virtual uint64_t get_alloc_size() const = 0;
virtual void get_meta(uint64_t target_size,
std::vector<std::pair<std::string, std::string>>*) const = 0;
void set_null_manager() {
null_manager = true;
}
bool is_null_manager() const {
return null_manager;
}
};
#endif
|