]> git.proxmox.com Git - ceph.git/blob - ceph/src/os/bluestore/FreelistManager.cc
5907df443e00b9a7134f6a569a7d86c3a2aa1413
[ceph.git] / ceph / src / os / bluestore / FreelistManager.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 "FreelistManager.h"
5 #include "BitmapFreelistManager.h"
6 #ifdef HAVE_LIBZBD
7 #include "ZonedFreelistManager.h"
8 #endif
9
10 FreelistManager *FreelistManager::create(
11 CephContext* cct,
12 std::string type,
13 std::string prefix)
14 {
15 // a bit of a hack... we hard-code the prefixes here. we need to
16 // put the freelistmanagers in different prefixes because the merge
17 // op is per prefix, has to done pre-db-open, and we don't know the
18 // freelist type until after we open the db.
19 ceph_assert(prefix == "B");
20 if (type == "bitmap")
21 return new BitmapFreelistManager(cct, "B", "b");
22
23 #ifdef HAVE_LIBZBD
24 // With zoned drives there is only one FreelistManager implementation that we
25 // can use, and we also know if a drive is zoned right after opening it
26 // (BlueStore::_open_bdev). Hence, we set freelist_type to "zoned" whenever
27 // we open the device and it turns out to be is zoned. We ignore |prefix|
28 // passed to create and use the prefixes defined for zoned devices at the top
29 // of BlueStore.cc.
30 if (type == "zoned")
31 return new ZonedFreelistManager(cct, "Z", "z");
32 #endif
33
34 return NULL;
35 }
36
37 void FreelistManager::setup_merge_operators(KeyValueDB *db,
38 const std::string& type)
39 {
40 #ifdef HAVE_LIBZBD
41 if (type == "zoned")
42 ZonedFreelistManager::setup_merge_operator(db, "z");
43 else
44 #endif
45 BitmapFreelistManager::setup_merge_operator(db, "b");
46 }