]>
git.proxmox.com Git - ceph.git/blob - ceph/src/os/bluestore/Allocator.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * This is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2.1, as published by the Free Software
9 * Foundation. See file COPYING.
12 #ifndef CEPH_OS_BLUESTORE_ALLOCATOR_H
13 #define CEPH_OS_BLUESTORE_ALLOCATOR_H
17 #include "include/ceph_assert.h"
18 #include "bluestore_types.h"
22 Allocator(std::string_view name
,
28 * returns allocator type name as per names in config
30 virtual const char* get_type() const = 0;
33 * Allocate required number of blocks in n number of extents.
34 * Min and Max number of extents are limited by:
37 * as no extent can be lesser than block_size and greater than max_alloc size.
38 * Apart from that extents can vary between these lower and higher limits according
39 * to free block search algorithm and availability of contiguous space.
41 virtual int64_t allocate(uint64_t want_size
, uint64_t block_size
,
42 uint64_t max_alloc_size
, int64_t hint
,
43 PExtentVector
*extents
) = 0;
45 int64_t allocate(uint64_t want_size
, uint64_t block_size
,
46 int64_t hint
, PExtentVector
*extents
) {
47 return allocate(want_size
, block_size
, want_size
, hint
, extents
);
50 /* Bulk release. Implementations may override this method to handle the whole
51 * set at once. This could save e.g. unnecessary mutex dance. */
52 virtual void release(const interval_set
<uint64_t>& release_set
) = 0;
53 void release(const PExtentVector
& release_set
);
55 virtual void dump() = 0;
56 virtual void dump(std::function
<void(uint64_t offset
, uint64_t length
)> notify
) = 0;
58 virtual void init_add_free(uint64_t offset
, uint64_t length
) = 0;
59 virtual void init_rm_free(uint64_t offset
, uint64_t length
) = 0;
61 virtual uint64_t get_free() = 0;
62 virtual double get_fragmentation()
66 virtual double get_fragmentation_score();
67 virtual void shutdown() = 0;
69 static Allocator
*create(
71 std::string_view type
,
74 int64_t zone_size
= 0,
75 int64_t firs_sequential_zone
= 0,
76 const std::string_view name
= ""
80 const std::string
& get_name() const;
81 int64_t get_capacity() const
85 int64_t get_block_size() const
92 SocketHook
* asok_hook
= nullptr;
94 const int64_t device_size
= 0;
95 const int64_t block_size
= 0;