From 79e7dbb80c6ee602b2f5869bace3adcad299d6b6 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 17 Sep 2017 21:55:27 -0500 Subject: [PATCH] osd/PG: move bits of delete_dir (pg removal) into PG We don't want to expose things like SnapMapper, OSDriver. Signed-off-by: Sage Weil --- src/osd/OSD.cc | 28 +++++++++------------------- src/osd/PG.cc | 10 ++++++++++ src/osd/PG.h | 1 + 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 4aa3fbe985e04..da4bc3a043a3b 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -5122,21 +5122,20 @@ void TestOpsSocketHook::test_ops(OSDService *service, ObjectStore *store, // ========================================= bool remove_dir( - CephContext *cct, - ObjectStore *store, SnapMapper *mapper, - OSDriver *osdriver, - ObjectStore::Sequencer *osr, - coll_t coll, DeletingStateRef dstate, + PGRef pg, + ObjectStore *store, + DeletingStateRef dstate, bool *finished, ThreadPool::TPHandle &handle) { + CephContext *cct = pg->get_cct(); vector olist; int64_t num = 0; ObjectStore::Transaction t; ghobject_t next; handle.reset_tp_timeout(); store->collection_list( - coll, + pg->coll, next, ghobject_t::get_max(), store->get_ideal_list_max(), @@ -5151,15 +5150,10 @@ bool remove_dir( ++i) { if (i->is_pgmeta()) continue; - OSDriver::OSTransaction _t(osdriver->get_transaction(&t)); - int r = mapper->remove_oid(i->hobj, &_t); - if (r != 0 && r != -ENOENT) { - ceph_abort(); - } - t.remove(coll, *i); + pg->pg_remove_object(*i, &t); if (++num >= cct->_conf->osd_target_transaction_size) { C_SaferCond waiter; - store->queue_transaction(osr, std::move(t), &waiter); + store->queue_transaction(pg->osr.get(), std::move(t), &waiter); cont = dstate->pause_clearing(); handle.suspend_tp_timeout(); waiter.wait(); @@ -5174,7 +5168,7 @@ bool remove_dir( } if (num) { C_SaferCond waiter; - store->queue_transaction(osr, std::move(t), &waiter); + store->queue_transaction(pg->osr.get(), std::move(t), &waiter); cont = dstate->pause_clearing(); handle.suspend_tp_timeout(); waiter.wait(); @@ -5193,8 +5187,6 @@ void OSD::RemoveWQ::_process( { FUNCTRACE(); PGRef pg(item.first); - SnapMapper &mapper = pg->snap_mapper; - OSDriver &driver = pg->osdriver; coll_t coll = coll_t(pg->pg_id); pg->osr->flush(); bool finished = false; @@ -5202,9 +5194,7 @@ void OSD::RemoveWQ::_process( if (!item.second->start_or_resume_clearing()) return; - bool cont = remove_dir( - pg->cct, store, &mapper, &driver, pg->osr.get(), coll, item.second, - &finished, handle); + bool cont = remove_dir(pg, store, item.second, &finished, handle); if (!cont) return; if (!finished) { diff --git a/src/osd/PG.cc b/src/osd/PG.cc index e0456118cf6f2..13b954c3f92c7 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -8278,3 +8278,13 @@ void PG::with_heartbeat_peers(std::function f) } heartbeat_peer_lock.Unlock(); } + +void PG::pg_remove_object(const ghobject_t& oid, ObjectStore::Transaction *t) +{ + OSDriver::OSTransaction _t(osdriver.get_transaction(t)); + int r = snap_mapper.remove_oid(oid.hobj, &_t); + if (r != 0 && r != -ENOENT) { + ceph_abort(); + } + t->remove(coll, oid); +} diff --git a/src/osd/PG.h b/src/osd/PG.h index 471edbfc964e8..3cf56c9d18d7b 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -483,6 +483,7 @@ public: virtual void agent_clear() = 0; virtual void agent_choose_mode_restart() = 0; + void pg_remove_object(const ghobject_t& oid, ObjectStore::Transaction *t); // reference counting #ifdef PG_DEBUG_REFS -- 2.39.5