]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: helper for retrieving the image sync snap name prefix
authorJason Dillaman <dillaman@redhat.com>
Wed, 29 Jan 2020 19:52:31 +0000 (14:52 -0500)
committerJason Dillaman <dillaman@redhat.com>
Thu, 30 Jan 2020 15:26:36 +0000 (10:26 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/tools/rbd_mirror/CMakeLists.txt
src/tools/rbd_mirror/image_sync/SyncPointCreateRequest.cc
src/tools/rbd_mirror/image_sync/Utils.cc [new file with mode: 0644]
src/tools/rbd_mirror/image_sync/Utils.h [new file with mode: 0644]

index 9211718d12e64ad8ae7eed4394e06a1260607f55..8d0007077f22ddf8c2ba07dbe120a76f96a9cb93 100644 (file)
@@ -54,6 +54,7 @@ set(rbd_mirror_internal
   image_replayer/snapshot/StateBuilder.cc
   image_sync/SyncPointCreateRequest.cc
   image_sync/SyncPointPruneRequest.cc
+  image_sync/Utils.cc
   pool_watcher/RefreshImagesRequest.cc
   service_daemon/Types.cc)
 
index 53153b0c678653a6b7226637236110e554eb04d0..3c8db97fc9c35369b00b0b9bf11bc413a5bb1a4a 100644 (file)
@@ -10,6 +10,7 @@
 #include "librbd/Operations.h"
 #include "librbd/Utils.h"
 #include "tools/rbd_mirror/image_sync/Types.h"
+#include "tools/rbd_mirror/image_sync/Utils.h"
 
 #define dout_context g_ceph_context
 #define dout_subsys ceph_subsys_rbd_mirror
@@ -21,12 +22,6 @@ namespace rbd {
 namespace mirror {
 namespace image_sync {
 
-namespace {
-
-static const std::string SNAP_NAME_PREFIX(".rbd-mirror");
-
-} // anonymous namespace
-
 using librbd::util::create_context_callback;
 
 template <typename I>
@@ -61,7 +56,7 @@ void SyncPointCreateRequest<I>::send_update_sync_points() {
   uuid_gen.generate_random();
 
   auto& sync_point = m_sync_points_copy.back();
-  sync_point.snap_name = SNAP_NAME_PREFIX + "." + m_local_mirror_uuid + "." +
+  sync_point.snap_name = util::get_snapshot_name_prefix(m_local_mirror_uuid) +
                          uuid_gen.to_string();
 
   auto ctx = create_context_callback<
diff --git a/src/tools/rbd_mirror/image_sync/Utils.cc b/src/tools/rbd_mirror/image_sync/Utils.cc
new file mode 100644 (file)
index 0000000..6a3eae7
--- /dev/null
@@ -0,0 +1,24 @@
+// -*- mode:c++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "Utils.h"
+
+namespace rbd {
+namespace mirror {
+namespace image_sync {
+namespace util {
+
+namespace {
+
+static const std::string SNAP_NAME_PREFIX(".rbd-mirror");
+
+} // anonymous namespace
+
+std::string get_snapshot_name_prefix(const std::string& local_mirror_uuid) {
+  return SNAP_NAME_PREFIX + "." + local_mirror_uuid + ".";
+}
+
+} // namespace util
+} // namespace image_sync
+} // namespace mirror
+} // namespace rbd
diff --git a/src/tools/rbd_mirror/image_sync/Utils.h b/src/tools/rbd_mirror/image_sync/Utils.h
new file mode 100644 (file)
index 0000000..139699d
--- /dev/null
@@ -0,0 +1,16 @@
+// -*- mode:c++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include <string>
+
+namespace rbd {
+namespace mirror {
+namespace image_sync {
+namespace util {
+
+std::string get_snapshot_name_prefix(const std::string& local_mirror_uuid);
+
+} // namespace util
+} // namespace image_sync
+} // namespace mirror
+} // namespace rbd