]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: add support for removing the journal from disk
authorJason Dillaman <dillaman@redhat.com>
Tue, 14 Jul 2015 18:13:14 +0000 (14:13 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 13 Nov 2015 04:27:05 +0000 (23:27 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/Journal.cc

index e7ec7e37b438e88011af1a7d1dcaabc7e6ab5617..0e5f00eba953952922752d9b8bd302f2b46a1eab 100644 (file)
@@ -78,6 +78,25 @@ int Journal::remove(librados::IoCtx &io_ctx, const std::string &image_id) {
   CephContext *cct = reinterpret_cast<CephContext *>(io_ctx.cct());
   ldout(cct, 5) << __func__ << ": image=" << image_id << dendl;
 
+  // TODO configurable commit flush interval
+  ::journal::Journaler journaler(io_ctx, image_id, "", 5);
+
+  C_SaferCond cond;
+  journaler.init(&cond);
+
+  int r = cond.wait();
+  if (r == -ENOENT) {
+    return 0;
+  } else if (r < 0) {
+    lderr(cct) << "failed to initialize journal: " << cpp_strerror(r) << dendl;
+    return r;
+  }
+
+  r = journaler.remove();
+  if (r < 0) {
+    lderr(cct) << "failed to remove journal: " << cpp_strerror(r) << dendl;
+    return r;
+  }
   return 0;
 }