]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: move recovery contexts to normal wq
authorSage Weil <sage@redhat.com>
Tue, 16 Jan 2018 22:42:28 +0000 (16:42 -0600)
committerSage Weil <sage@redhat.com>
Wed, 4 Apr 2018 13:26:49 +0000 (08:26 -0500)
We have a specific PGRecoveryContext type/event--even though we are just
calling a GenContext--so that we can distinguish the event type properly.

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSD.cc
src/osd/OSD.h
src/osd/OpQueueItem.cc
src/osd/OpQueueItem.h
src/osd/PrimaryLogPG.cc

index e882f342c3906a2bdd220bc447aa1710856df8a3..6d529e8cab8b8d5ae774a1ec10903d33b8eef6ac 100644 (file)
@@ -1691,6 +1691,22 @@ void OSDService::enqueue_front(OpQueueItem&& qi)
   osd->op_shardedwq.queue_front(std::move(qi));
 }
 
+void OSDService::queue_recovery_context(
+  PG *pg,
+  GenContext<ThreadPool::TPHandle&> *c)
+{
+  epoch_t e = get_osdmap()->get_epoch();
+  enqueue_back(
+    OpQueueItem(
+      unique_ptr<OpQueueItem::OpQueueable>(
+       new PGRecoveryContext(pg->get_pgid(), c, e)),
+      cct->_conf->osd_recovery_cost,
+      cct->_conf->osd_recovery_priority,
+      ceph_clock_now(),
+      0,
+      e));
+}
+
 void OSDService::queue_for_snap_trim(PG *pg)
 {
   dout(10) << "queueing " << *pg << " for snaptrim" << dendl;
index da17b9e85a1c4fdfcc87f59d397fe6c1c26d58ed..f9be95ceb098e472a4384dafd4cc7045732bbe08 100644 (file)
@@ -796,6 +796,7 @@ public:
   SafeTimer scrub_sleep_timer;
 
   AsyncReserver<spg_t> snap_reserver;
+  void queue_recovery_context(PG *pg, GenContext<ThreadPool::TPHandle&> *c);
   void queue_for_snap_trim(PG *pg);
   void queue_for_scrub(PG *pg, bool with_high_priority);
   void queue_for_pg_delete(spg_t pgid, epoch_t e);
index 5e2bda20b8709a5cca4a99979a97ad0f9e325dde..6a0560d7c934ffc02bcaaa17b0593916337ffcd6 100644 (file)
@@ -55,6 +55,15 @@ void PGRecovery::run(OSD *osd,
   pg->unlock();
 }
 
+void PGRecoveryContext::run(
+  OSD *osd,
+  PGRef& pg,
+  ThreadPool::TPHandle &handle)
+{
+  c.release()->complete(handle);
+  pg->unlock();
+}
+
 void PGDelete::run(
   OSD *osd,
   PGRef& pg,
@@ -62,4 +71,3 @@ void PGDelete::run(
 {
   osd->dequeue_delete(pg.get(), epoch_queued, handle);
 }
-
index fe3f66296adfc21eeee51f9a154565eb0b7e4dc6..b55114ae32ed7a6bcd599e91af9619891af9dba6 100644 (file)
@@ -298,6 +298,26 @@ public:
     OSD *osd, PGRef& pg, ThreadPool::TPHandle &handle) override final;
 };
 
+class PGRecoveryContext : public PGOpQueueable {
+  unique_ptr<GenContext<ThreadPool::TPHandle&>> c;
+  epoch_t epoch;
+public:
+  PGRecoveryContext(spg_t pgid,
+                   GenContext<ThreadPool::TPHandle&> *c, epoch_t epoch)
+    : PGOpQueueable(pgid),
+      c(c), epoch(epoch) {}
+  op_type_t get_op_type() const override final {
+    return op_type_t::bg_recovery;
+  }
+  ostream &print(ostream &rhs) const override final {
+    return rhs << "PGRecoveryContext(pgid=" << get_pgid()
+              << " c=" << c.get() << " epoch=" << epoch
+              << ")";
+  }
+  void run(
+    OSD *osd, PGRef& pg, ThreadPool::TPHandle &handle) override final;
+};
+
 class PGDelete : public PGOpQueueable {
   epoch_t epoch_queued;
 public:
index 9e711a571f677d24047699805f6646d8e436e6f5..9198238d3843949e17228b8e304f293ef551549f 100644 (file)
@@ -485,7 +485,7 @@ void PrimaryLogPG::begin_peer_recover(
 void PrimaryLogPG::schedule_recovery_work(
   GenContext<ThreadPool::TPHandle&> *c)
 {
-  osd->recovery_gen_wq.queue(c);
+  osd->queue_recovery_context(this, c);
 }
 
 void PrimaryLogPG::send_message_osd_cluster(