]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: new snapshot create API to pass flags
authorMykola Golub <mgolub@suse.com>
Sun, 31 May 2020 13:22:59 +0000 (14:22 +0100)
committerMykola Golub <mgolub@suse.com>
Tue, 9 Jun 2020 07:33:52 +0000 (08:33 +0100)
Signed-off-by: Mykola Golub <mgolub@suse.com>
46 files changed:
src/include/rbd/librbd.h
src/include/rbd/librbd.hpp
src/librbd/ImageWatcher.cc
src/librbd/ImageWatcher.h
src/librbd/Operations.cc
src/librbd/Operations.h
src/librbd/Types.h
src/librbd/WatchNotifyTypes.cc
src/librbd/WatchNotifyTypes.h
src/librbd/api/Snapshot.cc
src/librbd/api/Snapshot.h
src/librbd/deep_copy/SnapshotCreateRequest.cc
src/librbd/journal/Replay.cc
src/librbd/librbd.cc
src/librbd/mirror/snapshot/CreateNonPrimaryRequest.cc
src/librbd/mirror/snapshot/CreateNonPrimaryRequest.h
src/librbd/mirror/snapshot/CreatePrimaryRequest.cc
src/librbd/mirror/snapshot/CreatePrimaryRequest.h
src/librbd/operation/SnapshotCreateRequest.cc
src/librbd/operation/SnapshotCreateRequest.h
src/test/librbd/deep_copy/test_mock_ImageCopyRequest.cc
src/test/librbd/deep_copy/test_mock_ObjectCopyRequest.cc
src/test/librbd/deep_copy/test_mock_SnapshotCopyRequest.cc
src/test/librbd/deep_copy/test_mock_SnapshotCreateRequest.cc
src/test/librbd/image/test_mock_AttachChildRequest.cc
src/test/librbd/image/test_mock_CloneRequest.cc
src/test/librbd/journal/test_Replay.cc
src/test/librbd/journal/test_mock_Replay.cc
src/test/librbd/mirror/snapshot/test_mock_CreateNonPrimaryRequest.cc
src/test/librbd/mirror/snapshot/test_mock_CreatePrimaryRequest.cc
src/test/librbd/mock/MockOperations.h
src/test/librbd/operation/test_mock_SnapshotCreateRequest.cc
src/test/librbd/operation/test_mock_SnapshotRemoveRequest.cc
src/test/librbd/test_ImageWatcher.cc
src/test/librbd/test_fixture.cc
src/test/librbd/test_internal.cc
src/test/librbd/test_librbd.cc
src/test/rbd_mirror/image_replayer/snapshot/test_mock_CreateLocalImageRequest.cc
src/test/rbd_mirror/image_replayer/test_mock_CreateImageRequest.cc
src/test/rbd_mirror/image_sync/test_mock_SyncPointCreateRequest.cc
src/test/rbd_mirror/test_ImageDeleter.cc
src/test/rbd_mirror/test_ImageReplayer.cc
src/test/rbd_mirror/test_PoolWatcher.cc
src/test/rbd_mirror/test_fixture.cc
src/tools/rbd_mirror/image_sync/SyncPointCreateRequest.cc
src/tools/rbd_mirror/image_sync/SyncPointCreateRequest.h

