]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PG: start delete after initial delete start info is applied
authorSage Weil <sage@redhat.com>
Wed, 13 Dec 2017 00:35:55 +0000 (18:35 -0600)
committerSage Weil <sage@redhat.com>
Thu, 11 Jan 2018 23:07:00 +0000 (17:07 -0600)
This allows us to eliminate the flush in _delete_some().

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

index aa4b5555b5d74edb7ae768d554881bdd8421cdfb..9517f77046e0a7632b8a5bc29c122a852f195c76 100644 (file)
@@ -6037,15 +6037,37 @@ void PG::update_store_on_load()
   }
 }
 
+struct C_DeleteMore : public Context {
+  PGRef pg;
+  epoch_t epoch;
+  int count = 2;
+  C_DeleteMore(PG *p, epoch_t e) : pg(p), epoch(e) {}
+  void finish(int r) override {
+    ceph_abort();
+  }
+  void complete(int r) override {
+    assert(r == 0);
+    // complete will be called exactly count times; only the last time will actualy
+    // complete.
+    if (--count) {
+      return;
+    }
+    pg->lock();
+    if (!pg->pg_has_reset_since(epoch)) {
+      pg->osd->queue_for_pg_delete(pg->get_pgid(), epoch);
+    }
+    pg->unlock();
+    delete this;
+  }
+};
 
 void PG::_delete_some()
 {
   dout(10) << __func__ << dendl;
 
-  // this ensures we get a valid result.  it *also* serves to throttle
-  // us a bit (on filestore) because we won't delete more until the
-  // previous deletions are applied.
-  osr->flush();
+  // we do not need to flush here because (1) we only start deleting after
+  // the initial metadata changes are applied and committed, and (2) we do not
+  // process the next chunk until we have applied and committed our work.
 
   vector<ghobject_t> olist;
   ObjectStore::Transaction t;
@@ -6077,27 +6099,6 @@ void PG::_delete_some()
   epoch_t e = get_osdmap()->get_epoch();
   if (num) {
     dout(20) << __func__ << " deleting " << num << " objects" << dendl;
-    struct C_DeleteMore : public Context {
-      PGRef pg;
-      int count = 2;
-      epoch_t epoch;
-      C_DeleteMore(PG *p, epoch_t e) : pg(p), epoch(e) {}
-      void complete(int r) {
-       // complete will be called exactly count times; only the last time will actualy
-       // complete.
-       if (--count) {
-         return;
-       }
-       if (r >= 0) {
-         pg->lock();
-         if (!pg->pg_has_reset_since(epoch)) {
-           pg->osd->queue_for_pg_delete(pg->get_pgid(), epoch);
-         }
-         pg->unlock();
-       }
-       delete this;
-      }
-    };
     Context *fin = new C_DeleteMore(this, e);
     osd->store->queue_transaction(
       osr.get(),
@@ -7974,7 +7975,10 @@ PG::RecoveryState::Deleting::Deleting(my_context ctx)
   ObjectStore::Transaction* t = context<RecoveryMachine>().get_cur_transaction();
   pg->on_removal(t);
   pg->osd->logger->inc(l_osd_pg_removing);
-  pg->osd->queue_for_pg_delete(pg->get_pgid(), pg->get_osdmap()->get_epoch());
+  RecoveryCtx *rctx = context<RecoveryMachine>().get_recovery_ctx();
+  Context *fin = new C_DeleteMore(pg, pg->get_osdmap()->get_epoch());
+  rctx->on_applied->contexts.push_back(fin);
+  rctx->on_safe->contexts.push_back(fin);
 }
 
 boost::statechart::result PG::RecoveryState::Deleting::react(const DeleteSome& evt)
index 4bf83bc2b27e7e75aa6674abf07e20502930bc19..8fe5da84af3f7db2ccef60ca61fd18f751b9da7e 100644 (file)
@@ -1421,6 +1421,7 @@ protected:
   virtual void _split_into(pg_t child_pgid, PG *child, unsigned split_bits) = 0;
 
   friend class C_OSD_RepModify_Commit;
+  friend class C_DeleteMore;
 
   // -- backoff --
   Mutex backoff_lock;  // orders inside Backoff::lock