]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: pass clean_since_snap_id to CreatePrimaryRequest
authorJason Dillaman <dillaman@redhat.com>
Wed, 22 Apr 2020 15:42:17 +0000 (11:42 -0400)
committerJason Dillaman <dillaman@redhat.com>
Thu, 23 Apr 2020 17:19:49 +0000 (13:19 -0400)
This will be stored in the primary MirrorSnapshotNamespace for use by
the rbd-mirror snapshot replayer.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/api/Mirror.cc
src/librbd/mirror/EnableRequest.cc
src/librbd/mirror/snapshot/CreatePrimaryRequest.cc
src/librbd/mirror/snapshot/CreatePrimaryRequest.h
src/librbd/mirror/snapshot/DemoteRequest.cc
src/librbd/mirror/snapshot/PromoteRequest.cc
src/test/librbd/mirror/snapshot/test_mock_CreatePrimaryRequest.cc
src/test/librbd/mirror/snapshot/test_mock_PromoteRequest.cc
src/test/librbd/mirror/snapshot/test_mock_Utils.cc

index cc6c4da4e4415296ac2de97ecd1775fc430917f1..9289e80507392ab86d037386029f39c679fb02e4 100644 (file)
@@ -1997,7 +1997,7 @@ int Mirror<I>::image_snapshot_create(I *ictx, uint64_t *snap_id) {
 
   C_SaferCond on_finish;
   auto req = mirror::snapshot::CreatePrimaryRequest<I>::create(
-    ictx, mirror_image.global_image_id, 0U, snap_id, &on_finish);
+    ictx, mirror_image.global_image_id, CEPH_NOSNAP, 0U, snap_id, &on_finish);
   req->send();
   return on_finish.wait();
 }
index b99f9d71b306d4a90c4087e56667355ce992e079..1c6dcfe6766cab355e3a280ca6611e16d5cba4ab 100644 (file)
@@ -188,7 +188,7 @@ void EnableRequest<I>::create_primary_snapshot() {
     EnableRequest<I>,
     &EnableRequest<I>::handle_create_primary_snapshot>(this);
   auto req = snapshot::CreatePrimaryRequest<I>::create(
-    m_image_ctx, m_mirror_image.global_image_id,
+    m_image_ctx, m_mirror_image.global_image_id, CEPH_NOSNAP,
     snapshot::CREATE_PRIMARY_FLAG_IGNORE_EMPTY_PEERS, &m_snap_id, ctx);
   req->send();
 }
index 6c5cb5d9d50c3e975dd686dc1308e80d8040cfb4..c9937e6a6548dd8a6a9911059c1404713cd1feea 100644 (file)
@@ -27,10 +27,12 @@ using librbd::util::create_rados_callback;
 
 template <typename I>
 CreatePrimaryRequest<I>::CreatePrimaryRequest(
-    I *image_ctx, const std::string& global_image_id, uint32_t flags,
-    uint64_t *snap_id, Context *on_finish)
+    I *image_ctx, const std::string& global_image_id,
+    uint64_t clean_since_snap_id, uint32_t flags, uint64_t *snap_id,
+    Context *on_finish)
   : m_image_ctx(image_ctx), m_global_image_id(global_image_id),
-    m_flags(flags), m_snap_id(snap_id), m_on_finish(on_finish) {
+    m_clean_since_snap_id(clean_since_snap_id), m_flags(flags),
+    m_snap_id(snap_id), m_on_finish(on_finish) {
   m_default_ns_ctx.dup(m_image_ctx->md_ctx);
   m_default_ns_ctx.set_namespace("");
 }
@@ -111,7 +113,7 @@ void CreatePrimaryRequest<I>::create_snapshot() {
     ((m_flags & CREATE_PRIMARY_FLAG_DEMOTED) != 0 ?
       cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY_DEMOTED :
       cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY),
-    m_mirror_peer_uuids, "", CEPH_NOSNAP};
+    m_mirror_peer_uuids, "", m_clean_since_snap_id};
 
   CephContext *cct = m_image_ctx->cct;
   ldout(cct, 20) << "name=" << m_snap_name << ", "
