]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: create state machine uses new validate pool state machine
authorJason Dillaman <dillaman@redhat.com>
Wed, 27 Feb 2019 19:08:04 +0000 (14:08 -0500)
committerJason Dillaman <dillaman@redhat.com>
Fri, 1 Mar 2019 13:27:27 +0000 (08:27 -0500)
Fixes: http://tracker.ceph.com/issues/38500
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/image/CloneRequest.cc
src/librbd/image/CloneRequest.h
src/librbd/image/CreateRequest.cc
src/librbd/image/CreateRequest.h

index d36fa0bb723fe8c58236a308b42feaf37c281874..24da545113079f5c9d41a10e4f38616e67c460bb 100644 (file)
@@ -7,6 +7,7 @@
 #include "common/errno.h"
 #include "include/ceph_assert.h"
 #include "librbd/ImageState.h"
+#include "librbd/Utils.h"
 #include "librbd/image/AttachChildRequest.h"
 #include "librbd/image/AttachParentRequest.h"
 #include "librbd/image/CloneRequest.h"
index aa03d97f0fb6a3f9639c1f0bca5fbcb05c51b480..1e7d4c9c13ad44557ec0d3a397858b52219d2a61 100644 (file)
@@ -4,8 +4,8 @@
 #ifndef CEPH_LIBRBD_IMAGE_CLONE_REQUEST_H
 #define CEPH_LIBRBD_IMAGE_CLONE_REQUEST_H
 
-#include "cls/rbd/cls_rbd_types.h"
 #include "include/rbd/librbd.hpp"
+#include "cls/rbd/cls_rbd_types.h"
 #include "librbd/internal.h"
 
 class ConfigProxy;
index 14f4c3e83a3fc3185fd4790964ca740e92ce4a34..686e7639474961585f03a27f09b64936b940cdd9 100644 (file)
@@ -2,22 +2,23 @@
 // vim: ts=8 sw=2 smarttab
 
 #include "librbd/image/CreateRequest.h"
+#include "include/ceph_assert.h"
 #include "common/dout.h"
 #include "common/errno.h"
-#include "cls/rbd/cls_rbd_client.h"
-#include "include/ceph_assert.h"
-#include "librbd/Features.h"
-#include "librbd/Utils.h"
 #include "common/ceph_context.h"
+#include "cls/rbd/cls_rbd_client.h"
 #include "osdc/Striper.h"
+#include "librbd/Features.h"
 #include "librbd/Journal.h"
-#include "librbd/MirroringWatcher.h"
+#include "librbd/ObjectMap.h"
+#include "librbd/Utils.h"
+#include "librbd/image/ValidatePoolRequest.h"
 #include "librbd/journal/CreateRequest.h"
 #include "librbd/journal/RemoveRequest.h"
 #include "librbd/mirror/EnableRequest.h"
-#include "librbd/io/AioCompletion.h"
 #include "journal/Journaler.h"
 
+
 #define dout_subsys ceph_subsys_rbd
 #undef dout_prefix
 #define dout_prefix *_dout << "librbd::image::CreateRequest: " << __func__ \
@@ -276,80 +277,23 @@ void CreateRequest<I>::validate_data_pool() {
 
   ldout(m_cct, 15) << dendl;
 
-  using klass = CreateRequest<I>;
-  librados::AioCompletion *comp =
-    create_rados_callback<klass, &klass::handle_validate_data_pool>(this);
-
-  librados::ObjectReadOperation op;
-  op.read(0, 0, nullptr, nullptr);
-
-  m_outbl.clear();
-  int r = m_data_io_ctx.aio_operate(RBD_INFO, comp, &op, &m_outbl);
-  ceph_assert(r == 0);
-  comp->release();
+  auto ctx = create_context_callback<
+    CreateRequest<I>, &CreateRequest<I>::handle_validate_data_pool>(this);
+  auto req = ValidatePoolRequest<I>::create(m_data_io_ctx, m_op_work_queue,
+                                            ctx);
+  req->send();
 }
 
 template <typename I>
 void CreateRequest<I>::handle_validate_data_pool(int r) {
   ldout(m_cct, 15) << "r=" << r << dendl;
 
-  bufferlist bl;
-  bl.append("overwrite validated");
-
-  if (r >= 0 && m_outbl.contents_equal(bl)) {
-    add_image_to_directory();
-    return;
-  } else if ((r < 0) && (r != -ENOENT)) {
-    lderr(m_cct) << "failed to read RBD info: " << cpp_strerror(r) << dendl;
-    complete(r);
-    return;
-  }
-
-  // allocate a self-managed snapshot id if this a new pool to force
-  // self-managed snapshot mode
-  // This call is executed just once per (fresh) pool, hence we do not
-  // try hard to make it asynchronous (and it's pretty safe not to cause
-  // deadlocks).
-
-  ldout(m_cct, 10) << "validating self-managed RBD snapshot support" << dendl;
-
-  uint64_t snap_id;
-  r = m_data_io_ctx.selfmanaged_snap_create(&snap_id);
   if (r == -EINVAL) {
-    lderr(m_cct) << "pool not configured for self-managed RBD snapshot support"
-                 << dendl;
-    complete(r);
-    return;
-  } else if (r < 0) {
-    lderr(m_cct) << "failed to allocate self-managed snapshot: "
-                 << cpp_strerror(r) << dendl;
+    lderr(m_cct) << "pool does not support RBD images" << dendl;
     complete(r);
     return;
-  }
-
-  r = m_data_io_ctx.selfmanaged_snap_remove(snap_id);
-  if (r < 0) {
-    // we've already switched to self-managed snapshots -- no need to
-    // error out in case of failure here.
-    ldout(m_cct, 10) << "failed to release self-managed snapshot " << snap_id
-                     << ": " << cpp_strerror(r) << dendl;
-  }
-
-  ldout(m_cct, 10) << "validating overwrite support" << dendl;
-
-  bufferlist initial_bl;
-  initial_bl.append("validate");
-  r = m_data_io_ctx.write(RBD_INFO, initial_bl, initial_bl.length(), 0);
-  if (r >= 0) {
-    r = m_data_io_ctx.write(RBD_INFO, bl, bl.length(), 0);
-  }
-  if (r == -EOPNOTSUPP) {
-    lderr(m_cct) << "pool missing required overwrite support" << dendl;
-    complete(-EINVAL);
-    return;
   } else if (r < 0) {
-    lderr(m_cct) << "failed to validate overwrite support: " << cpp_strerror(r)
-                 << dendl;
+    lderr(m_cct) << "failed to validate pool: " << cpp_strerror(r) << dendl;
     complete(r);
     return;
   }
index 120686ed45316e1e869e7ce5c3c155c976bdde8e..6d5b641de99fa6d6992bc3c465f0761df5d3d710 100644 (file)
@@ -6,24 +6,18 @@
 
 #include "include/int_types.h"
 #include "include/buffer.h"
-#include "common/WorkQueue.h"
-#include "librbd/ObjectMap.h"
 #include "include/rados/librados.hpp"
-#include "include/rbd_types.h"
-#include "cls/rbd/cls_rbd_types.h"
 #include "include/rbd/librbd.hpp"
+#include "cls/rbd/cls_rbd_types.h"
 #include "librbd/ImageCtx.h"
-#include "common/Timer.h"
-#include "librbd/journal/TypeTraits.h"
 
 class ConfigProxy;
 class Context;
+class ContextWQ;
 
 using librados::IoCtx;
 
-namespace journal {
-  class Journaler;
-}
+namespace journal { class Journaler; }
 
 namespace librbd {
 namespace image {