index 9da0175221a1929ac81d70478e9c3f2e7075eb01..06c9b252f628b41acd0591bf75585757d2ed4715 100644 (file)
@@ -117,6 +117,9 @@ typedef struct {
 #define RBD_MAX_IMAGE_NAME_SIZE 96
 #define RBD_MAX_BLOCK_NAME_SIZE 24
 
+#define RBD_SNAP_CREATE_SKIP_QUIESCE           1 << 0
+#define RBD_SNAP_CREATE_IGNORE_QUIESCE_ERROR   1 << 1
+
 #define RBD_SNAP_REMOVE_UNPROTECT      1 << 0
 #define RBD_SNAP_REMOVE_FLATTEN                1 << 1
 #define RBD_SNAP_REMOVE_FORCE          (RBD_SNAP_REMOVE_UNPROTECT | RBD_SNAP_REMOVE_FLATTEN)
@@ -780,6 +783,9 @@ CEPH_RBD_API int rbd_snap_list(rbd_image_t image, rbd_snap_info_t *snaps,
 CEPH_RBD_API void rbd_snap_list_end(rbd_snap_info_t *snaps);
 CEPH_RBD_API int rbd_snap_exists(rbd_image_t image, const char *snapname, bool *exists);
 CEPH_RBD_API int rbd_snap_create(rbd_image_t image, const char *snapname);
+CEPH_RBD_API int rbd_snap_create2(rbd_image_t image, const char *snap_name,
+                                  uint32_t flags, librbd_progress_fn_t cb,
+                                  void *cbdata);
 CEPH_RBD_API int rbd_snap_remove(rbd_image_t image, const char *snapname);
 CEPH_RBD_API int rbd_snap_remove2(rbd_image_t image, const char *snap_name,
                                   uint32_t flags, librbd_progress_fn_t cb,
index 43b04f8a9b066d7f1980e9f2059a840a6347a2ca..6066bd33827af2a7644df28b201569d445853e0d 100644 (file)
@@ -612,6 +612,7 @@ public:
   bool snap_exists(const char *snapname) CEPH_RBD_DEPRECATED;
   int snap_exists2(const char *snapname, bool *exists);
   int snap_create(const char *snapname);
+  int snap_create2(const char *snapname, uint32_t flags, ProgressContext& pctx);
   int snap_remove(const char *snapname);
   int snap_remove2(const char *snapname, uint32_t flags, ProgressContext& pctx);
   int snap_remove_by_id(uint64_t snap_id);
index 72788d2899b7bd30823b003cf7e1120fcf9cab3a..33bf2e7a0d836e045643f8d821427cbe41c191b8 100644 (file)
@@ -196,6 +196,7 @@ template <typename I>
 void ImageWatcher<I>::notify_snap_create(uint64_t request_id,
                                          const cls::rbd::SnapshotNamespace &snap_namespace,
                                         const std::string &snap_name,
+                                         uint64_t flags,
                                          ProgressContext &prog_ctx,
                                          Context *on_finish) {
   ceph_assert(ceph_mutex_is_locked(m_image_ctx.owner_lock));
@@ -206,7 +207,7 @@ void ImageWatcher<I>::notify_snap_create(uint64_t request_id,
 
   notify_async_request(async_request_id,
                        new SnapCreatePayload(async_request_id, snap_namespace,
-                                             snap_name),
+                                             snap_name, flags),
                        prog_ctx, on_finish);
 }
 
@@ -992,11 +993,13 @@ bool ImageWatcher<I>::handle_payload(const SnapCreatePayload &payload,
         ldout(m_image_ctx.cct, 10) << this << " remote snap_create request: "
                                   << payload.async_request_id << " "
                                    << payload.snap_namespace << " "
-                                   << payload.snap_name << dendl;
+                                   << payload.snap_name << " "
+                                   << payload.flags << dendl;
 
         m_image_ctx.operations->execute_snap_create(payload.snap_namespace,
                                                     payload.snap_name,
-                                                    ctx, 0, false, *prog_ctx);
+                                                    ctx, 0, payload.flags,
+                                                    *prog_ctx);
       }
       return complete;
     } else if (r < 0) {
index f141f4a6f24f49f5a52530a38266a6ccb836d392..ed3db723a007818c9e87ea0cb6a7b7eb8c39ba56 100644 (file)
@@ -37,6 +37,7 @@ public:
   void notify_snap_create(uint64_t request_id,
                           const cls::rbd::SnapshotNamespace &snap_namespace,
                          const std::string &snap_name,
+                          uint64_t flags,
                           ProgressContext &prog_ctx,
                          Context *on_finish);
   void notify_snap_rename(const snapid_t &src_snap_id,
index ee401bb61bed282fe44155ce339ba1be48f326db..a980b8865161c671fab6a57371801e33d1df1824 100644 (file)
@@ -687,7 +687,8 @@ void Operations<I>::execute_resize(uint64_t size, bool allow_shrink, ProgressCon
 
 template <typename I>
 int Operations<I>::snap_create(const cls::rbd::SnapshotNamespace &snap_namespace,
-                              const std::string& snap_name) {
+                              const std::string& snap_name, uint64_t flags,
+                               ProgressContext &prog_ctx) {
   if (m_image_ctx.read_only) {
     return -EROFS;
   }
@@ -698,7 +699,7 @@ int Operations<I>::snap_create(const cls::rbd::SnapshotNamespace &snap_namespace
   }
 
   C_SaferCond ctx;
-  snap_create(snap_namespace, snap_name, &ctx);
+  snap_create(snap_namespace, snap_name, flags, prog_ctx, &ctx);
   r = ctx.wait();
 
   if (r < 0) {
@@ -711,8 +712,8 @@ int Operations<I>::snap_create(const cls::rbd::SnapshotNamespace &snap_namespace
 
 template <typename I>
 void Operations<I>::snap_create(const cls::rbd::SnapshotNamespace &snap_namespace,
-                               const std::string& snap_name,
-                               Context *on_finish) {
+                               const std::string& snap_name, uint64_t flags,
+                                ProgressContext &prog_ctx, Context *on_finish) {
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 5) << this << " " << __func__ << ": snap_name=" << snap_name
                 << dendl;
@@ -730,22 +731,15 @@ void Operations<I>::snap_create(const cls::rbd::SnapshotNamespace &snap_namespac
   }
   m_image_ctx.image_lock.unlock_shared();
 
-  auto prog_ctx = new NoOpProgressContext();
-  on_finish = new LambdaContext(
-    [prog_ctx, on_finish](int r) {
-      delete prog_ctx;
-      on_finish->complete(r);
-    });
-
   uint64_t request_id = ++m_async_request_seq;
   C_InvokeAsyncRequest<I> *req = new C_InvokeAsyncRequest<I>(
     m_image_ctx, "snap_create", exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL,
     true,
     boost::bind(&Operations<I>::execute_snap_create, this, snap_namespace, snap_name,
-               _1, 0, 0, boost::ref(*prog_ctx)),
+               _1, 0, flags, boost::ref(prog_ctx)),
     boost::bind(&ImageWatcher<I>::notify_snap_create, m_image_ctx.image_watcher,
-                request_id, snap_namespace, snap_name, boost::ref(*prog_ctx),
-                _1),
+                request_id, snap_namespace, snap_name, flags,
+                boost::ref(prog_ctx), _1),
     {-EEXIST}, on_finish);
   req->send();
 }
index 705d80273440f17c47ddc4216a92b5468f0a8351..fec7e16da4120371453a610c2a9edff1d596d81f 100644 (file)
@@ -50,9 +50,11 @@ public:
                       Context *on_finish, uint64_t journal_op_tid);
 
   int snap_create(const cls::rbd::SnapshotNamespace &snap_namespace,
-                 const std::string& snap_name);
+                 const std::string& snap_name, uint64_t flags,
+                  ProgressContext& prog_ctx);
   void snap_create(const cls::rbd::SnapshotNamespace &snap_namespace,
-                  const std::string& snap_name, Context *on_finish);
+                  const std::string& snap_name, uint64_t flags,
+                   ProgressContext& prog_ctx, Context *on_finish);
   void execute_snap_create(const cls::rbd::SnapshotNamespace &snap_namespace,
                           const std::string &snap_name, Context *on_finish,
                            uint64_t journal_op_tid, uint64_t flags,
index 733f133ba008a66420b45cefd0d1901447f75b2e..66e3a967f6fb75244d9050a10784546ba15d74df 100644 (file)
@@ -100,8 +100,9 @@ enum ImageReadOnlyFlag {
 };
 
 enum SnapCreateFlag {
-  SNAP_CREATE_FLAG_SKIP_OBJECT_MAP     = 1 << 0,
-  SNAP_CREATE_FLAG_SKIP_NOTIFY_QUIESCE = 1 << 1,
+  SNAP_CREATE_FLAG_SKIP_OBJECT_MAP             = 1 << 0,
+  SNAP_CREATE_FLAG_SKIP_NOTIFY_QUIESCE         = 1 << 1,
+  SNAP_CREATE_FLAG_IGNORE_NOTIFY_QUIESCE_ERROR = 1 << 2,
 };
 
 struct MigrationInfo {
index 6712f899a2516d5efea7c9c755af27155a590134..eb6401ca820afbd0635af6c54754288611761120 100644 (file)
@@ -196,6 +196,7 @@ void SnapCreatePayload::encode(bufferlist &bl) const {
   using ceph::encode;
   SnapPayloadBase::encode(bl);
   encode(async_request_id, bl);
+  encode(flags, bl);
 }
 
 void SnapCreatePayload::decode(__u8 version, bufferlist::const_iterator &iter) {
@@ -206,6 +207,7 @@ void SnapCreatePayload::decode(__u8 version, bufferlist::const_iterator &iter) {
   }
   if (version >= 7) {
     decode(async_request_id, iter);
+    decode(flags, iter);
   }
 }
 
@@ -214,6 +216,7 @@ void SnapCreatePayload::dump(Formatter *f) const {
   async_request_id.dump(f);
   f->close_section();
   SnapPayloadBase::dump(f);
+  f->dump_unsigned("flags", flags);
 }
 
 void SnapRenamePayload::encode(bufferlist &bl) const {
@@ -395,7 +398,7 @@ void NotifyMessage::generate_test_instances(std::list<NotifyMessage *> &o) {
   o.push_back(new NotifyMessage(new ResizePayload(123, true, AsyncRequestId(ClientId(0, 1), 2))));
   o.push_back(new NotifyMessage(new SnapCreatePayload(AsyncRequestId(ClientId(0, 1), 2),
                                                       cls::rbd::UserSnapshotNamespace(),
-                                                      "foo")));
+                                                      "foo", 1)));
   o.push_back(new NotifyMessage(new SnapRemovePayload(cls::rbd::UserSnapshotNamespace(), "foo")));
   o.push_back(new NotifyMessage(new SnapProtectPayload(cls::rbd::UserSnapshotNamespace(), "foo")));
   o.push_back(new NotifyMessage(new SnapUnprotectPayload(cls::rbd::UserSnapshotNamespace(), "foo")));
index e1ac5e1611f4871feaf0d4d59682aca9f920b19b..f7e991a55fac4b1d685fe3685f866eb5fc3f6b7e 100644 (file)
@@ -262,12 +262,14 @@ protected:
 
 struct SnapCreatePayload : public SnapPayloadBase {
   AsyncRequestId async_request_id;
+  uint64_t flags = 0;
 
   SnapCreatePayload() {}
   SnapCreatePayload(const AsyncRequestId &id,
                     const cls::rbd::SnapshotNamespace &snap_namespace,
-                   const std::string &name)
-    : SnapPayloadBase(snap_namespace, name), async_request_id(id) {
+                   const std::string &name, uint64_t flags)
+    : SnapPayloadBase(snap_namespace, name), async_request_id(id),
+      flags(flags) {
   }
 
   NotifyOp get_notify_op() const override {
index da6c7196bc83aba938fb085e85fb6caf548ba8f6..03f30ecba379901cb67cba201e11ba217a3550aa 100644 (file)
 #include "librbd/Operations.h"
 #include "librbd/Utils.h"
 #include "librbd/api/Image.h"
-#include <boost/variant.hpp>
 #include "include/Context.h"
 #include "common/Cond.h"
 
+#include <bitset>
+#include <boost/variant.hpp>
+
 #define dout_subsys ceph_subsys_rbd
 #undef dout_prefix
 #define dout_prefix *_dout << "librbd::api::Snapshot: " << __func__ << ": "
@@ -309,6 +311,32 @@ int Snapshot<I>::exists(I *ictx, const cls::rbd::SnapshotNamespace& snap_namespa
   return 0;
 }
 
+template <typename I>
+int Snapshot<I>::create(I *ictx, const char *snap_name, uint32_t flags,
+                        ProgressContext& pctx) {
+  ldout(ictx->cct, 20) << "snap_create " << ictx << " " << snap_name
+                       << " flags: " << flags << dendl;
+
+  uint64_t internal_flags = 0;
+
+  if (flags & RBD_SNAP_CREATE_SKIP_QUIESCE) {
+    internal_flags |= SNAP_CREATE_FLAG_SKIP_NOTIFY_QUIESCE;
+    flags &= ~RBD_SNAP_CREATE_SKIP_QUIESCE;
+  } else if (flags & RBD_SNAP_CREATE_IGNORE_QUIESCE_ERROR) {
+    internal_flags |= SNAP_CREATE_FLAG_IGNORE_NOTIFY_QUIESCE_ERROR;
+    flags &= ~RBD_SNAP_CREATE_IGNORE_QUIESCE_ERROR;
+  }
+
+  if (flags != 0) {
+    lderr(ictx->cct) << "invalid snap create flags: " << std::bitset<32>(flags)
+                     << dendl;
+    return -EINVAL;
+  }
+
+  return ictx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
+                                       snap_name, internal_flags, pctx);
+}
+
 template <typename I>
 int Snapshot<I>::remove(I *ictx, const char *snap_name, uint32_t flags,
                         ProgressContext& pctx) {
index ce5252c78d8f698e72c1a16ac30a2af5cb47848a..7e06a5a8d0772b81c13e79ba60d88aa3521a679b 100644 (file)
@@ -41,6 +41,9 @@ struct Snapshot {
   static int exists(ImageCtxT *ictx, const cls::rbd::SnapshotNamespace& snap_namespace,
                    const char *snap_name, bool *exists);
 
+  static int create(ImageCtxT *ictx, const char *snap_name, uint32_t flags,
+                    ProgressContext& pctx);
+
   static int remove(ImageCtxT *ictx, const char *snap_name, uint32_t flags, ProgressContext& pctx);
 
   static int get_limit(ImageCtxT *ictx, uint64_t *limit);
index ca22e5d1c03ad1da9434ab6824c15e25ccd2b742..d437bd3552fd890005b5d518ce6e07059354dcfd 100644 (file)
@@ -80,10 +80,11 @@ void SnapshotCreateRequest<I>::send_create_snap() {
       handle_create_snap(r);
       finish_op_ctx->complete(0);
     });
+  uint64_t flags = SNAP_CREATE_FLAG_SKIP_OBJECT_MAP |
+                   SNAP_CREATE_FLAG_SKIP_NOTIFY_QUIESCE;
   std::shared_lock owner_locker{m_dst_image_ctx->owner_lock};
   m_dst_image_ctx->operations->execute_snap_create(
-      m_snap_namespace, m_snap_name.c_str(), ctx, 0U,
-      SNAP_CREATE_FLAG_SKIP_OBJECT_MAP, m_prog_ctx);
+      m_snap_namespace, m_snap_name.c_str(), ctx, 0U, flags, m_prog_ctx);
 }
 
 template <typename I>
index 9efeeae0b114f065dbd6bcd411ec7a3ff66c9b13..d0b4234cdcefc9d441d9a44c2d1176eb08c71ed7 100644 (file)
@@ -42,7 +42,8 @@ struct ExecuteOp : public Context {
     image_ctx.operations->execute_snap_create(event.snap_namespace,
                                              event.snap_name,
                                               on_op_complete,
-                                              event.op_tid, 0,
+                                              event.op_tid,
+                                              SNAP_CREATE_FLAG_SKIP_NOTIFY_QUIESCE,
                                               no_op_progress_callback);
   }
 
index a2d9243550cf888520318359604564f139e7d87e..d61a9335b90e21c0a6a3396fddf894a4648bb274 100644 (file)
@@ -2180,8 +2180,18 @@ namespace librbd {
   {
     ImageCtx *ictx = (ImageCtx *)ctx;
     tracepoint(librbd, snap_create_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
-    int r = ictx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                         snap_name);
+    librbd::NoOpProgressContext prog_ctx;
+    int r = librbd::api::Snapshot<>::create(ictx, snap_name, 0, prog_ctx);
+    tracepoint(librbd, snap_create_exit, r);
+    return r;
+  }
+
+  int Image::snap_create2(const char *snap_name, uint32_t flags,
+                          ProgressContext& prog_ctx)
+  {
+    ImageCtx *ictx = (ImageCtx *)ctx;
+    tracepoint(librbd, snap_create_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
+    int r = librbd::api::Snapshot<>::create(ictx, snap_name, flags, prog_ctx);
     tracepoint(librbd, snap_create_exit, r);
     return r;
   }
@@ -5221,8 +5231,20 @@ extern "C" int rbd_snap_create(rbd_image_t image, const char *snap_name)
 {
   librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
   tracepoint(librbd, snap_create_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
-  int r = ictx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                       snap_name);
+  librbd::NoOpProgressContext prog_ctx;
+  int r = librbd::api::Snapshot<>::create(ictx, snap_name, 0, prog_ctx);
+  tracepoint(librbd, snap_create_exit, r);
+  return r;
+}
+
+extern "C" int rbd_snap_create2(rbd_image_t image, const char *snap_name,
+                                uint32_t flags, librbd_progress_fn_t cb,
+                                void *cbdata)
+{
+  librbd::ImageCtx *ictx = (librbd::ImageCtx *)image;
+  tracepoint(librbd, snap_create_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, snap_name);
+  librbd::CProgressContext prog_ctx(cb, cbdata);
+  int r = librbd::api::Snapshot<>::create(ictx, snap_name, flags, prog_ctx);
   tracepoint(librbd, snap_create_exit, r);
   return r;
 }
index 6d5588d7f2c4667d93a650bc60bed203e5a40efb..ee6b93ec2cbfea56d150a10a686fec601e89925c 100644 (file)
@@ -194,7 +194,7 @@ void CreateNonPrimaryRequest<I>::create_snapshot() {
   auto ctx = create_context_callback<
     CreateNonPrimaryRequest<I>,
     &CreateNonPrimaryRequest<I>::handle_create_snapshot>(this);
-  m_image_ctx->operations->snap_create(ns, m_snap_name, ctx);
+  m_image_ctx->operations->snap_create(ns, m_snap_name, 0, m_prog_ctx, ctx);
 }
 
 template <typename I>
index 32cb46d1aadbb7bfacdae0f327ae21a1c04d8b7f..36f155413c60923138252803fdcd2c2ea013f6b6 100644 (file)
@@ -7,6 +7,7 @@
 #include "include/buffer.h"
 #include "cls/rbd/cls_rbd_types.h"
 #include "librbd/Types.h"
+#include "librbd/internal.h"
 #include "librbd/mirror/snapshot/Types.h"
 
 #include <string>
@@ -89,6 +90,7 @@ private:
   std::string m_snap_name;
 
   bufferlist m_out_bl;
+  NoOpProgressContext m_prog_ctx;
 
   bool is_orphan() const {
     return m_primary_mirror_uuid.empty();
index c9937e6a6548dd8a6a9911059c1404713cd1feea..0694ecc109034629a633ede2342d1ab0158d6ba7 100644 (file)
@@ -121,7 +121,7 @@ void CreatePrimaryRequest<I>::create_snapshot() {
   auto ctx = create_context_callback<
     CreatePrimaryRequest<I>,
     &CreatePrimaryRequest<I>::handle_create_snapshot>(this);
-  m_image_ctx->operations->snap_create(ns, m_snap_name, ctx);
+  m_image_ctx->operations->snap_create(ns, m_snap_name, 0, m_prog_ctx, ctx);
 }
 
 template <typename I>
index 94e85c9d9d447dd392784f86b9d4b761df590951..b7869e5ef000e8cba61fd9ba9c6180ff2cb8b365 100644 (file)
@@ -7,6 +7,7 @@
 #include "include/buffer.h"
 #include "include/rados/librados.hpp"
 #include "cls/rbd/cls_rbd_types.h"
+#include "librbd/internal.h"
 #include "librbd/mirror/snapshot/Types.h"
 
 #include <string>
@@ -77,6 +78,7 @@ private:
   std::string m_snap_name;
 
   bufferlist m_out_bl;
+  NoOpProgressContext m_prog_ctx;
 
   void get_mirror_peers();
   void handle_get_mirror_peers(int r);
index 15d8e2f7a2855eb348e8826b0358a0efb220db80..bf3b374318450509168709be3162379b0d6dd9a7 100644 (file)
@@ -36,6 +36,7 @@ SnapshotCreateRequest<I>::SnapshotCreateRequest(I &image_ctx,
     m_snap_namespace(snap_namespace), m_snap_name(snap_name),
     m_skip_object_map(flags & SNAP_CREATE_FLAG_SKIP_OBJECT_MAP),
     m_skip_notify_quiesce(flags & SNAP_CREATE_FLAG_SKIP_NOTIFY_QUIESCE),
+    m_ignore_notify_quiesce_error(flags & SNAP_CREATE_FLAG_IGNORE_NOTIFY_QUIESCE_ERROR),
     m_prog_ctx(prog_ctx) {
 }
 
@@ -76,7 +77,7 @@ Context *SnapshotCreateRequest<I>::handle_notify_quiesce(int *result) {
   CephContext *cct = image_ctx.cct;
   ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl;
 
-  if (*result < 0) {
+  if (*result < 0 && !m_ignore_notify_quiesce_error) {
     lderr(cct) << "failed to notify quiesce: " << cpp_strerror(*result)
                << dendl;
     save_result(result);
@@ -359,7 +360,6 @@ template <typename I>
 Context *SnapshotCreateRequest<I>::send_notify_unquiesce() {
   I &image_ctx = this->m_image_ctx;
   CephContext *cct = image_ctx.cct;
-  ldout(cct, 5) << this << " " << __func__ << dendl;
 
   if (m_writes_blocked) {
     image_ctx.io_image_dispatcher->unblock_writes();
@@ -369,6 +369,8 @@ Context *SnapshotCreateRequest<I>::send_notify_unquiesce() {
     return this->create_context_finisher(m_ret_val);
   }
 
+  ldout(cct, 5) << this << " " << __func__ << dendl;
+
   image_ctx.image_watcher->notify_unquiesce(
     m_request_id, create_context_callback<
       SnapshotCreateRequest<I>,
index 20e591e71be267318d4ac9f4ecea8a20831efbf4..d306ee21b5b1f3f4aa6dbaa3d529d3f1752e7d89 100644 (file)
@@ -90,6 +90,7 @@ private:
   std::string m_snap_name;
   bool m_skip_object_map;
   bool m_skip_notify_quiesce;
+  bool m_ignore_notify_quiesce_error;
   ProgressContext &m_prog_ctx;
 
   uint64_t m_request_id = 0;
index 4ee6320f3e5c9fdc6f6a6cfb113d7951db406a78..f323894e08db933d95d840ffa6ab48d9fff153bb 100644 (file)
@@ -246,8 +246,9 @@ public:
 
   int create_snap(librbd::ImageCtx *image_ctx, const char* snap_name,
                   librados::snap_t *snap_id) {
+    NoOpProgressContext prog_ctx;
     int r = image_ctx->operations->snap_create(
-        cls::rbd::UserSnapshotNamespace(), snap_name);
+        cls::rbd::UserSnapshotNamespace(), snap_name, 0, prog_ctx);
     if (r < 0) {
       return r;
     }
index ba7966c9a38875d486d055fa283315782ab0a8b5..5641b537c784fa0ed509f38abdf0b1f58045546a 100644 (file)
@@ -305,8 +305,9 @@ public:
 
   int create_snap(librbd::ImageCtx *image_ctx, const char* snap_name,
                   librados::snap_t *snap_id) {
+    NoOpProgressContext prog_ctx;
     int r = image_ctx->operations->snap_create(
-        cls::rbd::UserSnapshotNamespace(), snap_name);
+        cls::rbd::UserSnapshotNamespace(), snap_name, 0, prog_ctx);
     if (r < 0) {
       return r;
     }
index 40c282cd4cd70911f443901b83bfae0e53d37a01..cd5159b0bfb9bb5afd7cc28064a01fd5365053cf 100644 (file)
@@ -241,7 +241,9 @@ public:
   int create_snap(librbd::ImageCtx *image_ctx,
                   const cls::rbd::SnapshotNamespace& snap_ns,
                   const std::string &snap_name, bool protect) {
-    int r = image_ctx->operations->snap_create(snap_ns, snap_name.c_str());
+    NoOpProgressContext prog_ctx;
+    int r = image_ctx->operations->snap_create(snap_ns, snap_name.c_str(), 0,
+                                               prog_ctx);
     if (r < 0) {
       return r;
     }
index 975aea937d86c4dddaf05e48b7666ac51cd14f85..b2f7ab8091132caa2378b1074fc628269d56ebf9 100644 (file)
@@ -107,9 +107,10 @@ public:
 
   void expect_snap_create(librbd::MockTestImageCtx &mock_image_ctx,
                           const std::string &snap_name, uint64_t snap_id, int r) {
+    uint64_t flags = SNAP_CREATE_FLAG_SKIP_OBJECT_MAP |
+                     SNAP_CREATE_FLAG_SKIP_NOTIFY_QUIESCE;
     EXPECT_CALL(*mock_image_ctx.operations,
-                execute_snap_create(_, StrEq(snap_name), _, 0,
-                                    SNAP_CREATE_FLAG_SKIP_OBJECT_MAP, _))
+                execute_snap_create(_, StrEq(snap_name), _, 0, flags, _))
                   .WillOnce(DoAll(InvokeWithoutArgs([&mock_image_ctx, snap_id, snap_name]() {
                                     inject_snap(mock_image_ctx, snap_id, snap_name);
                                   }),
index 14f9a73407382530b18a9e474b53b556bf5a123a..100d2da2457de888369cf95e195b78d4c6267e61 100644 (file)
@@ -10,6 +10,7 @@
 #include "librbd/Operations.h"
 #include "librbd/image/AttachChildRequest.h"
 #include "librbd/image/RefreshRequest.h"
+#include "librbd/internal.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -72,8 +73,9 @@ public:
     TestMockFixture::SetUp();
 
     ASSERT_EQ(0, open_image(m_image_name, &image_ctx));
+    NoOpProgressContext prog_ctx;
     ASSERT_EQ(0, image_ctx->operations->snap_create(
-                   cls::rbd::UserSnapshotNamespace{}, "snap"));
+                   cls::rbd::UserSnapshotNamespace{}, "snap", 0, prog_ctx));
     if (is_feature_enabled(RBD_FEATURE_LAYERING)) {
       ASSERT_EQ(0, image_ctx->operations->snap_protect(
                      cls::rbd::UserSnapshotNamespace{}, "snap"));
index 4c118ec35445d1a77256f4b7e8c768b9b00db701..641d7df20006ba24886e7c1f5bc56b181a3672b8 100644 (file)
@@ -237,8 +237,9 @@ public:
     ASSERT_EQ(0, _rados.conf_set("rbd_default_clone_format", "2"));
 
     ASSERT_EQ(0, open_image(m_image_name, &image_ctx));
+    NoOpProgressContext prog_ctx;
     ASSERT_EQ(0, image_ctx->operations->snap_create(
-                   cls::rbd::UserSnapshotNamespace{}, "snap"));
+                   cls::rbd::UserSnapshotNamespace{}, "snap", 0, prog_ctx));
     if (is_feature_enabled(RBD_FEATURE_LAYERING)) {
       ASSERT_EQ(0, image_ctx->operations->snap_protect(
                      cls::rbd::UserSnapshotNamespace{}, "snap"));
index 68f41a7ab251838772f927a992059c9eb9017fb8..90cb6005b1ead6ce2540341cf9c238e1f2a2c870 100644 (file)
@@ -338,9 +338,10 @@ TEST_F(TestJournalReplay, SnapCreate) {
                                             "snap"));
   }
 
-  // verify lock ordering constraints
+  // verify lock ordering constraints  
+  librbd::NoOpProgressContext no_op_progress;
   ASSERT_EQ(0, ictx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                            "snap2"));
+                                            "snap2", 0, no_op_progress));
 }
 
 TEST_F(TestJournalReplay, SnapProtect) {
@@ -351,8 +352,9 @@ TEST_F(TestJournalReplay, SnapProtect) {
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
   ASSERT_EQ(0, when_acquired_lock(ictx));
 
+  librbd::NoOpProgressContext no_op_progress;
   ASSERT_EQ(0, ictx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                            "snap"));
+                                            "snap", 0, no_op_progress));
 
   // get current commit position
   int64_t initial_tag;
@@ -383,7 +385,7 @@ TEST_F(TestJournalReplay, SnapProtect) {
 
   // verify lock ordering constraints
   ASSERT_EQ(0, ictx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                            "snap2"));
+                                            "snap2", 0, no_op_progress));
   ASSERT_EQ(0, ictx->operations->snap_protect(cls::rbd::UserSnapshotNamespace(),
                                              "snap2"));
 }
@@ -396,8 +398,9 @@ TEST_F(TestJournalReplay, SnapUnprotect) {
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
   ASSERT_EQ(0, when_acquired_lock(ictx));
 
+  librbd::NoOpProgressContext no_op_progress;
   ASSERT_EQ(0, ictx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                            "snap"));
+                                            "snap", 0, no_op_progress));
   uint64_t snap_id;
   {
     std::shared_lock image_locker{ictx->image_lock};
@@ -436,7 +439,7 @@ TEST_F(TestJournalReplay, SnapUnprotect) {
 
   // verify lock ordering constraints
   ASSERT_EQ(0, ictx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                            "snap2"));
+                                            "snap2", 0, no_op_progress));
   ASSERT_EQ(0, ictx->operations->snap_protect(cls::rbd::UserSnapshotNamespace(),
                                              "snap2"));
   ASSERT_EQ(0, ictx->operations->snap_unprotect(cls::rbd::UserSnapshotNamespace(),
@@ -451,8 +454,9 @@ TEST_F(TestJournalReplay, SnapRename) {
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
   ASSERT_EQ(0, when_acquired_lock(ictx));
 
+  librbd::NoOpProgressContext no_op_progress;
   ASSERT_EQ(0, ictx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                            "snap"));
+                                            "snap", 0, no_op_progress));
   uint64_t snap_id;
   {
     std::shared_lock image_locker{ictx->image_lock};
@@ -500,8 +504,9 @@ TEST_F(TestJournalReplay, SnapRollback) {
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
   ASSERT_EQ(0, when_acquired_lock(ictx));
 
+  librbd::NoOpProgressContext no_op_progress;
   ASSERT_EQ(0, ictx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                            "snap"));
+                                            "snap", 0, no_op_progress));
 
   // get current commit position
   int64_t initial_tag;
