]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: too_full_for_backfill() returns ostream for reason
authorDavid Zafman <dzafman@redhat.com>
Thu, 30 Mar 2017 18:17:13 +0000 (11:17 -0700)
committerDavid Zafman <dzafman@redhat.com>
Mon, 17 Apr 2017 14:58:30 +0000 (07:58 -0700)
Signed-off-by: David Zafman <dzafman@redhat.com>
src/osd/OSD.cc
src/osd/OSD.h
src/osd/PG.cc
src/osd/PrimaryLogPG.cc

index 7b1a021a2287f957341b13457921ba3b77f48bbd..167c0c1ff3ab4469552f31d12f2c15c3d2c29d31 100644 (file)
@@ -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;
 }
 
index fc60df7c65fcf37c5f971dfdb4d94624b61376f0..e593d552a6b19c931867f133b71a3de63d19165a 100644 (file)
@@ -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
 
 
index 56b9c19bed8ddd23b1105d0ba941196f85936951..7cee9141820160bda4963ebb168f946331b77b48 100644 (file)
@@ -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();
index 5fd0463401f73c99e06b6dca3b66b33c6229d507..553ffca191e7fac9420b0ec28274d8f9ac1bb514 100644 (file)
@@ -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<CephPeeringEvt>(