From fadb26dc430bac250e3b10ede90ff38efc0c325f Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 30 Aug 2020 16:47:10 +0800 Subject: [PATCH] crimson/osd: use logger() instead of crimson::get_logger(...) for better readability Signed-off-by: Kefu Chai --- .../osd/osd_operations/client_request.cc | 6 +- src/crimson/osd/pg_recovery.cc | 58 +++++++------------ 2 files changed, 23 insertions(+), 41 deletions(-) diff --git a/src/crimson/osd/osd_operations/client_request.cc b/src/crimson/osd/osd_operations/client_request.cc index c14a83a1c47..2b6f6e742b4 100644 --- a/src/crimson/osd/osd_operations/client_request.cc +++ b/src/crimson/osd/osd_operations/client_request.cc @@ -98,12 +98,10 @@ seastar::future<> ClientRequest::start() return seastar::stop_iteration::yes; }).handle_exception_type([](crimson::common::actingset_changed& e) { if (e.is_primary()) { - crimson::get_logger(ceph_subsys_osd).debug( - "operation restart, acting set changed"); + logger().debug("operation restart, acting set changed"); return seastar::stop_iteration::no; } else { - crimson::get_logger(ceph_subsys_osd).debug( - "operation abort, up primary changed"); + logger().debug("operation abort, up primary changed"); return seastar::stop_iteration::yes; } }); diff --git a/src/crimson/osd/pg_recovery.cc b/src/crimson/osd/pg_recovery.cc index aeb4db4ccbe..473be5f9747 100644 --- a/src/crimson/osd/pg_recovery.cc +++ b/src/crimson/osd/pg_recovery.cc @@ -61,8 +61,8 @@ PGRecovery::start_recovery_ops(size_t max_to_start) [this] { bool done = !pg->get_peering_state().needs_recovery(); if (done) { - crimson::get_logger(ceph_subsys_osd).debug("start_recovery_ops: AllReplicasRecovered for pg: {}", - pg->get_pgid()); + logger().debug("start_recovery_ops: AllReplicasRecovered for pg: {}", + pg->get_pgid()); using LocalPeeringEvent = crimson::osd::LocalPeeringEvent; if (!pg->get_peering_state().needs_backfill()) { logger().debug("start_recovery_ops: AllReplicasRecovered for pg: {}", @@ -107,12 +107,10 @@ size_t PGRecovery::start_primary_recovery_ops( const auto &missing = pg->get_peering_state().get_pg_log().get_missing(); - crimson::get_logger(ceph_subsys_osd).info( - "{} recovering {} in pg {}, missing {}", - __func__, - pg->get_recovery_backend()->total_recovering(), - *static_cast(pg), - missing); + logger().info("{} recovering {} in pg {}, missing {}", __func__, + pg->get_recovery_backend()->total_recovering(), + *static_cast(pg), + missing); unsigned started = 0; int skipped = 0; @@ -138,7 +136,7 @@ size_t PGRecovery::start_primary_recovery_ops( hobject_t head = soid.get_head(); - crimson::get_logger(ceph_subsys_osd).info( + logger().info( "{} {} item.need {} {} {} {} {}", __func__, soid, @@ -167,11 +165,7 @@ size_t PGRecovery::start_primary_recovery_ops( pg->get_peering_state().set_last_requested(v); } - crimson::get_logger(ceph_subsys_osd).info( - "{} started {} skipped {}", - __func__, - started, - skipped); + logger().info("{} started {} skipped {}", __func__, started, skipped); return started; } @@ -192,12 +186,10 @@ size_t PGRecovery::start_replica_recovery_ops( assert(peer != pg->get_peering_state().get_primary()); const auto& pm = pg->get_peering_state().get_peer_missing(peer); - crimson::get_logger(ceph_subsys_osd).debug( - "{}: peer osd.{} missing {} objects", __func__, - peer, pm.num_missing()); - crimson::get_logger(ceph_subsys_osd).trace( - "{}: peer osd.{} missing {}", __func__, - peer, pm.get_items()); + logger().debug("{}: peer osd.{} missing {} objects", __func__, + peer, pm.num_missing()); + logger().trace("{}: peer osd.{} missing {}", __func__, + peer, pm.get_items()); // recover oldest first for (auto p = pm.get_rmissing().begin(); @@ -206,15 +198,14 @@ size_t PGRecovery::start_replica_recovery_ops( const auto &soid = p->second; if (pg->get_peering_state().get_missing_loc().is_unfound(soid)) { - crimson::get_logger(ceph_subsys_osd).debug( - "{}: object {} still unfound", __func__, soid); + logger().debug("{}: object {} still unfound", __func__, soid); continue; } const pg_info_t &pi = pg->get_peering_state().get_peer_info(peer); if (soid > pi.last_backfill) { if (!pg->get_recovery_backend()->is_recovering(soid)) { - crimson::get_logger(ceph_subsys_osd).error( + logger().error( "{}: object {} in missing set for backfill (last_backfill {})" " but not in recovering", __func__, @@ -226,14 +217,12 @@ size_t PGRecovery::start_replica_recovery_ops( } if (pg->get_recovery_backend()->is_recovering(soid)) { - crimson::get_logger(ceph_subsys_osd).debug( - "{}: already recovering object {}", __func__, soid); + logger().debug("{}: already recovering object {}", __func__, soid); continue; } if (pg->get_peering_state().get_missing_loc().is_deleted(soid)) { - crimson::get_logger(ceph_subsys_osd).debug( - "{}: soid {} is a delete, removing", __func__, soid); + logger().debug("{}: soid {} is a delete, removing", __func__, soid); map::const_iterator r = pm.get_items().find(soid); started += prep_object_replica_deletes( @@ -244,22 +233,17 @@ size_t PGRecovery::start_replica_recovery_ops( if (soid.is_snap() && pg->get_peering_state().get_pg_log().get_missing().is_missing( soid.get_head())) { - crimson::get_logger(ceph_subsys_osd).debug( - "{}: head {} still missing on primary", - __func__, soid.get_head()); + logger().debug("{}: head {} still missing on primary", __func__, + soid.get_head()); continue; } if (pg->get_peering_state().get_pg_log().get_missing().is_missing(soid)) { - crimson::get_logger(ceph_subsys_osd).debug( - "{}: soid {} still missing on primary", __func__, soid); + logger().debug("{}: soid {} still missing on primary", __func__, soid); continue; } - crimson::get_logger(ceph_subsys_osd).debug( - "{}: recover_object_replicas({})", - __func__, - soid); + logger().debug("{}: recover_object_replicas({})", __func__,soid); map::const_iterator r = pm.get_items().find( soid); started += prep_object_replica_pushes( @@ -351,7 +335,7 @@ void PGRecovery::on_global_recover ( const object_stat_sum_t& stat_diff, const bool is_delete) { - crimson::get_logger(ceph_subsys_osd).info("{} {}", __func__, soid); + logger().info("{} {}", __func__, soid); pg->get_peering_state().object_recovered(soid, stat_diff); auto& recovery_waiter = pg->get_recovery_backend()->get_recovering(soid); if (!is_delete)