// and return errors during insert if the max is exceeded.
#define OMAP_INNER_BLOCK_SIZE 8192
#define OMAP_LEAF_BLOCK_SIZE 65536
+#define LOG_LEAF_BLOCK_SIZE 16384
namespace crimson::os::seastore {
{
LOG_PREFIX(BtreeOMapManager::initialize_omap);
DEBUGT("hint: {}", t, hint);
- return tm.alloc_non_data_extent<OMapLeafNode>(t, hint, OMAP_LEAF_BLOCK_SIZE)
+ return tm.alloc_non_data_extent<OMapLeafNode>(t, hint, get_leaf_size(type))
.si_then([hint, &t, type](auto&& root_extent) {
root_extent->set_size(0);
omap_node_meta_t meta{1};
omap_root_t &omap_root,
Transaction &t) final;
+ static extent_len_t get_leaf_size(omap_type_t type) {
+ if (type == omap_type_t::LOG) {
+ return LOG_LEAF_BLOCK_SIZE;
+ }
+ ceph_assert(type == omap_type_t::OMAP ||
+ type == omap_type_t::XATTR);
+ return OMAP_LEAF_BLOCK_SIZE;
+ }
};
using BtreeOMapManagerRef = std::unique_ptr<BtreeOMapManager>;
{
LOG_PREFIX(OMapLeafNode::make_split_children);
DEBUGT("this: {}", oc.t, *this);
- return oc.tm.alloc_extents<OMapLeafNode>(oc.t, oc.hint, OMAP_LEAF_BLOCK_SIZE, 2)
+ return oc.tm.alloc_extents<OMapLeafNode>(oc.t, oc.hint, get_len(), 2)
.si_then([this] (auto &&ext_pair) {
auto left = ext_pair.front();
auto right = ext_pair.back();
ceph_assert(right->get_type() == TYPE);
LOG_PREFIX(OMapLeafNode::make_full_merge);
DEBUGT("this: {}", oc.t, *this);
- return oc.tm.alloc_non_data_extent<OMapLeafNode>(oc.t, oc.hint, OMAP_LEAF_BLOCK_SIZE)
+ return oc.tm.alloc_non_data_extent<OMapLeafNode>(oc.t, oc.hint, get_len())
.si_then([this, right] (auto &&replacement) {
replacement->merge_from(*this, *right->cast<OMapLeafNode>());
return full_merge_ret(
ceph_assert(_right->get_type() == TYPE);
LOG_PREFIX(OMapLeafNode::make_balanced);
DEBUGT("this: {}", oc.t, *this);
- return oc.tm.alloc_extents<OMapLeafNode>(oc.t, oc.hint, OMAP_LEAF_BLOCK_SIZE, 2)
+ return oc.tm.alloc_extents<OMapLeafNode>(oc.t, oc.hint, get_len(), 2)
.si_then([this, _right] (auto &&replacement_pair) {
auto replacement_left = replacement_pair.front();
auto replacement_right = replacement_pair.back();
explicit OMapLeafNode(ceph::bufferptr &&ptr)
: OMapNode(std::move(ptr)) {
- this->set_layout_buf(this->get_bptr().c_str());
+ this->set_layout_buf(this->get_bptr().c_str(), this->get_bptr().length());
}
// Must be identical with OMapLeafNode(ptr) after on_fully_loaded()
explicit OMapLeafNode(extent_len_t length)
: OMapNode(length) {}
OMapLeafNode(const OMapLeafNode &rhs)
: OMapNode(rhs) {
- this->set_layout_buf(this->get_bptr().c_str());
+ this->set_layout_buf(this->get_bptr().c_str(), this->get_bptr().length());
}
omap_node_meta_t get_node_meta() const final { return get_meta(); }
uint32_t get_node_size() { return get_size(); }
void on_fully_loaded() final {
- this->set_layout_buf(this->get_bptr().c_str());
+ this->set_layout_buf(this->get_bptr().c_str(), this->get_bptr().length());
}
CachedExtentRef duplicate_for_write(Transaction&) final {
*/
class StringKVLeafNodeLayout {
char *buf = nullptr;
+ extent_len_t len = 0;
using L = absl::container_internal::Layout<ceph_le32, omap_node_meta_le_t, omap_leaf_key_le_t>;
static constexpr L layout{1, 1, 1}; // = L::Partial(1, 1, 1);
return get_node_key().key_off;
}
auto get_node_val_ptr() const {
- auto tail = node->buf + OMAP_LEAF_BLOCK_SIZE;
+ auto tail = node->buf + node->len;
if (*this == node->iter_end())
return tail;
else {
return (*this - 1)->get_node_val_offset();
}
auto get_right_ptr_end() const {
- return node->buf + OMAP_LEAF_BLOCK_SIZE - get_right_offset_end();
+ return node->buf + node->len - get_right_offset_end();
}
void update_offset(int offset) {
StringKVLeafNodeLayout() : buf(nullptr) {}
- void set_layout_buf(char *_buf) {
+ void set_layout_buf(char *_buf, extent_len_t _len) {
+ assert(_len > 0);
assert(buf == nullptr);
assert(_buf != nullptr);
buf = _buf;
+ len = _len;
}
const_iterator iter_begin() const {
}
uint32_t capacity() const {
- return OMAP_LEAF_BLOCK_SIZE
+ return len
- (reinterpret_cast<char*>(layout.template Pointer<2>(buf))
- reinterpret_cast<char*>(layout.template Pointer<0>(buf)));
}
+ auto get_len() const {
+ assert(len > 0);
+ return len;
+ }
+
bool is_overflow(size_t ksize, size_t vsize) const {
return free_space() < (sizeof(omap_leaf_key_le_t) + ksize + vsize);
}