From 79124330c7e8b377125dd52e12275cf81b3c38e6 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Thu, 30 Mar 2017 11:17:13 -0700 Subject: [PATCH] osd: too_full_for_backfill() returns ostream for reason Signed-off-by: David Zafman --- src/osd/OSD.cc | 7 ++----- src/osd/OSD.h | 2 +- src/osd/PG.cc | 18 ++++++++---------- src/osd/PrimaryLogPG.cc | 7 +++---- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 7b1a021a2287f..167c0c1ff3ab4 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -823,15 +823,12 @@ bool OSDService::is_full() return cur_state >= FULL; } -bool OSDService::too_full_for_backfill(double *_ratio, double *_max_ratio) +bool OSDService::too_full_for_backfill(ostream &ss) { Mutex::Locker l(full_status_lock); double max_ratio; max_ratio = cct->_conf->osd_backfill_full_ratio; - if (_ratio) - *_ratio = cur_ratio; - if (_max_ratio) - *_max_ratio = max_ratio; + ss << "current usage is " << cur_ratio << ", which is greater than max allowed ratio " << max_ratio; return cur_ratio >= max_ratio; } diff --git a/src/osd/OSD.h b/src/osd/OSD.h index fc60df7c65fcf..e593d552a6b19 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -1155,7 +1155,7 @@ public: bool check_failsafe_full(); bool is_nearfull(); bool is_full(); - bool too_full_for_backfill(double *ratio, double *max_ratio); + bool too_full_for_backfill(ostream &ss); bool need_fullness_update(); ///< osdmap state needs update diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 56b9c19bed8dd..7cee914182016 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -6554,18 +6554,17 @@ boost::statechart::result PG::RecoveryState::RepNotRecovering::react(const RequestBackfillPrio &evt) { PG *pg = context< RecoveryMachine >().pg; - double ratio, max_ratio; + 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(RemoteReservationRejected()); - } else if (pg->osd->too_full_for_backfill(&ratio, &max_ratio) && + } else if (pg->osd->too_full_for_backfill(ss) && !pg->cct->_conf->osd_debug_skip_full_check_in_backfill_reservation) { - ldout(pg->cct, 10) << "backfill reservation rejected: full ratio is " - << ratio << ", which is greater than max allowed ratio " - << max_ratio << dendl; + ldout(pg->cct, 10) << "backfill reservation rejected: " + << ss.str() << dendl; post_event(RemoteReservationRejected()); } else { pg->osd->remote_reserver.request_reservation( @@ -6590,7 +6589,7 @@ PG::RecoveryState::RepWaitBackfillReserved::react(const RemoteBackfillReserved & { PG *pg = context< RecoveryMachine >().pg; - double ratio, max_ratio; + 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: " @@ -6598,11 +6597,10 @@ PG::RecoveryState::RepWaitBackfillReserved::react(const RemoteBackfillReserved & pg->osd->remote_reserver.cancel_reservation(pg->info.pgid); post_event(RemoteReservationRejected()); return discard_event(); - } else if (pg->osd->too_full_for_backfill(&ratio, &max_ratio) && + } else if (pg->osd->too_full_for_backfill(ss) && !pg->cct->_conf->osd_debug_skip_full_check_in_backfill_reservation) { - ldout(pg->cct, 10) << "backfill reservation rejected after reservation: full ratio is " - << ratio << ", which is greater than max allowed ratio " - << max_ratio << dendl; + ldout(pg->cct, 10) << "backfill reservation rejected after reservation: " + << ss.str() << dendl; pg->osd->remote_reserver.cancel_reservation(pg->info.pgid); post_event(RemoteReservationRejected()); return discard_event(); diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 5fd0463401f73..553ffca191e7f 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -3331,10 +3331,9 @@ void PrimaryLogPG::do_scan( switch (m->op) { case MOSDPGScan::OP_SCAN_GET_DIGEST: { - double ratio, full_ratio; - if (osd->too_full_for_backfill(&ratio, &full_ratio)) { - dout(1) << __func__ << ": Canceling backfill, current usage is " - << ratio << ", which exceeds " << full_ratio << dendl; + ostringstream ss; + if (osd->too_full_for_backfill(ss)) { + dout(1) << __func__ << ": Canceling backfill, " << ss.str() << dendl; queue_peering_event( CephPeeringEvtRef( std::make_shared( -- 2.39.5