bluestore/fastbmap_allocator_impl.cc
bluestore/FreelistManager.cc
bluestore/StupidAllocator.cc
- bluestore/BitmapFastAllocator.cc
+ bluestore/BitmapAllocator.cc
)
endif(WITH_BLUESTORE)
#include "Allocator.h"
#include "StupidAllocator.h"
-#include "BitmapFastAllocator.h"
+#include "BitmapAllocator.h"
#include "common/debug.h"
#define dout_subsys ceph_subsys_bluestore
if (type == "stupid") {
return new StupidAllocator(cct);
} else if (type == "bitmap") {
- return new BitmapFastAllocator(cct, size, block_size);
+ return new BitmapAllocator(cct, size, block_size);
}
lderr(cct) << "Allocator::" << __func__ << " unknown alloc type "
<< type << dendl;
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "BitmapAllocator.h"
+
+#define dout_context cct
+#define dout_subsys ceph_subsys_bluestore
+#undef dout_prefix
+#define dout_prefix *_dout << "fbmap_alloc 0x" << this << " "
+
+BitmapAllocator::BitmapAllocator(CephContext* _cct,
+ int64_t capacity,
+ int64_t alloc_unit) :
+ cct(_cct)
+{
+ ldout(cct, 10) << __func__ << " 0x" << std::hex << capacity << "/"
+ << alloc_unit << std::dec << dendl;
+ _init(capacity, alloc_unit, false);
+}
+
+int64_t BitmapAllocator::allocate(
+ uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size,
+ int64_t hint, PExtentVector *extents)
+{
+ uint64_t allocated = 0;
+
+ ldout(cct, 10) << __func__ << std::hex << "0x" << want_size
+ << "/" << alloc_unit << "," << max_alloc_size << "," << hint
+ << std::dec << dendl;
+
+
+ _allocate_l2(want_size, alloc_unit, max_alloc_size, hint,
+ &allocated, extents);
+ if (!allocated) {
+ return -ENOSPC;
+ }
+ for (auto e : *extents) {
+ ldout(cct, 10) << __func__
+ << " 0x" << std::hex << e.offset << "~" << e.length
+ << "/" << alloc_unit << "," << max_alloc_size << "," << hint
+ << std::dec << dendl;
+ }
+ return int64_t(allocated);
+}
+
+void BitmapAllocator::release(
+ const interval_set<uint64_t>& release_set)
+{
+ for (auto r : release_set) {
+ ldout(cct, 10) << __func__ << " 0x" << std::hex << r.first << "~" << r.second
+ << std::dec << dendl;
+ }
+ _free_l2(release_set);
+ ldout(cct, 10) << __func__ << " done" << dendl;
+}
+
+
+void BitmapAllocator::init_add_free(uint64_t offset, uint64_t length)
+{
+ ldout(cct, 10) << __func__ << " 0x" << std::hex << offset << "~" << length
+ << std::dec << dendl;
+
+ auto mas = get_min_alloc_size();
+ uint64_t offs = round_up_to(offset, mas);
+ uint64_t l = p2align(offset + length - offs, mas);
+
+ _mark_free(offs, l);
+ ldout(cct, 10) << __func__ << " done" << dendl;
+}
+void BitmapAllocator::init_rm_free(uint64_t offset, uint64_t length)
+{
+ ldout(cct, 10) << __func__ << " 0x" << std::hex << offset << "~" << length
+ << std::dec << dendl;
+ auto mas = get_min_alloc_size();
+ uint64_t offs = round_up_to(offset, mas);
+ uint64_t l = p2align(offset + length - offs, mas);
+ _mark_allocated(offs, l);
+ ldout(cct, 10) << __func__ << " done" << dendl;
+}
+
+void BitmapAllocator::shutdown()
+{
+ ldout(cct, 1) << __func__ << dendl;
+ _shutdown();
+}
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_OS_BLUESTORE_BITMAPFASTALLOCATOR_H
+#define CEPH_OS_BLUESTORE_BITMAPFASTALLOCATOR_H
+
+#include <mutex>
+
+#include "Allocator.h"
+#include "os/bluestore/bluestore_types.h"
+#include "fastbmap_allocator_impl.h"
+#include "include/mempool.h"
+#include "common/debug.h"
+
+class BitmapAllocator : public Allocator,
+ public AllocatorLevel02<AllocatorLevel01Loose> {
+ CephContext* cct;
+
+public:
+ BitmapAllocator(CephContext* _cct, int64_t capacity, int64_t alloc_unit);
+ ~BitmapAllocator() override
+ {
+ }
+
+
+ int64_t allocate(
+ uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size,
+ int64_t hint, PExtentVector *extents) override;
+
+ void release(
+ const interval_set<uint64_t>& release_set) override;
+
+ uint64_t get_free() override
+ {
+ return get_available();
+ }
+
+ void dump() override
+ {
+ }
+
+ void init_add_free(uint64_t offset, uint64_t length) override;
+ void init_rm_free(uint64_t offset, uint64_t length) override;
+
+ void shutdown() override;
+};
+
+#endif
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#include "BitmapFastAllocator.h"
-
-#define dout_context cct
-#define dout_subsys ceph_subsys_bluestore
-#undef dout_prefix
-#define dout_prefix *_dout << "fbmap_alloc 0x" << this << " "
-
-BitmapFastAllocator::BitmapFastAllocator(CephContext* _cct,
- int64_t capacity,
- int64_t alloc_unit) :
- cct(_cct)
-{
- ldout(cct, 10) << __func__ << " 0x" << std::hex << capacity << "/"
- << alloc_unit << std::dec << dendl;
- _init(capacity, alloc_unit, false);
-}
-
-int64_t BitmapFastAllocator::allocate(
- uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size,
- int64_t hint, PExtentVector *extents)
-{
- uint64_t allocated = 0;
-
- ldout(cct, 10) << __func__ << std::hex << "0x" << want_size
- << "/" << alloc_unit << "," << max_alloc_size << "," << hint
- << std::dec << dendl;
-
-
- _allocate_l2(want_size, alloc_unit, max_alloc_size, hint,
- &allocated, extents);
- if (!allocated) {
- return -ENOSPC;
- }
- for (auto e : *extents) {
- ldout(cct, 10) << __func__
- << " 0x" << std::hex << e.offset << "~" << e.length
- << "/" << alloc_unit << "," << max_alloc_size << "," << hint
- << std::dec << dendl;
- }
- return int64_t(allocated);
-}
-
-void BitmapFastAllocator::release(
- const interval_set<uint64_t>& release_set)
-{
- for (auto r : release_set) {
- ldout(cct, 10) << __func__ << " 0x" << std::hex << r.first << "~" << r.second
- << std::dec << dendl;
- }
- _free_l2(release_set);
- ldout(cct, 10) << __func__ << " done" << dendl;
-}
-
-
-void BitmapFastAllocator::init_add_free(uint64_t offset, uint64_t length)
-{
- ldout(cct, 10) << __func__ << " 0x" << std::hex << offset << "~" << length
- << std::dec << dendl;
-
- auto mas = get_min_alloc_size();
- uint64_t offs = round_up_to(offset, mas);
- uint64_t l = p2align(offset + length - offs, mas);
-
- _mark_free(offs, l);
- ldout(cct, 10) << __func__ << " done" << dendl;
-}
-void BitmapFastAllocator::init_rm_free(uint64_t offset, uint64_t length)
-{
- ldout(cct, 10) << __func__ << " 0x" << std::hex << offset << "~" << length
- << std::dec << dendl;
- auto mas = get_min_alloc_size();
- uint64_t offs = round_up_to(offset, mas);
- uint64_t l = p2align(offset + length - offs, mas);
- _mark_allocated(offs, l);
- ldout(cct, 10) << __func__ << " done" << dendl;
-}
-
-void BitmapFastAllocator::shutdown()
-{
- ldout(cct, 1) << __func__ << dendl;
- _shutdown();
-}
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#ifndef CEPH_OS_BLUESTORE_BITMAPFASTALLOCATOR_H
-#define CEPH_OS_BLUESTORE_BITMAPFASTALLOCATOR_H
-
-#include <mutex>
-
-#include "Allocator.h"
-#include "os/bluestore/bluestore_types.h"
-#include "fastbmap_allocator_impl.h"
-#include "include/mempool.h"
-#include "common/debug.h"
-
-class BitmapFastAllocator : public Allocator,
- public AllocatorLevel02<AllocatorLevel01Loose> {
- CephContext* cct;
-
-public:
- BitmapFastAllocator(CephContext* _cct, int64_t capacity, int64_t alloc_unit);
- ~BitmapFastAllocator() override
- {
- }
-
-
- int64_t allocate(
- uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size,
- int64_t hint, PExtentVector *extents) override;
-
- void release(
- const interval_set<uint64_t>& release_set) override;
-
- uint64_t get_free() override
- {
- return get_available();
- }
-
- void dump() override
- {
- }
-
- void init_add_free(uint64_t offset, uint64_t length) override;
- void init_rm_free(uint64_t offset, uint64_t length) override;
-
- void shutdown() override;
-};
-
-#endif