]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PG: move bits of delete_dir (pg removal) into PG
authorSage Weil <sage@redhat.com>
Mon, 18 Sep 2017 02:55:27 +0000 (21:55 -0500)
committerSage Weil <sage@redhat.com>
Fri, 6 Oct 2017 18:08:18 +0000 (13:08 -0500)
We don't want to expose things like SnapMapper, OSDriver.

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

index 4aa3fbe985e04d2057d0fd4b89d54c6d6c18ae2e..da4bc3a043a3b423318c2ef2f8156b9a2c304cd4 100644 (file)
@@ -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<ghobject_t> 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) {
index e0456118cf6f2c622b6d9e3eecd7d3c8099a75ce..13b954c3f92c7e8f9374d08df31cdad36e8e70e5 100644 (file)
@@ -8278,3 +8278,13 @@ void PG::with_heartbeat_peers(std::function<void(int)> 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);
+}
index 471edbfc964e84fdf912e87f7a559972167ef2f1..3cf56c9d18d7b58b35c4627f25ed79ad9168c7ac 100644 (file)
@@ -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