@@ -527,7 +532,6 @@ TEST_F(TestJournalReplay, SnapRollback) {
   ASSERT_EQ(initial_entry + 2, current_entry);
 
   // verify lock ordering constraints
-  librbd::NoOpProgressContext no_op_progress;
   ASSERT_EQ(0, ictx->operations->snap_rollback(cls::rbd::UserSnapshotNamespace(),
                                               "snap",
                                               no_op_progress));
@@ -541,8 +545,9 @@ TEST_F(TestJournalReplay, SnapRemove) {
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
   ASSERT_EQ(0, when_acquired_lock(ictx));
 
+  librbd::NoOpProgressContext no_op_progress;
   ASSERT_EQ(0, ictx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                            "snap"));
+                                            "snap", 0, no_op_progress));
 
   // get current commit position
   int64_t initial_tag;
@@ -576,7 +581,7 @@ TEST_F(TestJournalReplay, SnapRemove) {
 
   // verify lock ordering constraints
   ASSERT_EQ(0, ictx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                            "snap"));
+                                            "snap", 0, no_op_progress));
   ASSERT_EQ(0, ictx->operations->snap_remove(cls::rbd::UserSnapshotNamespace(),
                                             "snap"));
 }
@@ -653,8 +658,9 @@ TEST_F(TestJournalReplay, Flatten) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
+  librbd::NoOpProgressContext no_op_progress;
   ASSERT_EQ(0, ictx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                            "snap"));
