]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
journaler: asynchronous JournalTrimmer::remove_objects()
authorVenky Shankar <vshankar@redhat.com>
Wed, 6 Jul 2016 16:16:11 +0000 (21:46 +0530)
committerVenky Shankar <vshankar@redhat.com>
Sun, 7 Aug 2016 11:01:36 +0000 (16:31 +0530)
Asynchronous removal of journal objects for a given rbd image.

Signed-off-by: Venky Shankar <vshankar@redhat.com>
src/journal/JournalTrimmer.cc
src/journal/JournalTrimmer.h

index aef16c2fb0acbaf050eccbbc8966515436c48da7..591ce83c22d36eec8abea0d96b90ae688d02349f 100644 (file)
@@ -79,6 +79,37 @@ int JournalTrimmer::remove_objects(bool force) {
   return ctx.wait();
 }
 
+void JournalTrimmer::remove_objects(bool force, Context *on_finish) {
+  ldout(m_cct, 20) << __func__ << dendl;
+
+  on_finish = new FunctionContext([this, force, on_finish](int r) {
+      Mutex::Locker locker(m_lock);
+
+      if (m_remove_set_pending) {
+        on_finish->complete(-EBUSY);
+      }
+
+      if (!force) {
+        JournalMetadata::RegisteredClients registered_clients;
+        m_journal_metadata->get_registered_clients(&registered_clients);
+
+        if (registered_clients.size() == 0) {
+          on_finish->complete(-EINVAL);
+        } else if (registered_clients.size() > 1) {
+          on_finish->complete(-EBUSY);
+        }
+      }
+
+      m_remove_set = std::numeric_limits<uint64_t>::max();
+      m_remove_set_pending = true;
+      m_remove_set_ctx = on_finish;
+
+      remove_set(m_journal_metadata->get_minimum_set());
+    });
+
+  m_async_op_tracker.wait_for_ops(on_finish);
+}
+
 void JournalTrimmer::committed(uint64_t commit_tid) {
   ldout(m_cct, 20) << __func__ << ": commit_tid=" << commit_tid << dendl;
   m_journal_metadata->committed(commit_tid,
index ec76d722cac5e5c6b98e24e07a350fa0653efcaa..41c4a379f77d2b34cb0ff6a309aeec4737f7add7 100644 (file)
@@ -28,6 +28,7 @@ public:
   void shut_down(Context *on_finish);
 
   int remove_objects(bool force);
+  void remove_objects(bool force, Context *on_finish);
   void committed(uint64_t commit_tid);
 
 private: