crimson/os/seastore/lba_manager: convert to seastore logging

Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
This commit is contained in:
Yingxin Cheng 2022-02-07 10:32:52 +08:00
parent c277fdecc5
commit 614088b684
5 changed files with 33 additions and 63 deletions

View File

@ -4,20 +4,11 @@
#include <sys/mman.h>
#include <string.h>
#include "crimson/common/log.h"
#include "crimson/os/seastore/logging.h"
#include "include/buffer.h"
#include "crimson/os/seastore/lba_manager/btree/btree_lba_manager.h"
#include "crimson/os/seastore/lba_manager/btree/lba_btree_node.h"
#include "crimson/os/seastore/lba_manager/btree/lba_btree.h"
namespace {
seastar::logger& logger() {
return crimson::get_logger(ceph_subsys_seastore_lba);
}
}
#include "crimson/os/seastore/logging.h"
SET_SUBSYS(seastore_lba);
@ -146,8 +137,7 @@ BtreeLBAManager::alloc_extent(
return LBABtree::iterate_repeat(
c,
btree.upper_bound_right(c, hint),
[this, &state, len, &t, hint](auto &pos) {
LOG_PREFIX(BtreeLBAManager::alloc_extent);
[this, &state, len, &t, hint, FNAME](auto &pos) {
++stats.num_alloc_extents_iter_nexts;
if (!pos.is_end()) {
DEBUGT("iterate_repeat: pos: {}~{}, state: {}~{}, hint: {}",
@ -219,6 +209,7 @@ static depth_t get_depth(const CachedExtent &e)
void BtreeLBAManager::complete_transaction(
Transaction &t)
{
LOG_PREFIX(BtreeLBAManager::complete_transaction);
std::vector<CachedExtentRef> to_clear;
to_clear.reserve(t.get_retired_set().size());
for (auto &e: t.get_retired_set()) {
@ -232,7 +223,7 @@ void BtreeLBAManager::complete_transaction(
for (auto &e: to_clear) {
auto &pin = get_pin(*e);
logger().debug("{}: retiring {}, {}", __func__, *e, pin);
DEBUGT("retiring {}, {}", t, *e, pin);
pin_set.retire(pin);
}
@ -249,13 +240,13 @@ void BtreeLBAManager::complete_transaction(
[](auto &l, auto &r) -> bool { return get_depth(*l) > get_depth(*r); });
for (auto &e : to_link) {
logger().debug("{}: linking {}", __func__, *e);
DEBUGT("linking {}", t, *e);
pin_set.add_pin(get_pin(*e));
}
for (auto &e: to_clear) {
auto &pin = get_pin(*e);
logger().debug("{}: checking {}, {}", __func__, *e, pin);
DEBUGT("checking {}, {}", t, *e, pin);
pin_set.check_parent(pin);
}
}
@ -353,10 +344,7 @@ BtreeLBAManager::rewrite_extent_ret BtreeLBAManager::rewrite_extent(
assert(!extent->has_been_invalidated());
assert(!extent->is_logical());
logger().debug(
"{}: rewriting {}",
__func__,
*extent);
DEBUGT("rewriting {}", t, *extent);
if (is_lba_node(*extent)) {
auto c = get_context(t);
@ -516,7 +504,8 @@ BtreeLBAManager::update_mapping_ret BtreeLBAManager::update_mapping(
BtreeLBAManager::~BtreeLBAManager()
{
pin_set.scan([](auto &i) {
logger().error("Found {} {} has_ref={}", i, i.get_extent(), i.has_ref());
LOG_PREFIX(BtreeLBAManager::~BtreeLBAManager);
ERROR("Found {} {} has_ref={}", i, i.get_extent(), i.has_ref());
});
}

View File

@ -1,15 +1,10 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#include "crimson/common/log.h"
#include "crimson/os/seastore/lba_manager/btree/btree_range_pin.h"
#include "crimson/os/seastore/logging.h"
namespace {
seastar::logger& logger() {
return crimson::get_logger(ceph_subsys_seastore_lba);
}
}
SET_SUBSYS(seastore_lba);
namespace crimson::os::seastore::lba_manager::btree {
@ -30,10 +25,11 @@ void btree_range_pin_t::take_pin(btree_range_pin_t &other)
btree_range_pin_t::~btree_range_pin_t()
{
LOG_PREFIX(btree_range_pin_t::~btree_range_pin_t);
ceph_assert(!pins == !is_linked());
ceph_assert(!ref);
if (pins) {
logger().debug("{}: removing {}", __func__, *this);
DEBUG("removing {}", *this);
pins->remove_pin(*this, true);
}
extent = nullptr;
@ -46,7 +42,8 @@ void btree_pin_set_t::replace_pin(btree_range_pin_t &to, btree_range_pin_t &from
void btree_pin_set_t::remove_pin(btree_range_pin_t &pin, bool do_check_parent)
{
logger().debug("{}: {}", __func__, pin);
LOG_PREFIX(btree_pin_set_t::remove_pin);
DEBUG("{}", pin);
ceph_assert(pin.is_linked());
ceph_assert(pin.pins);
ceph_assert(!pin.ref);
@ -107,15 +104,14 @@ void btree_pin_set_t::release_if_no_children(btree_range_pin_t &pin)
void btree_pin_set_t::add_pin(btree_range_pin_t &pin)
{
LOG_PREFIX(btree_pin_set_t::add_pin);
ceph_assert(!pin.is_linked());
ceph_assert(!pin.pins);
ceph_assert(!pin.ref);
auto [prev, inserted] = pins.insert(pin);
if (!inserted) {
logger().error(
"{}: unable to add {} ({}), found {} ({})",
__func__,
ERROR("unable to add {} ({}), found {} ({})",
pin,
*(pin.extent),
*prev,
@ -128,16 +124,14 @@ void btree_pin_set_t::add_pin(btree_range_pin_t &pin)
auto *parent = maybe_get_parent(pin.range);
ceph_assert(parent);
if (!parent->has_ref()) {
logger().debug("{}: acquiring parent {}", __func__,
static_cast<void*>(parent));
DEBUG("acquiring parent {}", static_cast<void*>(parent));
parent->acquire_ref();
} else {
logger().debug("{}: parent has ref {}", __func__,
static_cast<void*>(parent));
DEBUG("parent has ref {}", static_cast<void*>(parent));
}
}
if (maybe_get_first_child(pin.range) != nullptr) {
logger().debug("{}: acquiring self {}", __func__, pin);
DEBUG("acquiring self {}", pin);
pin.acquire_ref();
}
}
@ -150,9 +144,10 @@ void btree_pin_set_t::retire(btree_range_pin_t &pin)
void btree_pin_set_t::check_parent(btree_range_pin_t &pin)
{
LOG_PREFIX(btree_pin_set_t::check_parent);
auto parent = maybe_get_parent(pin.range);
if (parent) {
logger().debug("{}: releasing parent {}", __func__, *parent);
DEBUG("releasing parent {}", *parent);
release_if_no_children(*parent);
}
}

View File

@ -1,9 +1,6 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#include "crimson/common/log.h"
#include "crimson/os/seastore/logging.h"
#include "crimson/os/seastore/lba_manager/btree/lba_btree.h"
SET_SUBSYS(seastore_lba);
@ -342,7 +339,7 @@ LBABtree::get_internal_if_live(
laddr_t laddr,
seastore_off_t len)
{
LOG_PREFIX(BtreeLBAManager::get_leaf_if_live);
LOG_PREFIX(LBABtree::get_internal_if_live);
return lower_bound(
c, laddr
).si_then([FNAME, c, addr, laddr, len](auto iter) {
@ -378,7 +375,7 @@ LBABtree::get_leaf_if_live(
laddr_t laddr,
seastore_off_t len)
{
LOG_PREFIX(BtreeLBAManager::get_leaf_if_live);
LOG_PREFIX(LBABtree::get_leaf_if_live);
return lower_bound(
c, laddr
).si_then([FNAME, c, addr, laddr, len](auto iter) {
@ -637,8 +634,7 @@ LBABtree::handle_split_ret LBABtree::handle_split(
/* pos may be either node_position_t<LBALeafNode> or
* node_position_t<LBAInternalNode> */
auto split_level = [&](auto &parent_pos, auto &pos) {
LOG_PREFIX(LBATree::handle_split);
auto split_level = [&, FNAME](auto &parent_pos, auto &pos) {
auto [left, right, pivot] = pos.node->make_split_children(c);
auto parent_node = parent_pos.node;
@ -777,9 +773,8 @@ LBABtree::handle_merge_ret merge_level(
donor_iter.get_val().maybe_relative_to(parent_pos.node->get_paddr()),
begin,
end
).si_then([c, iter, donor_iter, donor_is_left, &parent_pos, &pos](
).si_then([FNAME, c, iter, donor_iter, donor_is_left, &parent_pos, &pos](
typename NodeType::Ref donor) {
LOG_PREFIX(LBABtree::merge_level);
auto [l, r] = donor_is_left ?
std::make_pair(donor, pos.node) : std::make_pair(pos.node, donor);
@ -804,7 +799,6 @@ LBABtree::handle_merge_ret merge_level(
c.cache.retire_extent(c.trans, l);
c.cache.retire_extent(c.trans, r);
} else {
LOG_PREFIX(LBABtree::merge_level);
auto [replacement_l, replacement_r, pivot] =
l->make_balanced(
c,

View File

@ -8,9 +8,8 @@
#include <memory>
#include <string.h>
#include "crimson/common/log.h"
#include "crimson/os/seastore/lba_manager.h"
#include "crimson/os/seastore/logging.h"
#include "crimson/os/seastore/seastore_types.h"
#include "crimson/os/seastore/lba_manager/btree/lba_btree_node.h"

View File

@ -11,12 +11,9 @@
#include "include/byteorder.h"
#include "crimson/os/seastore/lba_manager/btree/lba_btree_node.h"
#include "crimson/os/seastore/logging.h"
namespace {
seastar::logger& logger() {
return crimson::get_logger(ceph_subsys_seastore_lba);
}
}
SET_SUBSYS(seastore_lba);
namespace crimson::os::seastore::lba_manager::btree {
@ -28,13 +25,11 @@ std::ostream &LBAInternalNode::print_detail(std::ostream &out) const
void LBAInternalNode::resolve_relative_addrs(paddr_t base)
{
LOG_PREFIX(LBAInternalNode::resolve_relative_addrs);
for (auto i: *this) {
if (i->get_val().is_relative()) {
auto updated = base.add_relative(i->get_val());
logger().debug(
"LBAInternalNode::resolve_relative_addrs {} -> {}",
i->get_val(),
updated);
DEBUG("{} -> {}", i->get_val(), updated);
i->set_val(updated);
}
}
@ -48,14 +43,12 @@ std::ostream &LBALeafNode::print_detail(std::ostream &out) const
void LBALeafNode::resolve_relative_addrs(paddr_t base)
{
LOG_PREFIX(LBALeafNode::resolve_relative_addrs);
for (auto i: *this) {
if (i->get_val().paddr.is_relative()) {
auto val = i->get_val();
val.paddr = base.add_relative(val.paddr);
logger().debug(
"LBALeafNode::resolve_relative_addrs {} -> {}",
i->get_val().paddr,
val.paddr);
DEBUG("{} -> {}", i->get_val().paddr, val.paddr);
i->set_val(val);
}
}