]> git.proxmox.com Git - ceph.git/blob - ceph/src/os/bluestore/Allocator.cc
buildsys: auto-determine current version for makefile
[ceph.git] / ceph / src / os / bluestore / Allocator.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #include "Allocator.h"
5 #include "StupidAllocator.h"
6 #include "BitmapAllocator.h"
7 #include "common/debug.h"
8
9 #define dout_subsys ceph_subsys_bluestore
10
11 Allocator *Allocator::create(CephContext* cct, string type,
12 int64_t size, int64_t block_size)
13 {
14 if (type == "stupid") {
15 return new StupidAllocator(cct);
16 } else if (type == "bitmap") {
17 return new BitmapAllocator(cct, size, block_size);
18 }
19 lderr(cct) << "Allocator::" << __func__ << " unknown alloc type "
20 << type << dendl;
21 return nullptr;
22 }
23
24 void Allocator::release(const PExtentVector& release_vec)
25 {
26 interval_set<uint64_t> release_set;
27 for (auto e : release_vec) {
28 release_set.insert(e.offset, e.length);
29 }
30 release(release_set);
31 }