]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: journal reset should disable/re-enable journaling feature 8490/head
authorJason Dillaman <dillaman@redhat.com>
Thu, 7 Apr 2016 19:39:06 +0000 (15:39 -0400)
committerJason Dillaman <dillaman@redhat.com>
Thu, 7 Apr 2016 19:39:06 +0000 (15:39 -0400)
Fixes: http://tracker.ceph.com/issues/15097
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/tools/Makefile-client.am
src/tools/rbd/action/Journal.cc

index 509cba36eb8179394b31bd3857d2056cd1dd73cb..0b8154982f0a1cdaa81c6e0b89c1991b144003b8 100644 (file)
@@ -71,6 +71,7 @@ noinst_HEADERS += \
        tools/rbd/Utils.h
 rbd_LDADD = \
        libjournal.la libcls_journal_client.la \
+       libcls_rbd_client.la libcls_lock_client.la \
        $(LIBRBD) $(LIBRBD_TYPES) $(LIBRADOS) $(CEPH_GLOBAL) \
        $(BOOST_REGEX_LIBS) $(BOOST_PROGRAM_OPTIONS_LIBS)
 if LINUX
index 299568484d4b7defab9b5792f60b6daed88c8715..e82265ca471cbb03ef764e30fec78aff22fd5aa8 100644 (file)
 #include <fstream>
 #include <sstream>
 #include <boost/program_options.hpp>
-
+#include "cls/rbd/cls_rbd_client.h"
 #include "cls/journal/cls_journal_types.h"
 #include "cls/journal/cls_journal_client.h"
 
 #include "journal/Journaler.h"
 #include "journal/ReplayEntry.h"
 #include "journal/ReplayHandler.h"
-//#include "librbd/Journal.h" // XXXMG: for librbd::Journal::reset()
 #include "librbd/journal/Types.h"
 
 namespace rbd {
@@ -134,40 +133,35 @@ static int do_show_journal_status(librados::IoCtx& io_ctx,
 static int do_reset_journal(librados::IoCtx& io_ctx,
                            const std::string& journal_id)
 {
-  // XXXMG: does not work due to a linking issue
-  //return librbd::Journal::reset(io_ctx, journal_id);
-
-  ::journal::Journaler journaler(io_ctx, journal_id, "", 5);
-
-  C_SaferCond cond;
-  journaler.init(&cond);
-
-  int r = cond.wait();
+  // disable/re-enable journaling to delete/re-create the journal
+  // to properly handle mirroring constraints
+  std::string image_name;
+  int r = librbd::cls_client::dir_get_name(&io_ctx, RBD_DIRECTORY, journal_id,
+                                           &image_name);
   if (r < 0) {
-    std::cerr << "failed to initialize journal: " << cpp_strerror(r)
-             << std::endl;
+    std::cerr << "failed to locate journal's image: " << cpp_strerror(r)
+              << std::endl;
     return r;
   }
 
-  uint8_t order, splay_width;
-  int64_t pool_id;
-  journaler.get_metadata(&order, &splay_width, &pool_id);
-
-  r = journaler.remove(true);
+  librbd::Image image;
+  r = utils::open_image(io_ctx, image_name, false, &image);
   if (r < 0) {
-    std::cerr << "failed to reset journal: " << cpp_strerror(r) << std::endl;
+    std::cerr << "failed to open image: " << cpp_strerror(r) << std::endl;
     return r;
   }
-  r = journaler.create(order, splay_width, pool_id);
+
+  r = image.update_features(RBD_FEATURE_JOURNALING, false);
   if (r < 0) {
-    std::cerr << "failed to create journal: " << cpp_strerror(r) << std::endl;
+    std::cerr << "failed to disable image journaling: " << cpp_strerror(r)
+              << std::endl;
     return r;
   }
 
-  // TODO register with librbd payload
-  r = journaler.register_client(bufferlist());
+  r = image.update_features(RBD_FEATURE_JOURNALING, true);
   if (r < 0) {
-    std::cerr << "failed to register client: " << cpp_strerror(r) << std::endl;
+    std::cerr << "failed to re-enable image journaling: " << cpp_strerror(r)
+              << std::endl;
     return r;
   }
   return 0;