]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/cephfs_mirror: Store a reference of PeerReplayer object in SyncMechanism
authorKotresh HR <khiremat@redhat.com>
Sat, 21 Feb 2026 14:03:39 +0000 (19:33 +0530)
committerKotresh HR <khiremat@redhat.com>
Sun, 22 Feb 2026 18:56:35 +0000 (00:26 +0530)
Store a reference of PeerReplayer object in SyncMechanism.
This allows SyncMechansim object to call functions of PeerReplayer.
This is required in multiple places like handling
shutdown/blocklist/cancel where should_backoff() needs to be
called by syncm object while poppig dataq by data sync threads.

Fixes: https://tracker.ceph.com/issues/73452
Signed-off-by: Kotresh HR <khiremat@redhat.com>
src/tools/cephfs_mirror/PeerReplayer.cc
src/tools/cephfs_mirror/PeerReplayer.h

index 5b8a56479c08c70ff6f439a410806ca1974c6ca5..4338806549b5d389a819060af72749cd53be1266 100644 (file)
@@ -1300,18 +1300,19 @@ int PeerReplayer::sync_perms(const std::string& path) {
   return 0;
 }
 
-PeerReplayer::SyncMechanism::SyncMechanism(std::string_view dir_root,
+PeerReplayer::SyncMechanism::SyncMechanism(PeerReplayer& peer_replayer, std::string_view dir_root,
                                            MountRef local, MountRef remote, FHandles *fh,
                                            const Peer &peer, const Snapshot &current,
                                            boost::optional<Snapshot> prev)
-    : m_local(local),
+    : m_peer_replayer(peer_replayer),
+      m_dir_root(dir_root),
+      m_local(local),
       m_remote(remote),
       m_fh(fh),
       m_peer(peer),
       m_current(current),
       m_prev(prev),
-      sdq_lock(ceph::make_mutex("cephfs::mirror::PeerReplayer::SyncMechanism" + stringify(peer.uuid))),
-      m_dir_root(dir_root) {
+      sdq_lock(ceph::make_mutex("cephfs::mirror::PeerReplayer::SyncMechanism" + stringify(peer.uuid))) {
   }
 
 PeerReplayer::SyncMechanism::~SyncMechanism() {
@@ -1412,10 +1413,11 @@ int PeerReplayer::SyncMechanism::get_changed_blocks(const std::string &epath,
   return callback(block.num_blocks, block.b);
 }
 
-PeerReplayer::SnapDiffSync::SnapDiffSync(std::string_view dir_root, MountRef local, MountRef remote,
-                                         FHandles *fh, const Peer &peer, const Snapshot &current,
+PeerReplayer::SnapDiffSync::SnapDiffSync(PeerReplayer& peer_replayer, std::string_view dir_root,
+                                         MountRef local, MountRef remote, FHandles *fh,
+                                         const Peer &peer, const Snapshot &current,
                                          boost::optional<Snapshot> prev)
-  : SyncMechanism(dir_root, local, remote, fh, peer, current, prev) {
+  : SyncMechanism(peer_replayer, dir_root, local, remote, fh, peer, current, prev) {
 }
 
 PeerReplayer::SnapDiffSync::~SnapDiffSync() {
@@ -1722,11 +1724,11 @@ void PeerReplayer::SnapDiffSync::finish_crawl(int ret) {
   mark_crawl_finished(ret);
 }
 
-PeerReplayer::RemoteSync::RemoteSync(std::string_view dir_root,
-                                       MountRef local, MountRef remote, FHandles *fh,
-                                       const Peer &peer, const Snapshot &current,
-                                       boost::optional<Snapshot> prev)
-  : SyncMechanism(dir_root, local, remote, fh, peer, current, prev) {
+PeerReplayer::RemoteSync::RemoteSync(PeerReplayer& peer_replayer, std::string_view dir_root,
+                                     MountRef local, MountRef remote, FHandles *fh,
+                                     const Peer &peer, const Snapshot &current,
+                                     boost::optional<Snapshot> prev)
+  : SyncMechanism(peer_replayer, dir_root, local, remote, fh, peer, current, prev) {
 }
 
 PeerReplayer::RemoteSync::~RemoteSync() {
@@ -1900,11 +1902,10 @@ int PeerReplayer::do_synchronize(const std::string &dir_root, const Snapshot &cu
 
   std::shared_ptr<SyncMechanism> syncm;
   if (fh.p_mnt == m_local_mount) {
-    syncm = std::make_shared<SnapDiffSync>(dir_root, m_local_mount, m_remote_mount,
-                                          &fh, m_peer, current, prev);
-
+    syncm = std::make_shared<SnapDiffSync>(*this, dir_root, m_local_mount, m_remote_mount,
+                                           &fh, m_peer, current, prev);
   } else {
-    syncm = std::make_shared<RemoteSync>(dir_root, m_local_mount, m_remote_mount,
+    syncm = std::make_shared<RemoteSync>(*this, dir_root, m_local_mount, m_remote_mount,
                                          &fh, m_peer, current, boost::none);
   }
 
index f5d5db228294324196f08ff63df82a1db6d267a4..06873df50e07e894b59b58b095a1db81043214eb 100644 (file)
@@ -186,10 +186,10 @@ private:
 
   class SyncMechanism {
   public:
-    SyncMechanism(std::string_view dir_root,
-                  MountRef local, MountRef remote, FHandles *fh,
-                  const Peer &peer, /* keep dout happy */
-                  const Snapshot &current, boost::optional<Snapshot> prev);
+    explicit SyncMechanism(PeerReplayer& peer_replayer, std::string_view dir_root,
+                           MountRef local, MountRef remote, FHandles *fh,
+                           const Peer &peer, /* keep dout happy */
+                           const Snapshot &current, boost::optional<Snapshot> prev);
     virtual ~SyncMechanism() = 0;
 
     virtual int init_sync() = 0;
@@ -263,6 +263,9 @@ private:
 
     int remote_mkdir(const std::string &epath, const struct ceph_statx &stx);
   protected:
+    PeerReplayer& m_peer_replayer;
+    // It's not used in RemoteSync but required to be accessed in datasync threads
+    std::string m_dir_root;
     MountRef m_local;
     MountRef m_remote;
     FHandles *m_fh;
@@ -280,13 +283,11 @@ private:
     bool m_sync_done = false;
     bool m_datasync_error = false;
     int m_datasync_errno = 0;
-    // It's not used in RemoteSync but required to be accessed in datasync threads
-    std::string m_dir_root;
   };
 
   class RemoteSync : public SyncMechanism {
   public:
-    RemoteSync(std::string_view dir_root,
+    RemoteSync(PeerReplayer& peer_replayer, std::string_view dir_root,
                MountRef local, MountRef remote, FHandles *fh,
                const Peer &peer, /* keep dout happy */
                const Snapshot &current, boost::optional<Snapshot> prev);
@@ -303,8 +304,8 @@ private:
 
   class SnapDiffSync : public SyncMechanism {
   public:
-    SnapDiffSync(std::string_view dir_root, MountRef local, MountRef remote,
-                 FHandles *fh, const Peer &peer, const Snapshot &current,
+    SnapDiffSync(PeerReplayer& peer_replayer, std::string_view dir_root, MountRef local,
+                 MountRef remote, FHandles *fh, const Peer &peer, const Snapshot &current,
                  boost::optional<Snapshot> prev);
     ~SnapDiffSync();