LOG_PREFIX(FixedKVInternalNode::resolve_relative_addrs);
for (auto i: *this) {
if (i->get_val().is_relative()) {
- paddr_t updated;
- if (base.get_addr_type() == addr_types_t::SEGMENT) {
- updated = base.add_relative(i->get_val());
- } else {
- updated = base.add_offset(i->get_val().as_seg_paddr().get_segment_off());
- }
+ paddr_t updated = base.add_relative(i->get_val());
SUBTRACE(seastore_fixedkv_tree, "{} -> {}", i->get_val(), updated);
i->set_val(updated);
}
bool is_inline = false;
if (i->is_inline()) {
is_inline = true;
- if (final_block_start.get_addr_type() == addr_types_t::SEGMENT) {
- i->set_paddr(final_block_start.add_relative(i->get_paddr()));
- } else if (final_block_start.get_addr_type() ==
- addr_types_t::RANDOM_BLOCK) {
- i->set_paddr(final_block_start.add_offset(
- i->get_paddr().as_seg_paddr().get_segment_off()));
- }
+ i->set_paddr(final_block_start.add_relative(i->get_paddr()));
}
i->last_committed_crc = i->get_crc32c();
i->on_initial_write();
for (auto &alloc_blk : alloc_delta.alloc_blk_ranges) {
if (alloc_blk.paddr.is_relative()) {
assert(alloc_blk.paddr.is_record_relative());
- if (record_base.get_addr_type() == addr_types_t::SEGMENT) {
- alloc_blk.paddr = record_base.add_relative(alloc_blk.paddr);
- } else {
- alloc_blk.paddr = record_base.add_offset(
- alloc_blk.paddr.as_seg_paddr().get_segment_off());
- }
+ alloc_blk.paddr = record_base.add_relative(alloc_blk.paddr);
}
DEBUG("replay alloc_blk {}~{} {}, journal_seq: {}",
alloc_blk.paddr, alloc_blk.len, alloc_blk.laddr, journal_seq);
for (auto i: *this) {
if (i->get_val().paddr.is_relative()) {
auto val = i->get_val();
- if (base.get_addr_type() == addr_types_t::SEGMENT) {
- val.paddr = base.add_relative(val.paddr);
- } else {
- val.paddr = base.add_offset(val.paddr.as_seg_paddr().get_segment_off());
- }
+ val.paddr = base.add_relative(val.paddr);
TRACE("{} -> {}", i->get_val().paddr, val.paddr);
i->set_val(val);
}
return paddr_t::make_blk_paddr(get_device_id(), get_block_off() + o);
}
+ paddr_t add_relative(paddr_t o) const {
+ seastore_off_t off;
+ if (o.get_addr_type() == addr_types_t::SEGMENT) {
+ // segment addr is allocated when alloc_new_extent is called.
+ // But, if random block device is used,
+ // this eventually can be converted to blk addr after submit_record().
+ off = o.as_seg_paddr().get_segment_off();
+ } else {
+ off = o.as_blk_paddr().get_block_off();
+ }
+ return add_offset(off);
+ }
+
private:
void check_blk_off_valid(const block_off_t offset) const {
assert(offset <= BLK_OFF_MAX);
inline paddr_t paddr_t::add_relative(paddr_t o) const {
PADDR_OPERATION(addr_types_t::SEGMENT, seg_paddr_t, add_relative(o))
+ PADDR_OPERATION(addr_types_t::RANDOM_BLOCK, blk_paddr_t, add_relative(o))
ceph_assert(0 == "not supported type");
return P_ADDR_NULL;
}