void BlueStore::handle_discard(interval_set<uint64_t>& to_release)
{
dout(10) << __func__ << dendl;
- ceph_assert(shared_alloc.a);
- shared_alloc.a->release(to_release);
+ ceph_assert(alloc);
+ alloc->release(to_release);
}
BlueStore::BlueStore(CephContext *cct, const string& path)
int BlueStore::_create_alloc()
{
+ ceph_assert(alloc == NULL);
ceph_assert(shared_alloc.a == NULL);
ceph_assert(bdev->get_size());
allocator_type = "zoned";
}
#endif
-
- shared_alloc.set(
- Allocator::create(
- cct, allocator_type,
- bdev->get_size(),
- alloc_size,
- zone_size,
- first_sequential_zone,
- "block"));
- if (!shared_alloc.a) {
+ alloc = Allocator::create(
+ cct, allocator_type,
+ bdev->get_size(),
+ alloc_size,
+ zone_size,
+ first_sequential_zone,
+ "block");
+ if (!alloc) {
lderr(cct) << __func__ << " failed to create " << allocator_type << " allocator"
<< dendl;
return -EINVAL;
}
+ // BlueFS will share the same allocator
+ shared_alloc.set(alloc);
+
return 0;
}
if (r < 0) {
return r;
}
- ceph_assert(shared_alloc.a != NULL);
+ ceph_assert(alloc != NULL);
#ifdef HAVE_LIBZBD
if (bdev->is_smr()) {
- auto a = dynamic_cast<ZonedAllocator*>(shared_alloc.a);
+ auto a = dynamic_cast<ZonedAllocator*>(alloc);
ceph_assert(a);
auto f = dynamic_cast<ZonedFreelistManager*>(fm);
ceph_assert(f);
dout(1) << __func__
<< " loaded zone pointers: "
<< std::hex
- << ", allocator type " << shared_alloc.a->get_type()
- << ", capacity 0x" << shared_alloc.a->get_capacity()
- << ", block size 0x" << shared_alloc.a->get_block_size()
- << ", free 0x" << shared_alloc.a->get_free()
- << ", fragmentation " << shared_alloc.a->get_fragmentation()
+ << ", allocator type " << alloc->get_type()
+ << ", capacity 0x" << alloc->get_capacity()
+ << ", block size 0x" << alloc->get_block_size()
+ << ", free 0x" << alloc->get_free()
+ << ", fragmentation " << alloc->get_fragmentation()
<< std::dec << dendl;
return 0;
utime_t start_time = ceph_clock_now();
if (!fm->is_null_manager()) {
// This is the original path - loading allocation map from RocksDB and feeding into the allocator
- dout(5) << __func__ << "::NCB::loading allocation from FM -> shared_alloc" << dendl;
+ dout(5) << __func__ << "::NCB::loading allocation from FM -> alloc" << dendl;
// initialize from freelist
fm->enumerate_reset();
uint64_t offset, length;
while (fm->enumerate_next(db, &offset, &length)) {
- shared_alloc.a->init_add_free(offset, length);
+ alloc->init_add_free(offset, length);
++num;
bytes += length;
}
utime_t duration = ceph_clock_now() - start_time;
dout(5) << __func__ << "::num_entries=" << num << " free_size=" << bytes << " alloc_size=" <<
- shared_alloc.a->get_capacity() - bytes << " time=" << duration << " seconds" << dendl;
+ alloc->get_capacity() - bytes << " time=" << duration << " seconds" << dendl;
} else {
// This is the new path reading the allocation map from a flat bluefs file and feeding them into the allocator
return -ENOTSUP; // Operation not supported
}
- if (restore_allocator(shared_alloc.a, &num, &bytes) == 0) {
- dout(5) << __func__ << "::NCB::restore_allocator() completed successfully shared_alloc.a=" << shared_alloc.a << dendl;
+ if (restore_allocator(alloc, &num, &bytes) == 0) {
+ dout(5) << __func__ << "::NCB::restore_allocator() completed successfully alloc=" << alloc << dendl;
} else {
// This must mean that we had an unplanned shutdown and didn't manage to destage the allocator
dout(1) << __func__ << "::NCB::restore_allocator() failed!" << dendl;
dout(1) << __func__
<< " loaded " << byte_u_t(bytes) << " in " << num << " extents"
<< std::hex
- << ", allocator type " << shared_alloc.a->get_type()
- << ", capacity 0x" << shared_alloc.a->get_capacity()
- << ", block size 0x" << shared_alloc.a->get_block_size()
- << ", free 0x" << shared_alloc.a->get_free()
- << ", fragmentation " << shared_alloc.a->get_fragmentation()
+ << ", allocator type " << alloc->get_type()
+ << ", capacity 0x" << alloc->get_capacity()
+ << ", block size 0x" << alloc->get_block_size()
+ << ", free 0x" << alloc->get_free()
+ << ", fragmentation " << alloc->get_fragmentation()
<< std::dec << dendl;
return 0;
bdev->discard_drain();
ceph_assert(shared_alloc.a);
+ ceph_assert(alloc);
+ ceph_assert(alloc == shared_alloc.a);
shared_alloc.a->shutdown();
delete shared_alloc.a;
shared_alloc.reset();
+ alloc = nullptr;
}
int BlueStore::_open_fsid(bool create)
}
reserved = _get_ondisk_reserved();
- shared_alloc.a->init_add_free(reserved,
+ alloc->init_add_free(reserved,
p2align(bdev->get_size(), min_alloc_size) - reserved);
r = _open_db(true);
mounted = false;
- ceph_assert(shared_alloc.a);
+ ceph_assert(alloc);
if (!_kv_only) {
mempool_thread.shutdown();
// GBH - Vault the allocation state
dout(5) << "NCB::BlueStore::umount->store_allocation_state_on_bluestore() " << dendl;
if (was_mounted && fm->is_null_manager()) {
- int ret = store_allocator(shared_alloc.a);
+ int ret = store_allocator(alloc);
if (ret != 0) {
derr << __func__ << "::NCB::store_allocator() failed (continue with bitmapFreelistManager)" << dendl;
_close_db_and_around(false);
#ifdef HAVE_LIBZBD
if (bdev->is_smr()) {
- auto a = dynamic_cast<ZonedAllocator*>(shared_alloc.a);
+ auto a = dynamic_cast<ZonedAllocator*>(alloc);
ceph_assert(a);
auto f = dynamic_cast<ZonedFreelistManager*>(fm);
ceph_assert(f);
continue;
}
PExtentVector exts;
- dout(5) << __func__ << "::NCB::(F)shared_alloc.a=" << shared_alloc.a << ", length=" << e->length << dendl;
+ dout(5) << __func__ << "::NCB::(F)alloc=" << alloc << ", length=" << e->length << dendl;
int64_t alloc_len =
- shared_alloc.a->allocate(e->length, min_alloc_size,
+ alloc->allocate(e->length, min_alloc_size,
0, 0, &exts);
if (alloc_len < 0 || alloc_len < (int64_t)e->length) {
derr << __func__
<< " failed to allocate 0x" << std::hex << e->length
<< " allocated 0x " << (alloc_len < 0 ? 0 : alloc_len)
<< " min_alloc_size 0x" << min_alloc_size
- << " available 0x " << shared_alloc.a->get_free()
+ << " available 0x " << alloc->get_free()
<< std::dec << dendl;
if (alloc_len > 0) {
- shared_alloc.a->release(exts);
+ alloc->release(exts);
}
bypass_rest = true;
break;
<< "~" << it.get_len() << std::dec << dendl;
fm->release(it.get_start(), it.get_len(), txn);
}
- shared_alloc.a->release(to_release);
+ alloc->release(to_release);
to_release.clear();
} // if (it) {
} //if (repair && repairer.preprocess_misreference()) {
// - verify no allocations beyond write pointer
// - verify num_dead_bytes count (neither allocated nor
// free space past the write pointer)
- auto a = dynamic_cast<ZonedAllocator*>(shared_alloc.a);
+ auto a = dynamic_cast<ZonedAllocator*>(alloc);
auto num_zones = bdev->get_size() / zone_size;
// mark the free space past the write pointer
void BlueStore::inject_leaked(uint64_t len)
{
PExtentVector exts;
- int64_t alloc_len = shared_alloc.a->allocate(len, min_alloc_size,
+ int64_t alloc_len = alloc->allocate(len, min_alloc_size,
min_alloc_size * 256, 0, &exts);
if (fm->is_null_manager()) {
buf->omap_allocated =
db->estimate_prefix_size(prefix, string());
- uint64_t bfree = shared_alloc.a->get_free();
+ uint64_t bfree = alloc->get_free();
if (bluefs) {
buf->internally_reserved = 0;
}
dout(10) << __func__ << "(sync) " << txc << " " << std::hex
<< txc->released << std::dec << dendl;
- shared_alloc.a->release(txc->released);
+ alloc->release(txc->released);
}
out:
_reap_collections();
logger->set(l_bluestore_fragmentation,
- (uint64_t)(shared_alloc.a->get_fragmentation() * 1000));
+ (uint64_t)(alloc->get_fragmentation() * 1000));
log_latency("kv_final",
l_bluestore_kv_final_lat,
ceph_assert(!zoned_cleaner_started);
zoned_cleaner_started = true;
zoned_cleaner_cond.notify_all();
- auto a = dynamic_cast<ZonedAllocator*>(shared_alloc.a);
+ auto a = dynamic_cast<ZonedAllocator*>(alloc);
ceph_assert(a);
auto f = dynamic_cast<ZonedFreelistManager*>(fm);
ceph_assert(f);
PExtentVector prealloc;
prealloc.reserve(2 * wctx->writes.size());;
int64_t prealloc_left = 0;
- prealloc_left = shared_alloc.a->allocate(
+ prealloc_left = alloc->allocate(
need, min_alloc_size, need,
0, &prealloc);
if (prealloc_left < 0 || prealloc_left < (int64_t)need) {
- dout(5) << __func__ << "::NCB::failed allocation of " << need << " bytes!! shared_alloc.a=" << shared_alloc.a << dendl;
+ dout(5) << __func__ << "::NCB::failed allocation of " << need << " bytes!! alloc=" << alloc << dendl;
derr << __func__ << " failed to allocate 0x" << std::hex << need
<< " allocated 0x " << (prealloc_left < 0 ? 0 : prealloc_left)
<< " min_alloc_size 0x" << min_alloc_size
- << " available 0x " << shared_alloc.a->get_free()
+ << " available 0x " << alloc->get_free()
<< std::dec << dendl;
if (prealloc.size()) {
- shared_alloc.a->release(prealloc);
+ alloc->release(prealloc);
}
- dout(5) << __func__ << "::NCB::(2)shared_alloc.a=" << shared_alloc.a << dendl;
+ dout(5) << __func__ << "::NCB::(2)alloc=" << alloc << dendl;
return -ENOSPC;
}
_collect_allocation_stats(need, min_alloc_size, prealloc);
}
uint64_t num_entries = 0;
- dout(5) << " calling copy_allocator(bitmap_allocator -> shared_alloc.a)" << dendl;
- copy_allocator(allocator, shared_alloc.a, &num_entries);
+ dout(5) << " calling copy_allocator(bitmap_allocator -> alloc)" << dendl;
+ copy_allocator(allocator, alloc, &num_entries);
delete allocator;
utime_t duration = ceph_clock_now() - start;
dout(5) << " <<<FINISH>>> in " << duration << " seconds, num_entries=" << num_entries << dendl;
}
for (auto itr = bluefs_extents.begin(); itr != bluefs_extents.end(); extent_count++, itr++) {
//dout(5) << "BlueFS[" << extent_count << "] <" << itr.get_start() << "," << itr.get_len() << ">" << dendl;
- allocator->init_rm_free(itr.get_start(), itr.get_len());
+ shared_alloc.a->init_rm_free(itr.get_start(), itr.get_len());
stats.extent_count++;
}
}
dout(5) << "\n" << " <<<FINISH>>> in " << duration << " seconds; extent_count=" << stats.extent_count << dendl;
- dout(5) << "calling compare_allocator(shared_alloc.a) insert_count=" << stats.insert_count << dendl;
- ret = compare_allocators(allocator, shared_alloc.a, stats.insert_count, memory_target);
+ dout(5) << "calling compare_allocator(alloc) insert_count=" << stats.insert_count << dendl;
+ ret = compare_allocators(allocator, alloc, stats.insert_count, memory_target);
if (ret == 0) {
- dout(5) << "SUCCESS!!! compare(allocator, shared_alloc.a)" << dendl;
+ dout(5) << "SUCCESS!!! compare(allocator, alloc)" << dendl;
} else {
- derr << "**** FAILURE compare(allocator, shared_alloc.a)::ret=" << ret << dendl;
+ derr << "**** FAILURE compare(allocator, alloc)::ret=" << ret << dendl;
}
if (test_store_and_restore) {
_close_db_leave_bluefs();
- dout(5) << "calling store_allocator(shared_alloc.a)" << dendl;
- store_allocator(shared_alloc.a);
+ dout(5) << "calling store_allocator(alloc)" << dendl;
+ store_allocator(alloc);
Allocator* alloc2 = create_bitmap_allocator(bdev_size);
if (alloc2) {
dout(5) << "bitmap-allocator=" << alloc2 << dendl;
_close_db_and_around(false); return ret;
}
// verify that we can store and restore allocator to/from drive
- ret = compare_allocators(alloc2, shared_alloc.a, stats.insert_count, memory_target);
+ ret = compare_allocators(alloc2, alloc, stats.insert_count, memory_target);
if (ret == 0) {
- dout(5) << "SUCCESS!!! compare(alloc2, shared_alloc.a)" << dendl;
+ dout(5) << "SUCCESS!!! compare(alloc2, alloc)" << dendl;
} else {
- derr << "**** FAILURE compare(alloc2, shared_alloc.a)::ret=" << ret << dendl;
+ derr << "**** FAILURE compare(alloc2, alloc)::ret=" << ret << dendl;
}
} else {
derr << "******Failed restore_allocator******\n" << dendl;
}
uint64_t num_entries = 0;
- dout(5) << "calling copy_allocator(shared_alloc.a -> bitmap_allocator)" << dendl;
+ dout(5) << "calling copy_allocator(alloc -> bitmap_allocator)" << dendl;
copy_allocator(src_allocator, allocator, &num_entries);
// BlueFS stores its internal allocation outside RocksDB (FM) so we should not destage them to the allcoator-file
// and compare it to the base allocator passed in
int BlueStore::verify_rocksdb_allocations(Allocator *allocator)
{
- dout(5) << "verify that shared_alloc content is identical to FM" << dendl;
+ dout(5) << "verify that alloc content is identical to FM" << dendl;
// initialize from freelist
Allocator* temp_allocator = initialize_allocator_from_freelist(fm);
if (temp_allocator == nullptr) {
}
// start by creating a clone copy of the shared-allocator
- unique_ptr<Allocator> allocator(clone_allocator_without_bluefs(shared_alloc.a));
+ unique_ptr<Allocator> allocator(clone_allocator_without_bluefs(alloc));
if (!allocator) {
return db_cleanup(-1);
}