seastore: fix add_relative to work corretly in case of blk addr

Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
This commit is contained in:
myoungwon oh 2022-05-05 14:55:32 +09:00
parent af1f1e2bec
commit 410e29d188
4 changed files with 18 additions and 24 deletions

View File

@ -217,12 +217,7 @@ struct FixedKVInternalNode
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);
}

View File

@ -1348,13 +1348,7 @@ void Cache::complete_commit(
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();
@ -1543,12 +1537,7 @@ Cache::replay_delta(
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);

View File

@ -39,11 +39,7 @@ void LBALeafNode::resolve_relative_addrs(paddr_t base)
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);
}

View File

@ -683,6 +683,19 @@ struct blk_paddr_t : public paddr_t {
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);
@ -1781,6 +1794,7 @@ inline paddr_t paddr_t::add_offset(int32_t o) const {
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;
}