assert(id < alloc.size());
assert(alloc[id]);
- int64_t got = alloc[id]->allocate(want, cct->_conf->bluefs_alloc_size, 0,
- extents);
+ int64_t got = alloc[id]->allocate(want, alloc_size[id], 0, extents);
+ ceph_assert(got != 0);
if (got < 0) {
derr << __func__ << " failed to allocate space to return to bluestore"
<< dendl;
{
dout(20) << __func__ << dendl;
alloc.resize(MAX_BDEV);
+ alloc_size.resize(MAX_BDEV, 0);
pending_release.resize(MAX_BDEV);
+
+ if (bdev[BDEV_WAL]) {
+ alloc_size[BDEV_WAL] = cct->_conf->bluefs_alloc_size;
+ }
+ if (bdev[BDEV_SLOW]) {
+ alloc_size[BDEV_DB] = cct->_conf->bluefs_alloc_size;
+ alloc_size[BDEV_SLOW] = cct->_conf->bluefs_shared_alloc_size;
+ } else {
+ alloc_size[BDEV_DB] = cct->_conf->bluefs_shared_alloc_size;
+ }
+
for (unsigned id = 0; id < bdev.size(); ++id) {
if (!bdev[id]) {
continue;
name += devnames[id];
else
name += to_string(uintptr_t(this));
+ ceph_assert(alloc_size[id]);
+ dout(20) << __func__ << " id " << id
+ << " alloc_size 0x" << std::hex << alloc_size[id]
+ << " size 0x" << bdev[id]->get_size() << std::dec << dendl;
alloc[id] = Allocator::create(cct, cct->_conf->bluefs_allocator,
bdev[id]->get_size(),
- cct->_conf->bluefs_alloc_size, name);
+ alloc_size[id], name);
interval_set<uint64_t>& p = block_all[id];
for (interval_set<uint64_t>::iterator q = p.begin(); q != p.end(); ++q) {
alloc[id]->init_add_free(q.get_start(), q.get_len());
log_t.clear();
_compact_log_dump_metadata(&t);
+ uint64_t max_alloc_size = std::max(alloc_size[BDEV_WAL],
+ std::max(alloc_size[BDEV_DB],
+ alloc_size[BDEV_SLOW]));
+
// conservative estimate for final encoded size
new_log_jump_to = ROUND_UP_TO(t.op_bl.length() + super.block_size * 2,
- cct->_conf->bluefs_alloc_size);
+ max_alloc_size);
t.op_jump(log_seq, new_log_jump_to);
bufferlist bl;
{
dout(10) << __func__ << " len 0x" << std::hex << len << std::dec
<< " from " << (int)id << dendl;
- assert(id < alloc.size());
- uint64_t min_alloc_size = cct->_conf->bluefs_alloc_size;
-
- uint64_t left = ROUND_UP_TO(len, min_alloc_size);
+ ceph_assert(id < alloc.size());
int64_t alloc_len = 0;
PExtentVector extents;
-
if (alloc[id]) {
uint64_t hint = 0;
if (!node->extents.empty() && node->extents.back().bdev == id) {
hint = node->extents.back().end();
}
extents.reserve(4); // 4 should be (more than) enough for most allocations
- alloc_len = alloc[id]->allocate(left, min_alloc_size, hint, &extents);
+ alloc_len = alloc[id]->allocate(ROUND_UP_TO(len, alloc_size[id]),
+ alloc_size[id], hint, &extents);
}
- if (alloc_len < 0 || alloc_len < (int64_t)left) {
+ if (!alloc[id] ||
+ alloc_len < 0 ||
+ alloc_len < (int64_t)ROUND_UP_TO(len, alloc_size[id])) {
if (alloc_len > 0) {
alloc[id]->release(extents);
}
if (id != BDEV_SLOW) {
if (bdev[id]) {
- dout(1) << __func__ << " failed to allocate 0x" << std::hex << left
+ dout(1) << __func__ << " failed to allocate 0x" << std::hex << len
<< " on bdev " << (int)id
<< ", free 0x" << alloc[id]->get_free()
<< "; fallback to bdev " << (int)id + 1