]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: move remove API method to api namespace
authorJason Dillaman <dillaman@redhat.com>
Mon, 8 Oct 2018 14:09:39 +0000 (10:09 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 10 Oct 2018 13:07:00 +0000 (09:07 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/api/Image.cc
src/librbd/api/Image.h
src/librbd/api/Trash.cc
src/librbd/internal.cc
src/librbd/internal.h
src/librbd/librbd.cc
src/test/librbd/image/test_mock_RefreshRequest.cc
src/test/librbd/test_internal.cc
src/test/rbd_mirror/test_ImageDeleter.cc

index bf5ad695db96976af78dd1c962d05fe52bd207f0..2d6fb757e6b1944e19741899fc83b0ace6531fa0 100644 (file)
@@ -12,6 +12,7 @@
 #include "librbd/ImageState.h"
 #include "librbd/Utils.h"
 #include "librbd/image/CloneRequest.h"
+#include "librbd/image/RemoveRequest.h"
 #include "librbd/internal.h"
 #include "librbd/Utils.h"
 #include "librbd/api/Config.h"
@@ -370,6 +371,27 @@ int Image<I>::snap_set(I *ictx, uint64_t snap_id) {
   return 0;
 }
 
+template <typename I>
+int Image<I>::remove(IoCtx& io_ctx, const std::string &image_name,
+                     const std::string &image_id, ProgressContext& prog_ctx,
+                     bool force, bool from_trash_remove)
+{
+  CephContext *cct((CephContext *)io_ctx.cct());
+  ldout(cct, 20) << (image_id.empty() ? image_name : image_id) << dendl;
+
+  ThreadPool *thread_pool;
+  ContextWQ *op_work_queue;
+  ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);
+
+  C_SaferCond cond;
+  auto req = librbd::image::RemoveRequest<>::create(
+    io_ctx, image_name, image_id, force, from_trash_remove, prog_ctx,
+    op_work_queue, &cond);
+  req->send();
+
+  return cond.wait();
+}
+
 } // namespace api
 } // namespace librbd
 
index 88c15f80c77b1016a42f1532e61a74b850f3d873..a46104d5226a0d2108288c1985e6df4e535afabe 100644 (file)
@@ -47,6 +47,10 @@ struct Image {
                      const char *snap_name);
   static int snap_set(ImageCtxT *ictx, uint64_t snap_id);
 
+  static int remove(librados::IoCtx& io_ctx, const std::string &image_name,
+                    const std::string &image_id, ProgressContext& prog_ctx,
+                    bool force=false, bool from_trash_remove=false);
+
 };
 
 } // namespace api
index 560c5f2a24105b34a6101dd693a4eb10ba8ccff9..b6f4cafdcf347718d509479ef478a783076c8482 100644 (file)
@@ -13,6 +13,7 @@
 #include "librbd/Operations.h"
 #include "librbd/TrashWatcher.h"
 #include "librbd/Utils.h"
+#include "librbd/api/Image.h"
 #include "librbd/trash/MoveRequest.h"
 
 #define dout_subsys ceph_subsys_rbd
@@ -209,7 +210,7 @@ int Trash<I>::remove(IoCtx &io_ctx, const std::string &image_id, bool force,
     return r;
   }
 
-  r = librbd::remove(io_ctx, "", image_id, prog_ctx, false, true);
+  r = Image<I>::remove(io_ctx, "", image_id, prog_ctx, false, true);
   if (r < 0) {
     lderr(cct) << "error removing image " << image_id
                << ", which is pending deletion" << dendl;
index 903a8ce110dacf9823db323c03f5d7b7e0e2aef3..12d8da2f905a3172a446f97d3901b3af3569df6a 100644 (file)
@@ -38,7 +38,6 @@
 #include "librbd/exclusive_lock/StandardPolicy.h"
 #include "librbd/image/CloneRequest.h"
 #include "librbd/image/CreateRequest.h"
-#include "librbd/image/RemoveRequest.h"
 #include "librbd/io/AioCompletion.h"
 #include "librbd/io/ImageRequest.h"
 #include "librbd/io/ImageRequestWQ.h"
@@ -1371,27 +1370,6 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2)
     return 0;
   }
 
