From: Jason Dillaman Date: Wed, 29 Jan 2020 19:52:31 +0000 (-0500) Subject: rbd-mirror: helper for retrieving the image sync snap name prefix X-Git-Tag: v15.1.1~472^2~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f2d9d167c21ccfeb9229bd7b4727b82d863e2c7a;p=ceph.git rbd-mirror: helper for retrieving the image sync snap name prefix Signed-off-by: Jason Dillaman --- diff --git a/src/tools/rbd_mirror/CMakeLists.txt b/src/tools/rbd_mirror/CMakeLists.txt index 9211718d12e6..8d0007077f22 100644 --- a/src/tools/rbd_mirror/CMakeLists.txt +++ b/src/tools/rbd_mirror/CMakeLists.txt @@ -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) diff --git a/src/tools/rbd_mirror/image_sync/SyncPointCreateRequest.cc b/src/tools/rbd_mirror/image_sync/SyncPointCreateRequest.cc index 53153b0c6786..3c8db97fc9c3 100644 --- a/src/tools/rbd_mirror/image_sync/SyncPointCreateRequest.cc +++ b/src/tools/rbd_mirror/image_sync/SyncPointCreateRequest.cc @@ -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 @@ -61,7 +56,7 @@ void SyncPointCreateRequest::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 index 000000000000..6a3eae72d669 --- /dev/null +++ b/src/tools/rbd_mirror/image_sync/Utils.cc @@ -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 index 000000000000..139699daa7b1 --- /dev/null +++ b/src/tools/rbd_mirror/image_sync/Utils.h @@ -0,0 +1,16 @@ +// -*- mode:c++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#include + +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