From: Mark Nelson Date: Sun, 4 Feb 2018 20:35:18 +0000 (-0600) Subject: OSD: don't process ostream strings when not debugging. X-Git-Tag: v13.1.0~434^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=36b94df6ad93ac55d3fb9c539cd4683c2ebaec4f;p=ceph.git OSD: don't process ostream strings when not debugging. Signed-off-by: Mark Nelson --- diff --git a/src/osd/ECBackend.cc b/src/osd/ECBackend.cc index a5d9736b8817..4aed9e54592a 100644 --- a/src/osd/ECBackend.cc +++ b/src/osd/ECBackend.cc @@ -285,9 +285,8 @@ void ECBackend::handle_recovery_push( const PushOp &op, RecoveryMessages *m) { - ostringstream ss; - if (get_parent()->check_failsafe_full(ss)) { - dout(10) << __func__ << " Out of space (failsafe) processing push request: " << ss.str() << dendl; + if (get_parent()->check_failsafe_full()) { + dout(10) << __func__ << " Out of space (failsafe) processing push request." << dendl; ceph_abort(); } diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 78f9a6584125..92c981a09ec8 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -860,7 +860,7 @@ bool OSDService::need_fullness_update() return want != cur; } -bool OSDService::_check_full(s_names type, ostream &ss) const +bool OSDService::_check_full(DoutPrefixProvider *dpp, s_names type) const { Mutex::Locker l(full_status_lock); @@ -869,33 +869,34 @@ bool OSDService::_check_full(s_names type, ostream &ss) const // or if -1 then always return full if (injectfull > 0) --injectfull; - ss << "Injected " << get_full_state_name(type) << " OSD (" - << (injectfull < 0 ? "set" : std::to_string(injectfull)) << ")"; + ldpp_dout(dpp, 10) << __func__ << " Injected " << get_full_state_name(type) << " OSD (" + << (injectfull < 0 ? "set" : std::to_string(injectfull)) << ")" + << dendl; return true; } + ldpp_dout(dpp, 10) << __func__ << " current usage is " << cur_ratio << dendl; - ss << "current usage is " << cur_ratio; return cur_state >= type; } -bool OSDService::check_failsafe_full(ostream &ss) const +bool OSDService::check_failsafe_full(DoutPrefixProvider *dpp) const { - return _check_full(FAILSAFE, ss); + return _check_full(dpp, FAILSAFE); } -bool OSDService::check_full(ostream &ss) const +bool OSDService::check_full(DoutPrefixProvider *dpp) const { - return _check_full(FULL, ss); + return _check_full(dpp, FULL); } -bool OSDService::check_backfill_full(ostream &ss) const +bool OSDService::check_backfill_full(DoutPrefixProvider *dpp) const { - return _check_full(BACKFILLFULL, ss); + return _check_full(dpp, BACKFILLFULL); } -bool OSDService::check_nearfull(ostream &ss) const +bool OSDService::check_nearfull(DoutPrefixProvider *dpp) const { - return _check_full(NEARFULL, ss); + return _check_full(dpp, NEARFULL); } bool OSDService::is_failsafe_full() const diff --git a/src/osd/OSD.h b/src/osd/OSD.h index ee94a5032070..9ac969ee90d0 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -1015,12 +1015,12 @@ private: s_names injectfull_state = NONE; float get_failsafe_full_ratio(); void check_full_status(float ratio); - bool _check_full(s_names type, ostream &ss) const; + bool _check_full(DoutPrefixProvider *dpp, s_names type) const; public: - bool check_failsafe_full(ostream &ss) const; - bool check_full(ostream &ss) const; - bool check_backfill_full(ostream &ss) const; - bool check_nearfull(ostream &ss) const; + bool check_failsafe_full(DoutPrefixProvider *dpp) const; + bool check_full(DoutPrefixProvider *dpp) const; + bool check_backfill_full(DoutPrefixProvider *dpp) const; + bool check_nearfull(DoutPrefixProvider *dpp) const; bool is_failsafe_full() const; bool is_full() const; bool is_backfillfull() const; diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 80cddeb90fb6..e5a2d40407ce 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -7040,17 +7040,15 @@ boost::statechart::result PG::RecoveryState::RepNotRecovering::react(const RequestBackfillPrio &evt) { PG *pg = context< RecoveryMachine >().pg; - ostringstream ss; - if (pg->cct->_conf->osd_debug_reject_backfill_probability > 0 && (rand()%1000 < (pg->cct->_conf->osd_debug_reject_backfill_probability*1000.0))) { ldout(pg->cct, 10) << "backfill reservation rejected: failure injection" << dendl; post_event(RejectRemoteReservation()); } else if (!pg->cct->_conf->osd_debug_skip_full_check_in_backfill_reservation && - pg->osd->check_backfill_full(ss)) { - ldout(pg->cct, 10) << "backfill reservation rejected: " - << ss.str() << dendl; + pg->osd->check_backfill_full(pg)) { + ldout(pg->cct, 10) << "backfill reservation rejected: backfill full" + << dendl; post_event(RejectRemoteReservation()); } else { Context *preempt = nullptr; @@ -7111,7 +7109,6 @@ PG::RecoveryState::RepWaitBackfillReserved::react(const RemoteBackfillReserved & { PG *pg = context< RecoveryMachine >().pg; - ostringstream ss; if (pg->cct->_conf->osd_debug_reject_backfill_probability > 0 && (rand()%1000 < (pg->cct->_conf->osd_debug_reject_backfill_probability*1000.0))) { ldout(pg->cct, 10) << "backfill reservation rejected after reservation: " @@ -7119,9 +7116,9 @@ PG::RecoveryState::RepWaitBackfillReserved::react(const RemoteBackfillReserved & post_event(RejectRemoteReservation()); return discard_event(); } else if (!pg->cct->_conf->osd_debug_skip_full_check_in_backfill_reservation && - pg->osd->check_backfill_full(ss)) { - ldout(pg->cct, 10) << "backfill reservation rejected after reservation: " - << ss.str() << dendl; + pg->osd->check_backfill_full(pg)) { + ldout(pg->cct, 10) << "backfill reservation rejected after reservation: backfill full" + << dendl; post_event(RejectRemoteReservation()); return discard_event(); } else { diff --git a/src/osd/PG.h b/src/osd/PG.h index fe092a4ae38c..c13a8b32ef0a 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -490,7 +490,6 @@ public: return ref; } - // ctor PG(OSDService *o, OSDMapRef curmap, const PGPool &pool, spg_t p); diff --git a/src/osd/PGBackend.h b/src/osd/PGBackend.h index 7db632ed6443..546d671e26a9 100644 --- a/src/osd/PGBackend.h +++ b/src/osd/PGBackend.h @@ -287,7 +287,7 @@ typedef ceph::shared_ptr OSDMapRef; virtual LogClientTemp clog_error() = 0; virtual LogClientTemp clog_warn() = 0; - virtual bool check_failsafe_full(ostream &ss) = 0; + virtual bool check_failsafe_full() = 0; virtual bool check_osdmap_full(const set &missing_on) = 0; diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index c3c62f01aecd..292325ffeadf 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -1987,11 +1987,9 @@ void PrimaryLogPG::do_op(OpRequestRef& op) // mds should have stopped writing before this point. // We can't allow OSD to become non-startable even if mds // could be writing as part of file removals. - ostringstream ss; - if (write_ordered && osd->check_failsafe_full(ss) && !m->has_flag(CEPH_OSD_FLAG_FULL_TRY)) { - dout(10) << __func__ << " fail-safe full check failed, dropping request" - << ss.str() - << dendl; + if (write_ordered && osd->check_failsafe_full(get_dpp()) && + !m->has_flag(CEPH_OSD_FLAG_FULL_TRY)) { + dout(10) << __func__ << " fail-safe full check failed, dropping request." << dendl; return; } int64_t poolid = get_pgid().pool(); @@ -3997,9 +3995,9 @@ void PrimaryLogPG::do_scan( switch (m->op) { case MOSDPGScan::OP_SCAN_GET_DIGEST: { - ostringstream ss; - if (osd->check_backfill_full(ss)) { - dout(1) << __func__ << ": Canceling backfill, " << ss.str() << dendl; + auto dpp = get_dpp(); + if (osd->check_backfill_full(dpp)) { + dout(1) << __func__ << ": Canceling backfill: Full." << dendl; queue_peering_event( PGPeeringEventRef( std::make_shared( @@ -15087,8 +15085,8 @@ int PrimaryLogPG::getattrs_maybe_cache( return r; } -bool PrimaryLogPG::check_failsafe_full(ostream &ss) { - return osd->check_failsafe_full(ss); +bool PrimaryLogPG::check_failsafe_full() { + return osd->check_failsafe_full(get_dpp()); } void intrusive_ptr_add_ref(PrimaryLogPG *pg) { pg->get("intptr"); } diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index 9cceb28d1c07..157e24d64efb 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -1840,7 +1840,7 @@ public: void on_removal(ObjectStore::Transaction *t) override; void shutdown() override; void on_shutdown(); - bool check_failsafe_full(ostream &ss) override; + bool check_failsafe_full() override; bool check_osdmap_full(const set &missing_on) override; bool maybe_preempt_replica_scrub(const hobject_t& oid) override { return write_blocked_by_scrub(oid); diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc index 10a7aadaf692..5332a8963999 100644 --- a/src/osd/ReplicatedBackend.cc +++ b/src/osd/ReplicatedBackend.cc @@ -802,9 +802,8 @@ void ReplicatedBackend::_do_push(OpRequestRef op) vector replies; ObjectStore::Transaction t; - ostringstream ss; - if (get_parent()->check_failsafe_full(ss)) { - dout(10) << __func__ << " Out of space (failsafe) processing push request: " << ss.str() << dendl; + if (get_parent()->check_failsafe_full()) { + dout(10) << __func__ << " Out of space (failsafe) processing push request." << dendl; ceph_abort(); } for (vector::const_iterator i = m->pushes.begin(); @@ -868,10 +867,8 @@ void ReplicatedBackend::_do_pull_response(OpRequestRef op) op->mark_started(); vector replies(1); - - ostringstream ss; - if (get_parent()->check_failsafe_full(ss)) { - dout(10) << __func__ << " Out of space (failsafe) processing pull response (push): " << ss.str() << dendl; + if (get_parent()->check_failsafe_full()) { + dout(10) << __func__ << " Out of space (failsafe) processing pull response (push)." << dendl; ceph_abort(); }