-  int remove(IoCtx& io_ctx, const std::string &image_name,
-             const std::string &image_id, ProgressContext& prog_ctx,
-             bool force, bool from_trash_remove)
-  {
-    CephContext *cct((CephContext *)io_ctx.cct());
-    ldout(cct, 20) << "remove " << &io_ctx << " "
-                   << (image_id.empty() ? image_name : image_id) << dendl;
-
-    ThreadPool *thread_pool;
-    ContextWQ *op_work_queue;
-    ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);
-
-    C_SaferCond cond;
-    auto req = librbd::image::RemoveRequest<>::create(
-      io_ctx, image_name, image_id, force, from_trash_remove, prog_ctx,
-      op_work_queue, &cond);
-    req->send();
-
-    return cond.wait();
-  }
-
   int snap_list(ImageCtx *ictx, vector<snap_info_t>& snaps)
   {
     ldout(ictx->cct, 20) << "snap_list " << ictx << dendl;
index 27e7be8f2e2c1da6352a32d7c59b1857e99008ee..abb618d9971540ab41fd3f420b807906b18e5edb 100644 (file)
@@ -101,10 +101,6 @@ namespace librbd {
   int lock_break(ImageCtx *ictx, rbd_lock_mode_t lock_mode,
                  const std::string &lock_owner);
 
-  int remove(librados::IoCtx& io_ctx, const std::string &image_name,
-             const std::string &image_id, ProgressContext& prog_ctx,
-             bool force=false, bool from_trash_remove=false);
-
   int snap_list(ImageCtx *ictx, std::vector<snap_info_t>& snaps);
   int snap_exists(ImageCtx *ictx, const cls::rbd::SnapshotNamespace& snap_namespace,
                  const char *snap_name, bool *exists);
index 5546cefb1054dfacd7fa6121e174f8e4002e76d6..6e409babc295b501889f372de73a5fdeff869397 100644 (file)
@@ -558,7 +558,7 @@ namespace librbd {
     TracepointProvider::initialize<tracepoint_traits>(get_cct(io_ctx));
     tracepoint(librbd, remove_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name);
     librbd::NoOpProgressContext prog_ctx;
-    int r = librbd::remove(io_ctx, name, "", prog_ctx);
+    int r = librbd::api::Image<>::remove(io_ctx, name, "", prog_ctx);
     tracepoint(librbd, remove_exit, r);
     return r;
   }
@@ -568,7 +568,7 @@ namespace librbd {
   {
     TracepointProvider::initialize<tracepoint_traits>(get_cct(io_ctx));
     tracepoint(librbd, remove_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name);
-    int r = librbd::remove(io_ctx, name, "", pctx);
+    int r = librbd::api::Image<>::remove(io_ctx, name, "", pctx);
     tracepoint(librbd, remove_exit, r);
     return r;
   }
@@ -2805,7 +2805,7 @@ extern "C" int rbd_remove(rados_ioctx_t p, const char *name)
   TracepointProvider::initialize<tracepoint_traits>(get_cct(io_ctx));
   tracepoint(librbd, remove_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name);
   librbd::NoOpProgressContext prog_ctx;
-  int r = librbd::remove(io_ctx, name, "", prog_ctx);
+  int r = librbd::api::Image<>::remove(io_ctx, name, "", prog_ctx);
   tracepoint(librbd, remove_exit, r);
   return r;
 }
@@ -2818,7 +2818,7 @@ extern "C" int rbd_remove_with_progress(rados_ioctx_t p, const char *name,
   TracepointProvider::initialize<tracepoint_traits>(get_cct(io_ctx));
   tracepoint(librbd, remove_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name);
   librbd::CProgressContext prog_ctx(cb, cbdata);
-  int r = librbd::remove(io_ctx, name, "", prog_ctx);
+  int r = librbd::api::Image<>::remove(io_ctx, name, "", prog_ctx);
   tracepoint(librbd, remove_exit, r);
   return r;
 }
index ff1cb4921c242f594fc8d162b92d885915e55528..e7a731d6a332b8dad99925e140b22494e5ab163e 100644 (file)
@@ -682,7 +682,7 @@ TEST_F(TestMockImageRefreshRequest, SuccessChild) {
     }
 
     librbd::NoOpProgressContext no_op;
-    ASSERT_EQ(0, librbd::remove(m_ioctx, clone_name, "", no_op));
+    ASSERT_EQ(0, librbd::api::Image<>::remove(m_ioctx, clone_name, "", no_op));
     ASSERT_EQ(0, ictx->operations->snap_unprotect(cls::rbd::UserSnapshotNamespace(), "snap"));
   };
 
@@ -736,7 +736,7 @@ TEST_F(TestMockImageRefreshRequest, SuccessChildDontOpenParent) {
     }
 
     librbd::NoOpProgressContext no_op;
-    ASSERT_EQ(0, librbd::remove(m_ioctx, clone_name, "", no_op));
+    ASSERT_EQ(0, librbd::api::Image<>::remove(m_ioctx, clone_name, "", no_op));
     ASSERT_EQ(0, ictx->operations->snap_unprotect(cls::rbd::UserSnapshotNamespace(), "snap"));
   };
 
