]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: use rctx transaction for PG removal
authorSage Weil <sage@redhat.com>
Fri, 9 Mar 2018 01:46:03 +0000 (19:46 -0600)
committerSage Weil <sage@redhat.com>
Wed, 4 Apr 2018 13:26:58 +0000 (08:26 -0500)
In the normal case, queue up the removal work on the rctx transaction.

For the final cleanup, since we need to block, dispatch it ourselves, and
do not do so in OSD.cc.

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

index bb000d4a9f0d8da0c7f2d54d107700d0d39402d8..1745f92a6af90532bc95437b9683ae6d6525e13f 100644 (file)
@@ -8187,6 +8187,15 @@ void OSD::dispatch_context(PG::RecoveryCtx &ctx, PG *pg, OSDMapRef curmap,
   }
 }
 
+void OSD::discard_context(PG::RecoveryCtx& ctx)
+{
+  delete ctx.notify_list;
+  delete ctx.query_map;
+  delete ctx.info_map;
+  delete ctx.transaction;
+}
+
+
 /** do_notifies
  * Send an MOSDPGNotify to a primary, with a list of PGs that I have
  * content for, and they are primary for.
@@ -8839,6 +8848,12 @@ void OSD::dequeue_peering_evt(
       advance_pg(curmap->get_epoch(), pg, handle, &rctx);
     }
     pg->do_peering_event(evt, &rctx);
+    if (pg->is_deleted()) {
+      // do not dispatch rctx; the final _delete_some already did it.
+      discard_context(rctx);
+      pg->unlock();
+      return;
+    }
     dispatch_context_transaction(rctx, pg, &handle);
     need_up_thru = pg->get_need_up_thru();
     same_interval_since = pg->get_same_interval_since();
index 27422bb29c8582be57eae3e5fcdf0f3f9f98d0fb..e9a52fd011173d01b031f38a475fec34503ff3e4 100644 (file)
@@ -1977,6 +1977,7 @@ protected:
                         ThreadPool::TPHandle *handle = NULL);
   void dispatch_context_transaction(PG::RecoveryCtx &ctx, PG *pg,
                                     ThreadPool::TPHandle *handle = NULL);
+  void discard_context(PG::RecoveryCtx &ctx);
   void do_notifies(map<int,
                       vector<pair<pg_notify_t, PastIntervals> > >&
                       notify_list,
index c0d608dbda329ff181b6cec304b25ac893086431..9a551656d471bc4fa53dce95c4c8069b77435ce0 100644 (file)
@@ -6483,12 +6483,11 @@ struct C_DeleteMore : public Context {
   }
 };
 
-void PG::_delete_some()
+void PG::_delete_some(ObjectStore::Transaction *t)
 {
   dout(10) << __func__ << dendl;
 
   vector<ghobject_t> olist;
-  ObjectStore::Transaction t;
   int max = std::min(osd->store->get_ideal_list_max(),
                     (int)cct->_conf->osd_target_transaction_size);
   ghobject_t next;
@@ -6501,7 +6500,7 @@ void PG::_delete_some()
     &next);
   dout(20) << __func__ << " " << olist << dendl;
 
-  OSDriver::OSTransaction _t(osdriver.get_transaction(&t));
+  OSDriver::OSTransaction _t(osdriver.get_transaction(t));
   int64_t num = 0;
   for (auto& oid : olist) {
     if (oid.is_pgmeta()) {
@@ -6511,17 +6510,14 @@ void PG::_delete_some()
     if (r != 0 && r != -ENOENT) {
       ceph_abort();
     }
-    t.remove(coll, oid);
+    t->remove(coll, oid);
     ++num;
   }
   epoch_t e = get_osdmap()->get_epoch();
   if (num) {
     dout(20) << __func__ << " deleting " << num << " objects" << dendl;
     Context *fin = new C_DeleteMore(this, e);
-    t.register_on_commit(fin);
-    osd->store->queue_transaction(
-      ch,
-      std::move(t));
+    t->register_on_commit(fin);
   } else {
     dout(20) << __func__ << " finished" << dendl;
     if (cct->_conf->osd_inject_failure_on_pg_removal) {
@@ -6531,13 +6527,12 @@ void PG::_delete_some()
     // final flush here to ensure completions drop refs.  Of particular concern
     // are the SnapMapper ContainerContexts.
     {
-      ObjectStore::Transaction t;
       PGRef pgref(this);
-      PGLog::clear_info_log(info.pgid, &t);
-      t.remove_collection(coll);
-      t.register_on_commit(new ContainerContext<PGRef>(pgref));
-      t.register_on_applied(new ContainerContext<PGRef>(pgref));
-      osd->store->queue_transaction(ch, std::move(t));
+      PGLog::clear_info_log(info.pgid, t);
+      t->remove_collection(coll);
+      t->register_on_commit(new ContainerContext<PGRef>(pgref));
+      t->register_on_applied(new ContainerContext<PGRef>(pgref));
+      osd->store->queue_transaction(ch, std::move(*t));
     }
     ch->flush();
 
@@ -8512,7 +8507,7 @@ boost::statechart::result PG::RecoveryState::Deleting::react(
   const DeleteSome& evt)
 {
   PG *pg = context< RecoveryMachine >().pg;
-  pg->_delete_some();
+  pg->_delete_some(context<RecoveryMachine>().get_cur_transaction());
   return discard_event();
 }
 
index 947c3b14b77c3f89f5bf619c1164d3aa6c128f7e..186703f32e0f4bc425a027ac3db98752306cfcb0 100644 (file)
@@ -477,7 +477,7 @@ public:
 
   virtual void on_removal(ObjectStore::Transaction *t) = 0;
 
-  void _delete_some();
+  void _delete_some(ObjectStore::Transaction *t);
 
   // reference counting
 #ifdef PG_DEBUG_REFS