index 69c0ed4470198423a80bad74b558599d657f4a14..94e85c9d9d447dd392784f86b9d4b761df590951 100644 (file)
@@ -26,15 +26,18 @@ class CreatePrimaryRequest {
 public:
   static CreatePrimaryRequest *create(ImageCtxT *image_ctx,
                                       const std::string& global_image_id,
+                                      uint64_t clean_since_snap_id,
                                       uint32_t flags, uint64_t *snap_id,
                                       Context *on_finish) {
-    return new CreatePrimaryRequest(image_ctx, global_image_id, flags, snap_id,
+    return new CreatePrimaryRequest(image_ctx, global_image_id,
+                                    clean_since_snap_id, flags, snap_id,
                                     on_finish);
   }
 
   CreatePrimaryRequest(ImageCtxT *image_ctx,
                        const std::string& global_image_id,
-                       uint32_t flags, uint64_t *snap_id, Context *on_finish);
+                       uint64_t clean_since_snap_id, uint32_t flags,
+                       uint64_t *snap_id, Context *on_finish);
 
   void send();
 
@@ -64,6 +67,7 @@ private:
 
   ImageCtxT *m_image_ctx;
   std::string m_global_image_id;
+  uint64_t m_clean_since_snap_id;
   const uint32_t m_flags;
   uint64_t *m_snap_id;
   Context *m_on_finish;
index 23cbd1d479766f4e455dd63f7601decad275d9be..17d157d41e17e4ada8709e6b5ef85cf4acb30a71 100644 (file)
@@ -72,7 +72,7 @@ void DemoteRequest<I>::create_snapshot() {
     DemoteRequest<I>, &DemoteRequest<I>::handle_create_snapshot>(this);
 
   auto req = CreatePrimaryRequest<I>::create(
-    m_image_ctx, m_global_image_id,
+    m_image_ctx, m_global_image_id, CEPH_NOSNAP,
     (snapshot::CREATE_PRIMARY_FLAG_IGNORE_EMPTY_PEERS |
      snapshot::CREATE_PRIMARY_FLAG_DEMOTED), nullptr, ctx);
   req->send();
index ef62c0813960bb285c054656a0f91bc5e6c276dc..f9cf4b5b973dd67d66dcf228bb1df16a978581f2 100644 (file)
@@ -295,7 +295,7 @@ void PromoteRequest<I>::create_promote_snapshot() {
     &PromoteRequest<I>::handle_create_promote_snapshot>(this);
 
   auto req = CreatePrimaryRequest<I>::create(
-    m_image_ctx, m_global_image_id,
+    m_image_ctx, m_global_image_id, CEPH_NOSNAP,
     (snapshot::CREATE_PRIMARY_FLAG_IGNORE_EMPTY_PEERS |
      snapshot::CREATE_PRIMARY_FLAG_FORCE), nullptr, ctx);
   req->send();
index 6e69e800256398a0470dd9ed4780a11ae17f71a9..a79bd0cc45ff67bf5e4af96f1ca4d15c5c97b4c2 100644 (file)
@@ -210,8 +210,8 @@ TEST_F(TestMockMirrorSnapshotCreatePrimaryRequest, Success) {
   expect_create_snapshot(mock_image_ctx, 0);
 
   C_SaferCond ctx;
-  auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", 0U, nullptr,
-                                          &ctx);
+  auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", CEPH_NOSNAP,
+                                          0U, nullptr, &ctx);
   req->send();
   ASSERT_EQ(0, ctx.wait());
 }
@@ -231,8 +231,8 @@ TEST_F(TestMockMirrorSnapshotCreatePrimaryRequest, CanNotError) {
   expect_can_create_primary_snapshot(mock_utils, false, false, false);
 
   C_SaferCond ctx;
-  auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", 0U, nullptr,
-                                          &ctx);
+  auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", CEPH_NOSNAP,
+                                          0U, nullptr, &ctx);
   req->send();
   ASSERT_EQ(-EINVAL, ctx.wait());
 }
@@ -255,8 +255,8 @@ TEST_F(TestMockMirrorSnapshotCreatePrimaryRequest, GetMirrorPeersError) {
                             "mirror", "mirror uuid"}}, -EINVAL);
 
   C_SaferCond ctx;
-  auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", 0U, nullptr,
-                                          &ctx);
+  auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", CEPH_NOSNAP,
+                                          0U, nullptr, &ctx);
   req->send();
   ASSERT_EQ(-EINVAL, ctx.wait());
 }
@@ -280,8 +280,8 @@ TEST_F(TestMockMirrorSnapshotCreatePrimaryRequest, CreateSnapshotError) {
   expect_create_snapshot(mock_image_ctx, -EINVAL);
 
   C_SaferCond ctx;
-  auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", 0U, nullptr,
-                                          &ctx);
+  auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", CEPH_NOSNAP,
+                                          0U, nullptr, &ctx);
   req->send();
   ASSERT_EQ(-EINVAL, ctx.wait());
 }
@@ -315,8 +315,8 @@ TEST_F(TestMockMirrorSnapshotCreatePrimaryRequest, SuccessUnlinkPeer) {
   expect_unlink_peer(mock_image_ctx, mock_unlink_peer_request, snap_id, "uuid",
                      0);
   C_SaferCond ctx;
-  auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", 0U, nullptr,
-                                          &ctx);
+  auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", CEPH_NOSNAP,
+                                          0U, nullptr, &ctx);
   req->send();
   ASSERT_EQ(0, ctx.wait());
 }
index 3e1faf4873ecf1d31ea2ab74c8acd69b03cb5cd5..0965ab4644bede272ea9084605a0f58c672ebdd2 100644 (file)
@@ -122,6 +122,7 @@ struct CreatePrimaryRequest<MockTestImageCtx> {
   static CreatePrimaryRequest* s_instance;
   static CreatePrimaryRequest *create(MockTestImageCtx *image_ctx,
                                       const std::string& global_image_id,
+                                      uint64_t clean_since_snap_id,
                                       uint32_t flags, uint64_t *snap_id,
                                       Context *on_finish) {
     ceph_assert(s_instance != nullptr);
index d2374332a10ce790fc1e6807d69c2a9e6e777890..410dc3eba723999ebdadef05ee28c0393d7d71c3 100644 (file)
@@ -8,7 +8,6 @@
 #include "test/librbd/mock/MockOperations.h"
 #include "test/librados_test_stub/MockTestMemIoCtxImpl.h"
 #include "test/librados_test_stub/MockTestMemRadosClient.h"
-#include "librbd/mirror/snapshot/CreatePrimaryRequest.h"
 #include "librbd/mirror/snapshot/UnlinkPeerRequest.h"
 #include "librbd/mirror/snapshot/Utils.h"