]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
OSD: split out handle_pg_scrub() from handle_scrub() 9980/head
authorWanlong Gao <wanlong.gao@easystack.cn>
Tue, 28 Jun 2016 07:51:52 +0000 (15:51 +0800)
committerWanlong Gao <wanlong.gao@easystack.cn>
Tue, 28 Jun 2016 07:51:52 +0000 (15:51 +0800)
Signed-off-by: Wanlong Gao <wanlong.gao@easystack.cn>
src/osd/OSD.cc
src/osd/OSD.h

index 15e85ccedce8c98a49654cf6bfac2d117b55f8e3..89a4cc3e4c2c7c6f1c4f8eed8b3b651d099178b2 100644 (file)
@@ -6333,6 +6333,20 @@ void OSD::_dispatch(Message *m)
 
 }
 
+void OSD::handle_pg_scrub(MOSDScrub *m, PG *pg)
+{
+  pg->lock();
+  if (pg->is_primary()) {
+    pg->unreg_next_scrub();
+    pg->scrubber.must_scrub = true;
+    pg->scrubber.must_deep_scrub = m->deep || m->repair;
+    pg->scrubber.must_repair = m->repair;
+    pg->reg_next_scrub();
+    dout(10) << "marking " << *pg << " for scrub" << dendl;
+  }
+  pg->unlock();
+}
+
 void OSD::handle_scrub(MOSDScrub *m)
 {
   dout(10) << "handle_scrub " << *m << dendl;
@@ -6348,38 +6362,16 @@ void OSD::handle_scrub(MOSDScrub *m)
   if (m->scrub_pgs.empty()) {
     for (ceph::unordered_map<spg_t, PG*>::iterator p = pg_map.begin();
         p != pg_map.end();
-        ++p) {
-      PG *pg = p->second;
-      pg->lock();
-      if (pg->is_primary()) {
-       pg->unreg_next_scrub();
-       pg->scrubber.must_scrub = true;
-       pg->scrubber.must_deep_scrub = m->deep || m->repair;
-       pg->scrubber.must_repair = m->repair;
-       pg->reg_next_scrub();
-       dout(10) << "marking " << *pg << " for scrub" << dendl;
-      }
-      pg->unlock();
-    }
+        ++p)
+      handle_pg_scrub(m, p->second);
   } else {
     for (vector<pg_t>::iterator p = m->scrub_pgs.begin();
         p != m->scrub_pgs.end();
         ++p) {
       spg_t pcand;
       if (osdmap->get_primary_shard(*p, &pcand) &&
-         pg_map.count(pcand)) {
-       PG *pg = pg_map[pcand];
-       pg->lock();
-       if (pg->is_primary()) {
-         pg->unreg_next_scrub();
-         pg->scrubber.must_scrub = true;
-         pg->scrubber.must_deep_scrub = m->deep || m->repair;
-         pg->scrubber.must_repair = m->repair;
-         pg->reg_next_scrub();
-         dout(10) << "marking " << *pg << " for scrub" << dendl;
-       }
-       pg->unlock();
-      }
+         pg_map.count(pcand))
+       handle_pg_scrub(m, pg_map[pcand]);
     }
   }
 
index 2b7fe220e097944ec91cf5490452c5b6df0ddb95..189755701c8f094db56ae26d71cbadb31854b984 100644 (file)
@@ -2457,6 +2457,7 @@ private:
   static int write_meta(ObjectStore *store,
                        uuid_d& cluster_fsid, uuid_d& osd_fsid, int whoami);
 
+  void handle_pg_scrub(struct MOSDScrub *m, PG* pg);
   void handle_scrub(struct MOSDScrub *m);
   void handle_osd_ping(class MOSDPing *m);
   void handle_op(OpRequestRef& op, OSDMapRef& osdmap);