+                                            "snap", 0, no_op_progress));
   ASSERT_EQ(0, ictx->operations->snap_protect(cls::rbd::UserSnapshotNamespace(),
                                              "snap"));
 
index c0c77517c53803fc0e5f52b2c6be038fe5432135..85ff9884cc832396d52ae5910788b1e338275b54 100644 (file)
@@ -218,8 +218,9 @@ public:
   void expect_snap_create(MockReplayImageCtx &mock_image_ctx,
                           Context **on_finish, const char *snap_name,
                           uint64_t op_tid) {
-    EXPECT_CALL(*mock_image_ctx.operations, execute_snap_create(_, StrEq(snap_name), _,
-                                                                op_tid, 0, _))
+    EXPECT_CALL(*mock_image_ctx.operations,
+                execute_snap_create(_, StrEq(snap_name), _, op_tid,
+                                    SNAP_CREATE_FLAG_SKIP_NOTIFY_QUIESCE, _))
                   .WillOnce(DoAll(SaveArg<2>(on_finish),
                                   NotifyInvoke(&m_invoke_lock, &m_invoke_cond)));
   }
index a92be03304ff5e943bd8b54281bfabdd86fdd1e4..6649d24479aa5dbf45645bcdad9e9c02fb158715 100644 (file)
@@ -155,8 +155,8 @@ public:
   }
 
   void expect_create_snapshot(MockTestImageCtx &mock_image_ctx, int r) {
-    EXPECT_CALL(*mock_image_ctx.operations, snap_create(_, _, _))
-      .WillOnce(WithArg<2>(CompleteContext(
+    EXPECT_CALL(*mock_image_ctx.operations, snap_create(_, _, _, _, _))
+      .WillOnce(WithArg<4>(CompleteContext(
                              r, mock_image_ctx.image_ctx->op_work_queue)));
   }
 
index a79bd0cc45ff67bf5e4af96f1ca4d15c5c97b4c2..8006c35956e22a67f7bedd04dcddfb9650e33ea4 100644 (file)
@@ -146,18 +146,20 @@ public:
   }
 
   void expect_create_snapshot(MockTestImageCtx &mock_image_ctx, int r) {
-    EXPECT_CALL(*mock_image_ctx.operations, snap_create(_, _, _))
+    EXPECT_CALL(*mock_image_ctx.operations, snap_create(_, _, _, _, _))
       .WillOnce(DoAll(
                   Invoke([this, &mock_image_ctx, r](
                              const cls::rbd::SnapshotNamespace &ns,
                              const std::string& snap_name,
+                             uint64_t flags,
+                             ProgressContext &prog_ctx,
                              Context *on_finish) {
                            if (r != 0) {
                              return;
                            }
                            snap_create(mock_image_ctx, ns, snap_name);
                          }),
-                  WithArg<2>(CompleteContext(
+                  WithArg<4>(CompleteContext(
                                r, mock_image_ctx.image_ctx->op_work_queue))
                   ));
   }
index 93fd2fa4502791e1bce56ec8396d6bd3c05eb38e..99dc253d115748971e208ababe026b6260950733 100644 (file)
@@ -25,8 +25,10 @@ struct MockOperations {
                                     ProgressContext &prog_ctx,
                                     Context *on_finish,
                                     uint64_t journal_op_tid));
-  MOCK_METHOD3(snap_create, void(const cls::rbd::SnapshotNamespace &snapshot_namespace,
+  MOCK_METHOD5(snap_create, void(const cls::rbd::SnapshotNamespace &snapshot_namespace,
                                 const std::string &snap_name,
+                                 uint64_t flags,
+                                 ProgressContext &prog_ctx,
                                  Context *on_finish));
   MOCK_METHOD6(execute_snap_create, void(const cls::rbd::SnapshotNamespace &snapshot_namespace,
                                         const std::string &snap_name,
index e2032a084054c1c5d13e48c408ba4b7ed09015aa..efc9001a8857c8ededeacde92965c70f7b1e4ca6 100644 (file)
@@ -173,7 +173,7 @@ TEST_F(TestMockOperationSnapshotCreateRequest, Success) {
   expect_op_work_queue(mock_image_ctx);
 
   ::testing::InSequence seq;
-  expect_notify_quiesce(mock_image_ctx, 0);
+  expect_notify_quiesce(mock_image_ctx, -EINVAL);
   expect_block_writes(mock_image_ctx);
   expect_allocate_snap_id(mock_image_ctx, 0);
   expect_snap_create(mock_image_ctx, 0);
@@ -188,7 +188,7 @@ TEST_F(TestMockOperationSnapshotCreateRequest, Success) {
   librbd::NoOpProgressContext prog_ctx;
   MockSnapshotCreateRequest *req = new MockSnapshotCreateRequest(
     mock_image_ctx, &cond_ctx, cls::rbd::UserSnapshotNamespace(),
-    "snap1", 0, 0, prog_ctx);
+    "snap1", 0, SNAP_CREATE_FLAG_IGNORE_NOTIFY_QUIESCE_ERROR, prog_ctx);
   {
     std::shared_lock owner_locker{mock_image_ctx.owner_lock};
     req->send();
index 208998b5eac426dffa9c22b5654cf09ac7d85164..74c0108300dd17907a8d1537eac5e61ef4c5985e 100644 (file)
@@ -446,8 +446,9 @@ TEST_F(TestMockOperationSnapshotRemoveRequest, TrashCloneParent) {
 
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
+  NoOpProgressContext prog_ctx;
   ASSERT_EQ(0, ictx->operations->snap_create(
-                 {cls::rbd::TrashSnapshotNamespace{}}, "snap1"));
+                 {cls::rbd::TrashSnapshotNamespace{}}, "snap1", 0, prog_ctx));
   ASSERT_EQ(0, ictx->state->refresh_if_required());
 
   MockImageCtx mock_image_ctx(*ictx);
index 58a831ab78843b9f4c88c44e31c92a123df4001b..22bf95e1e24668233ed8f0d0f1b744217edf306e 100644 (file)
@@ -293,7 +293,7 @@ struct SnapCreateTask {
     std::shared_lock l{ictx->owner_lock};
     C_SaferCond ctx;
     ictx->image_watcher->notify_snap_create(0, cls::rbd::UserSnapshotNamespace(),
-                                            "snap", *progress_context, &ctx);
+                                            "snap", 0, *progress_context, &ctx);
     ASSERT_EQ(0, ctx.wait());
   }
 };
@@ -486,7 +486,7 @@ TEST_F(TestImageWatcher, NotifySnapCreateError) {
   C_SaferCond notify_ctx;
   librbd::NoOpProgressContext prog_ctx;
   ictx->image_watcher->notify_snap_create(0, cls::rbd::UserSnapshotNamespace(),
-       "snap", prog_ctx, &notify_ctx);
+                                          "snap", 0, prog_ctx, &notify_ctx);
   ASSERT_EQ(-EEXIST, notify_ctx.wait());
 
   NotifyOps expected_notify_ops;
index 82c6e6d278127b55cffa9d5777ae23d84b4c6328..15409d5676ffdae866006c21a55267f911b897aa 100644 (file)
@@ -85,8 +85,9 @@ int TestFixture::open_image(const std::string &image_name,
 
 int TestFixture::snap_create(librbd::ImageCtx &ictx,
                              const std::string &snap_name) {
+  librbd::NoOpProgressContext prog_ctx;
   return ictx.operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                     snap_name.c_str());
+                                     snap_name.c_str(), 0, prog_ctx);
 }
 
 int TestFixture::snap_protect(librbd::ImageCtx &ictx,
index 4d455de07730e332ef554adf9b09160a1f6214a0..ce6e939f8a83e6ddceebef1ff9126394ec4745e5 100644 (file)
@@ -1157,7 +1157,7 @@ TEST_F(TestInternal, WriteFullCopyup) {
 
   ASSERT_EQ(0, open_image(clone_name, &ictx2));
   ASSERT_EQ(0, ictx2->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                             "snap1"));
+                                             "snap1", 0, no_op));
 
   bufferlist write_full_bl;
   write_full_bl.append(std::string(1 << ictx2->order, '2'));
index e3ffc536098b8ad7e28ec6e00da06c27d2e016db..cbd9f12927bb6d77a61932e787c43e418ac264a1 100644 (file)
@@ -8341,8 +8341,6 @@ TEST_F(TestLibRBD, QuiesceWatchError)
     struct Watcher : public librbd::QuiesceWatchCtx {
       librbd::Image &image;
       int r;
-      mutex m_lock;
-      condition_variable m_cond;
       size_t quiesce_count = 0;
       size_t unquiesce_count = 0;
 
@@ -8350,24 +8348,12 @@ TEST_F(TestLibRBD, QuiesceWatchError)
       }
 
       void handle_quiesce() override {
-        lock_guard<mutex> locker(m_lock);
         quiesce_count++;
         image.quiesce_complete(r);
-        m_cond.notify_one();
       }
 
       void handle_unquiesce() override {
-        lock_guard<mutex> locker(m_lock);
         unquiesce_count++;
-        m_cond.notify_one();
-      }
-
-      void wait_for_unquiesce_count(size_t count) {
-        unique_lock<mutex> locker(m_lock);
-        ASSERT_TRUE(m_cond.wait_for(locker, seconds(60),
-                                    [this, count] {
-                                      return this->unquiesce_count == count;
-                                    }));
       }
     } watcher1(image1, -EINVAL), watcher2(image2, 0);
     uint64_t handle1, handle2;
@@ -8376,16 +8362,19 @@ TEST_F(TestLibRBD, QuiesceWatchError)
     ASSERT_EQ(0, image2.quiesce_watch(&watcher2, &handle2));
 
     ASSERT_EQ(-EINVAL, image1.snap_create("snap1"));
-    ASSERT_EQ(1U, watcher2.quiesce_count);
-    watcher2.wait_for_unquiesce_count(1U);
     ASSERT_EQ(1U, watcher1.quiesce_count);
     ASSERT_EQ(0U, watcher1.unquiesce_count);
+    ASSERT_EQ(1U, watcher2.quiesce_count);
+    ASSERT_EQ(1U, watcher2.unquiesce_count);
 
-    ASSERT_EQ(-EINVAL, image2.snap_create("snap2"));
-    ASSERT_EQ(2U, watcher2.quiesce_count);
-    watcher2.wait_for_unquiesce_count(2U);
+    PrintProgress prog_ctx;
+    ASSERT_EQ(0, image2.snap_create2("snap2",
+                                     RBD_SNAP_CREATE_IGNORE_QUIESCE_ERROR,
+                                     prog_ctx));
     ASSERT_EQ(2U, watcher1.quiesce_count);
     ASSERT_EQ(0U, watcher1.unquiesce_count);
+    ASSERT_EQ(2U, watcher2.quiesce_count);
+    ASSERT_EQ(2U, watcher2.unquiesce_count);
 
     ASSERT_EQ(0, image1.quiesce_unwatch(handle1));
 
@@ -8393,9 +8382,16 @@ TEST_F(TestLibRBD, QuiesceWatchError)
     ASSERT_EQ(3U, watcher2.quiesce_count);
     ASSERT_EQ(3U, watcher2.unquiesce_count);
 
+    ASSERT_EQ(0, image2.snap_create2("snap4", RBD_SNAP_CREATE_SKIP_QUIESCE,
+                                     prog_ctx));
+    ASSERT_EQ(3U, watcher2.quiesce_count);
+    ASSERT_EQ(3U, watcher2.unquiesce_count);
+
     ASSERT_EQ(0, image2.quiesce_unwatch(handle2));
 
+    ASSERT_EQ(0, image1.snap_remove("snap2"));
     ASSERT_EQ(0, image1.snap_remove("snap3"));
+    ASSERT_EQ(0, image1.snap_remove("snap4"));
   }
 
   ASSERT_EQ(0, rbd.remove(ioctx, name.c_str()));
index 18304f67dd7dc4c4e72c65761c13c9d690061c7d..87fde976fee7ee6c5462e9111f57db541d47cb35 100644 (file)
@@ -142,10 +142,11 @@ public:
   }
 
   void snap_create(librbd::ImageCtx *image_ctx, const std::string &snap_name) {
+    librbd::NoOpProgressContext prog_ctx;
     ASSERT_EQ(0, image_ctx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                                   snap_name.c_str()));
+                                                   snap_name, 0, prog_ctx));
     ASSERT_EQ(0, image_ctx->operations->snap_protect(cls::rbd::UserSnapshotNamespace(),
-                                                    snap_name.c_str()));
+                                                    snap_name));
     ASSERT_EQ(0, image_ctx->state->refresh());
   }
 
