]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: check pending or active scrub before sched_scrub 3973/head
authorXinze Chi <xmdxcxz@gmail.com>
Fri, 29 May 2015 03:29:38 +0000 (11:29 +0800)
committerXinze Chi <xmdxcxz@gmail.com>
Fri, 29 May 2015 03:29:38 +0000 (11:29 +0800)
Signed-off-by: Xinze Chi <xmdxcxz@gmail.com>
src/osd/OSD.cc
src/osd/OSD.h

index 294272844c4439aecbd46884aefe25c6c09e2399..79fea44beb24c9f2f53acae6411c6576bebaf2ec 100644 (file)
@@ -896,6 +896,21 @@ void OSDService::share_map_peer(int peer, Connection *con, OSDMapRef map)
   }
 }
 
+bool OSDService::can_inc_scrubs_pending()
+{
+  bool can_inc = false;
+  Mutex::Locker l(sched_scrub_lock);
+
+  if (scrubs_pending + scrubs_active < cct->_conf->osd_max_scrubs) {
+    dout(20) << __func__ << scrubs_pending << " -> " << (scrubs_pending+1)
+            << " (max " << cct->_conf->osd_max_scrubs << ", active " << scrubs_active << ")" << dendl;
+    can_inc = true;
+  } else {
+    dout(20) << __func__ << scrubs_pending << " + " << scrubs_active << " active >= max " << cct->_conf->osd_max_scrubs << dendl;
+  }
+
+  return can_inc;
+}
 
 bool OSDService::inc_scrubs_pending()
 {
@@ -5923,6 +5938,11 @@ bool OSD::scrub_load_below_threshold()
 
 void OSD::sched_scrub()
 {
+  // if not permitted, fail fast
+  if (!service.can_inc_scrubs_pending()) {
+    return;
+  }
+
   utime_t now = ceph_clock_now(cct);
   bool time_permit = scrub_time_permit(now);
   bool load_is_low = scrub_load_below_threshold();
index 2cf6819f596b836519696e36ef3d919e7ee85739..5897b865c13abee6a6a3e50bb1ad5fe491511742 100644 (file)
@@ -564,6 +564,7 @@ public:
     return true;
   }
 
+  bool can_inc_scrubs_pending();
   bool inc_scrubs_pending();
   void inc_scrubs_active(bool reserved);
   void dec_scrubs_pending();