From: Sage Weil Date: Fri, 9 Mar 2018 01:46:03 +0000 (-0600) Subject: osd: use rctx transaction for PG removal X-Git-Tag: v13.1.0~390^2~30 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=740b7809af540b4f3fe0cd3c0f05d5a25633ee0c;p=ceph.git osd: use rctx transaction for PG removal 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 --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index bb000d4a9f0..1745f92a6af 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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(); diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 27422bb29c8..e9a52fd0111 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -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 > >& notify_list, diff --git a/src/osd/PG.cc b/src/osd/PG.cc index c0d608dbda3..9a551656d47 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -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 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)); - t.register_on_applied(new ContainerContext(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)); + t->register_on_applied(new ContainerContext(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().get_cur_transaction()); return discard_event(); } diff --git a/src/osd/PG.h b/src/osd/PG.h index 947c3b14b77..186703f32e0 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -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