index ab952269d3d222a9b8d0f38885a82f6f76361328..b9f5add1fa00c93f829fdf8d2b784a52bdfd5f1f 100644 (file)
@@ -230,10 +230,11 @@ public:
   }
 
   void snap_create(librbd::ImageCtx *image_ctx, const std::string &snap_name) {
+    librbd::NoOpProgressContext prog_ctx;
     ASSERT_EQ(0, image_ctx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                                   snap_name.c_str()));
+                                                   snap_name, 0, prog_ctx));
     ASSERT_EQ(0, image_ctx->operations->snap_protect(cls::rbd::UserSnapshotNamespace(),
-                                                    snap_name.c_str()));
+                                                    snap_name));
     ASSERT_EQ(0, image_ctx->state->refresh());
   }
 
index 69c2f3883842dbef6d9314ff95c38285fc6001a4..9a4d920f8c2ad3d790781e7036da430c043e49ce 100644 (file)
@@ -77,8 +77,8 @@ public:
   }
 
   void expect_snap_create(librbd::MockTestImageCtx &mock_remote_image_ctx, int r) {
-    EXPECT_CALL(*mock_remote_image_ctx.operations, snap_create(_, _, _))
-      .WillOnce(WithArg<2>(CompleteContext(r)));
+    EXPECT_CALL(*mock_remote_image_ctx.operations, snap_create(_, _, _, _, _))
+      .WillOnce(WithArg<4>(CompleteContext(r)));
   }
 
   MockSyncPointCreateRequest *create_request(librbd::MockTestImageCtx &mock_remote_image_ctx,
index 9bd2658daedb4c0f48b17072f89ad7d8f8a44255..2febc6f32963160db83a52275a7aa7d83a19d17b 100644 (file)
@@ -170,12 +170,13 @@ public:
       ictx->set_journal_policy(new librbd::journal::DisabledPolicy());
     }
 
