]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
OSD: clean up revcovery_wq queueing and ref counting
authorSamuel Just <sam.just@inktank.com>
Tue, 3 Jul 2012 15:53:54 +0000 (08:53 -0700)
committerSamuel Just <sam.just@inktank.com>
Fri, 6 Jul 2012 00:18:51 +0000 (17:18 -0700)
Previously, we tended to explicitely remove the pg from the queue uisng
remove_myself on the xlist::item.  This causes us to drop a reference
count.  Manipulating the revovery_wq is now accomplished through the
recovery_wq interface, which also handles pg ref counting.

Signed-off-by: Samuel Just <sam.just@inktank.com>
src/osd/OSD.cc
src/osd/OSD.h

index 388fd2aaa86ebfed523561af08101231dd1dc67f..2c22674c1d783fb779a15efd5510057b0afd8f51 100644 (file)
@@ -4832,7 +4832,6 @@ void OSD::do_recovery(PG *pg)
     pg->lock();
     if (pg->deleting || !(pg->is_active() && pg->is_primary())) {
       pg->unlock();
-      pg->put();
       return;
     }
     
@@ -4860,7 +4859,7 @@ void OSD::do_recovery(PG *pg)
       if (!rctx.query_map->size()) {
        dout(10) << "do_recovery  no luck, giving up on this pg for now" << dendl;
        recovery_wq.lock();
-       pg->recovery_item.remove_myself();      // sigh...
+       recovery_wq._dequeue(pg);
        recovery_wq.unlock();
       }
     }
@@ -4870,7 +4869,6 @@ void OSD::do_recovery(PG *pg)
     pg->unlock();
     dispatch_context(rctx, pg, curmap);
   }
-  pg->put();
 }
 
 void OSD::start_recovery_op(PG *pg, const hobject_t& soid)
@@ -4910,10 +4908,9 @@ void OSD::finish_recovery_op(PG *pg, const hobject_t& soid, bool dequeue)
 #endif
 
   if (dequeue)
-    pg->recovery_item.remove_myself();
+    recovery_wq._dequeue(pg);
   else {
-    pg->get();
-    recovery_queue.push_front(&pg->recovery_item);  // requeue
+    recovery_wq._queue_front(pg);
   }
 
   recovery_wq.kick();
@@ -4926,8 +4923,7 @@ void OSD::defer_recovery(PG *pg)
 
   // move pg to the end of the queue...
   recovery_wq.lock();
-  pg->get();
-  recovery_queue.push_back(&pg->recovery_item);
+  recovery_wq._enqueue(pg);
   recovery_wq.kick();
   recovery_wq.unlock();
 }
index cd9c2a5d8b008d983459d433e91df60f2cbd9e24..7af558150eabcff405987b77857be19f77cb8851 100644 (file)
@@ -980,8 +980,15 @@ protected:
       osd->recovery_queue.pop_front();
       return pg;
     }
+    void _queue_front(PG *pg) {
+      if (!pg->recovery_item.is_on_list()) {
+       pg->get();
+       osd->recovery_queue.push_front(&pg->recovery_item);
+      }
+    }
     void _process(PG *pg) {
       osd->do_recovery(pg);
+      pg->put();
     }
     void _clear() {
       while (!osd->recovery_queue.empty()) {