index 326c87435a70e117a9301774f9031f7283aca64f..c9af08272454349f6daad229eb99e06e4d05b7f5 100644 (file)
@@ -326,7 +326,7 @@ TEST_F(TestInternal, FlattenFailsToLockImage) {
       parent->unlock_image();
     }
     librbd::NoOpProgressContext no_op;
-    ASSERT_EQ(0, librbd::remove(m_ioctx, clone_name, "", no_op));
+    ASSERT_EQ(0, librbd::api::Image<>::remove(m_ioctx, clone_name, "", no_op));
   } BOOST_SCOPE_EXIT_END;
 
   ASSERT_EQ(0, open_image(clone_name, &ictx2));
@@ -890,7 +890,8 @@ TEST_F(TestInternal, WriteFullCopyup) {
     }
 
     librbd::NoOpProgressContext remove_no_op;
-    ASSERT_EQ(0, librbd::remove(m_ioctx, clone_name, "", remove_no_op));
+    ASSERT_EQ(0, librbd::api::Image<>::remove(m_ioctx, clone_name, "",
+                                              remove_no_op));
   } BOOST_SCOPE_EXIT_END;
 
   ASSERT_EQ(0, open_image(clone_name, &ictx2));
@@ -934,7 +935,8 @@ TEST_F(TestInternal, RemoveById) {
   close_image(ictx);
 
   librbd::NoOpProgressContext remove_no_op;
-  ASSERT_EQ(0, librbd::remove(m_ioctx, "", image_id, remove_no_op));
+  ASSERT_EQ(0, librbd::api::Image<>::remove(m_ioctx, "", image_id,
+                                            remove_no_op));
 }
 
 static int iterate_cb(uint64_t off, size_t len, int exists, void *arg)
index 2b3fd44cd9993299797771e908fedbc442c83ced..d86a8822e7112f81e1ba79cf5d237eab9a00b802 100644 (file)
@@ -112,7 +112,8 @@ public:
       promote_image();
     }
     NoOpProgressContext ctx;
-    int r = remove(m_local_io_ctx, m_image_name, "", ctx, force);
+    int r = librbd::api::Image<>::remove(m_local_io_ctx, m_image_name, "", ctx,
+                                         force);
     EXPECT_EQ(1, r == 0 || r == -ENOENT);
   }