+    librbd::NoOpProgressContext prog_ctx;
     EXPECT_EQ(0, ictx->operations->snap_create(
-                   cls::rbd::UserSnapshotNamespace(), snap_name.c_str()));
+                   cls::rbd::UserSnapshotNamespace(), snap_name, 0, prog_ctx));
 
     if (protect) {
       EXPECT_EQ(0, ictx->operations->snap_protect(
-                     cls::rbd::UserSnapshotNamespace(), snap_name.c_str()));
+                     cls::rbd::UserSnapshotNamespace(), snap_name));
     }
 
     EXPECT_EQ(0, ictx->state->close());
@@ -190,8 +191,9 @@ public:
       ictx->set_journal_policy(new librbd::journal::DisabledPolicy());
     }
 
+    librbd::NoOpProgressContext prog_ctx;
     EXPECT_EQ(0, ictx->operations->snap_create(
-                   cls::rbd::UserSnapshotNamespace(), "snap1"));
+                   cls::rbd::UserSnapshotNamespace(), "snap1", 0, prog_ctx));
     EXPECT_EQ(0, ictx->operations->snap_protect(
                    cls::rbd::UserSnapshotNamespace(), "snap1"));
     EXPECT_EQ(0, librbd::api::Image<>::snap_set(
index 4498c7bef3aba4c57e3431653f2bb1c1d1dad3bd..592044c920b1dd060280684e9773d8c356b045c4 100644 (file)
@@ -1008,8 +1008,9 @@ TEST_F(TestImageReplayerJournal, MultipleReplayFailures_SingleEpoch) {
   librbd::ImageCtx *ictx;
   this->open_image(this->m_local_ioctx, this->m_image_name, false, &ictx);
   ictx->features &= ~RBD_FEATURE_JOURNALING;
+  librbd::NoOpProgressContext prog_ctx;
   ASSERT_EQ(0, ictx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                            "foo"));
+                                            "foo", 0, prog_ctx));
   ASSERT_EQ(0, ictx->operations->snap_protect(cls::rbd::UserSnapshotNamespace(),
                                              "foo"));
   ASSERT_EQ(0, librbd::cls_client::add_child(&ictx->md_ctx, RBD_CHILDREN,
@@ -1061,8 +1062,9 @@ TEST_F(TestImageReplayerJournal, MultipleReplayFailures_MultiEpoch) {
   librbd::ImageCtx *ictx;
   this->open_image(this->m_local_ioctx, this->m_image_name, false, &ictx);
   ictx->features &= ~RBD_FEATURE_JOURNALING;
+  librbd::NoOpProgressContext prog_ctx;
   ASSERT_EQ(0, ictx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                            "foo"));
+                                            "foo", 0, prog_ctx));
   ASSERT_EQ(0, ictx->operations->snap_protect(cls::rbd::UserSnapshotNamespace(),
                                              "foo"));
   ASSERT_EQ(0, librbd::cls_client::add_child(&ictx->md_ctx, RBD_CHILDREN,
@@ -1465,8 +1467,9 @@ TYPED_TEST(TestImageReplayer, SnapshotUnprotect) {
   this->open_remote_image(&remote_image_ctx);
 
   // create a protected snapshot
+  librbd::NoOpProgressContext prog_ctx;
   ASSERT_EQ(0, remote_image_ctx->operations->snap_create(
-                 cls::rbd::UserSnapshotNamespace{}, "snap1"));
+              cls::rbd::UserSnapshotNamespace{}, "snap1", 0, prog_ctx));
   ASSERT_EQ(0, remote_image_ctx->operations->snap_protect(
                  cls::rbd::UserSnapshotNamespace{}, "snap1"));
   this->flush(remote_image_ctx);
@@ -1508,8 +1511,9 @@ TYPED_TEST(TestImageReplayer, SnapshotProtect) {
   this->open_remote_image(&remote_image_ctx);
 
   // create an unprotected snapshot
+  librbd::NoOpProgressContext prog_ctx;
   ASSERT_EQ(0, remote_image_ctx->operations->snap_create(
-                 cls::rbd::UserSnapshotNamespace{}, "snap1"));
+                 cls::rbd::UserSnapshotNamespace{}, "snap1", 0, prog_ctx));
   this->flush(remote_image_ctx);
 
   this->create_replayer();
