]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
tools/cephfs_mirror: Move dir_root to SyncMechanism
authorKotresh HR <khiremat@redhat.com>
Sat, 21 Feb 2026 08:19:19 +0000 (13:49 +0530)
committerKotresh HR <khiremat@redhat.com>
Sat, 21 Feb 2026 20:12:39 +0000 (01:42 +0530)
Store m_dir_root in parent (SyncMehansim) to make
it accessible in the data sync threads to sync
files

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 2ceab740e9ea01e4519d683653f508619a7c48f0..96a4a25c3b63527a693e7179d1f309793f1b0577 100644 (file)
@@ -1296,7 +1296,8 @@ int PeerReplayer::sync_perms(const std::string& path) {
   return 0;
 }
 
-PeerReplayer::SyncMechanism::SyncMechanism(MountRef local, MountRef remote, FHandles *fh,
+PeerReplayer::SyncMechanism::SyncMechanism(std::string_view dir_root,
+                                           MountRef local, MountRef remote, FHandles *fh,
                                            const Peer &peer, const Snapshot &current,
                                            boost::optional<Snapshot> prev)
     : m_local(local),
@@ -1305,7 +1306,8 @@ PeerReplayer::SyncMechanism::SyncMechanism(MountRef local, MountRef remote, FHan
       m_peer(peer),
       m_current(current),
       m_prev(prev),
-      sdq_lock(ceph::make_mutex("cephfs::mirror::PeerReplayer::SyncMechanism" + stringify(peer.uuid))) {
+      sdq_lock(ceph::make_mutex("cephfs::mirror::PeerReplayer::SyncMechanism" + stringify(peer.uuid))),
+      m_dir_root(dir_root) {
   }
 
 PeerReplayer::SyncMechanism::~SyncMechanism() {
@@ -1366,8 +1368,7 @@ int PeerReplayer::SyncMechanism::get_changed_blocks(const std::string &epath,
 PeerReplayer::SnapDiffSync::SnapDiffSync(std::string_view dir_root, MountRef local, MountRef remote,
                                          FHandles *fh, const Peer &peer, const Snapshot &current,
                                          boost::optional<Snapshot> prev)
-  : SyncMechanism(local, remote, fh, peer, current, prev),
-    m_dir_root(dir_root) {
+  : SyncMechanism(dir_root, local, remote, fh, peer, current, prev) {
 }
 
 PeerReplayer::SnapDiffSync::~SnapDiffSync() {
@@ -1665,10 +1666,11 @@ void PeerReplayer::SnapDiffSync::finish_crawl() {
   mark_crawl_finished();
 }
 
-PeerReplayer::RemoteSync::RemoteSync(MountRef local, MountRef remote, FHandles *fh,
+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(local, remote, fh, peer, current, prev) {
+  : SyncMechanism(dir_root, local, remote, fh, peer, current, prev) {
 }
 
 PeerReplayer::RemoteSync::~RemoteSync() {
@@ -1846,8 +1848,8 @@ int PeerReplayer::do_synchronize(const std::string &dir_root, const Snapshot &cu
                                           &fh, m_peer, current, prev);
 
   } else {
-    syncm = std::make_shared<RemoteSync>(m_local_mount, m_remote_mount, &fh,
-                                             m_peer, current, boost::none);
+    syncm = std::make_shared<RemoteSync>(dir_root, m_local_mount, m_remote_mount,
+                                         &fh, m_peer, current, boost::none);
   }
 
   r = syncm->init_sync();
index b95316abbca887ce3e5657b39f8c4e96fc5f9032..b107d7cefcfe68880a5988034f4c861f586d16e3 100644 (file)
@@ -178,7 +178,8 @@ private:
 
   class SyncMechanism {
   public:
-    SyncMechanism(MountRef local, MountRef remote, FHandles *fh,
+    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);
     virtual ~SyncMechanism() = 0;
@@ -219,6 +220,9 @@ private:
     ceph::mutex& get_sdq_lock() {
       return sdq_lock;
     }
+    std::string_view get_m_dir_root() {
+      return m_dir_root;
+    }
 
     int remote_mkdir(const std::string &epath, const struct ceph_statx &stx);
   protected:
@@ -235,11 +239,14 @@ private:
     std::queue<PeerReplayer::SyncEntry> m_sync_dataq;
     int m_in_flight = 0;
     bool m_crawl_finished = false;
+    // 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(MountRef local, MountRef remote, FHandles *fh,
+    RemoteSync(std::string_view dir_root,
+               MountRef local, MountRef remote, FHandles *fh,
                const Peer &peer, /* keep dout happy */
                const Snapshot &current, boost::optional<Snapshot> prev);
     ~RemoteSync();
@@ -278,7 +285,6 @@ private:
     int next_entry(SyncEntry &entry, std::string *e_name, snapid_t *snapid);
     void fini_directory(SyncEntry &entry);
 
-    std::string m_dir_root;
     std::map<std::string, std::set<std::string>> m_deleted;
   };