]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
tools/cephfs_mirror: Store a reference of PeerReplayer object in SyncMechanism
authorKotresh HR <khiremat@redhat.com>
Sun, 15 Feb 2026 04:00:25 +0000 (09:30 +0530)
committerKotresh HR <khiremat@redhat.com>
Tue, 17 Feb 2026 20:10:51 +0000 (01:40 +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 69c3f1f9e6c038ae71c865f7076386c02408a2ef..52b61d39bdd29cc55ac0f93232ac0e484f98c264 100644 (file)
@@ -1306,18 +1306,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() {
@@ -1418,10 +1419,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() {
@@ -1728,11 +1730,11 @@ void PeerReplayer::SnapDiffSync::finish_sync(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() {
@@ -1906,11 +1908,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 e294e5bd0763d83805818089a97d120c24cd38f0..3bb16867ffbf0a3fe645049abbfa9060ad1fa5e1 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;
@@ -265,6 +265,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;
@@ -282,13 +285,11 @@ private:
     bool m_take_snapshot = 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);
@@ -305,8 +306,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();