@@ -1549,8 +1553,9 @@ TYPED_TEST(TestImageReplayer, SnapshotRemove) {
   this->open_remote_image(&remote_image_ctx);
 
   // create a user snapshot
+  librbd::NoOpProgressContext prog_ctx;
   ASSERT_EQ(0, remote_image_ctx->operations->snap_create(
-                 cls::rbd::UserSnapshotNamespace{}, "snap1"));
+                 cls::rbd::UserSnapshotNamespace{}, "snap1", 0, prog_ctx));
   this->flush(remote_image_ctx);
 
   this->create_replayer();
@@ -1584,8 +1589,9 @@ TYPED_TEST(TestImageReplayer, SnapshotRename) {
   this->open_remote_image(&remote_image_ctx);
 
   // create a user snapshot
+  librbd::NoOpProgressContext prog_ctx;
   ASSERT_EQ(0, remote_image_ctx->operations->snap_create(
-                 cls::rbd::UserSnapshotNamespace{}, "snap1"));
+                 cls::rbd::UserSnapshotNamespace{}, "snap1", 0, prog_ctx));
   this->flush(remote_image_ctx);
 
   this->create_replayer();
index 493c675d0c4cba498e597c40d33e975e45fd0670..c29ed65afb25c7cc703a404183215c1654ca41cc 100644 (file)
@@ -170,10 +170,11 @@ public:
       librbd::ImageCtx *ictx = new librbd::ImageCtx(parent_image_name.c_str(),
                                                    "", "", pioctx, false);
       ictx->state->open(0);
+      librbd::NoOpProgressContext prog_ctx;
       EXPECT_EQ(0, ictx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                                snap_name.c_str()));
+                                                snap_name, 0, prog_ctx));
       EXPECT_EQ(0, ictx->operations->snap_protect(cls::rbd::UserSnapshotNamespace(),
-                                                 snap_name.c_str()));
+                                                 snap_name));
       ictx->state->close();
     }
 
index 092d41f5f651eda9496b0ea1c3d00481fea6401c..e271364033d119286da1b34fb5aa02dfaa888c7a 100644 (file)
@@ -8,6 +8,7 @@
 #include "librbd/ImageCtx.h"
 #include "librbd/ImageState.h"
 #include "librbd/Operations.h"
+#include "librbd/internal.h"
 #include "test/librados/test_cxx.h"
 #include "tools/rbd_mirror/Threads.h"
 
@@ -105,8 +106,9 @@ int TestFixture::open_image(librados::IoCtx &io_ctx,
 
 int TestFixture::create_snap(librbd::ImageCtx *image_ctx, const char* snap_name,
                              librados::snap_t *snap_id) {
+  librbd::NoOpProgressContext prog_ctx;
   int r = image_ctx->operations->snap_create(cls::rbd::UserSnapshotNamespace(),
-                                            snap_name);
+                                            snap_name, 0, prog_ctx);
   if (r < 0) {
     return r;
   }
index 3c8db97fc9c35369b00b0b9bf11bc413a5bb1a4a..1bd5d77f09418dd7d2781c829f94f1f2b64ab690 100644 (file)
@@ -113,7 +113,8 @@ void SyncPointCreateRequest<I>::send_create_snap() {
     SyncPointCreateRequest<I>, &SyncPointCreateRequest<I>::handle_create_snap>(
       this);
   m_remote_image_ctx->operations->snap_create(
-    cls::rbd::UserSnapshotNamespace(), sync_point.snap_name.c_str(), ctx);
+    cls::rbd::UserSnapshotNamespace(), sync_point.snap_name.c_str(),
+    librbd::SNAP_CREATE_FLAG_SKIP_NOTIFY_QUIESCE, m_prog_ctx, ctx);
 }
 
 template <typename I>
index 278795af967e11827f09d550655dfae7948c6231..9b52b837479af45ab33c5142c8baaca933f29885 100644 (file)
@@ -4,6 +4,7 @@
 #ifndef RBD_MIRROR_IMAGE_SYNC_SYNC_POINT_CREATE_REQUEST_H
 #define RBD_MIRROR_IMAGE_SYNC_SYNC_POINT_CREATE_REQUEST_H
 
+#include "librbd/internal.h"
 #include "Types.h"
 #include <string>
 
@@ -66,6 +67,7 @@ private:
   Context *m_on_finish;
 
   SyncPoints m_sync_points_copy;
+  librbd::NoOpProgressContext m_prog_ctx;
 
   void send_update_sync_points();
   void handle_update_sync_points(int r);