From: Kotresh HR Date: Sat, 21 Feb 2026 08:19:19 +0000 (+0530) Subject: tools/cephfs_mirror: Move dir_root to SyncMechanism X-Git-Tag: testing/wip-vshankar-testing-20260224.100235^2~21 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=898b3917c69a277ecf41c26f338ab5d52a12d033;p=ceph-ci.git tools/cephfs_mirror: Move dir_root to SyncMechanism 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 --- diff --git a/src/tools/cephfs_mirror/PeerReplayer.cc b/src/tools/cephfs_mirror/PeerReplayer.cc index 2ceab740e9e..96a4a25c3b6 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.cc +++ b/src/tools/cephfs_mirror/PeerReplayer.cc @@ -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 ¤t, boost::optional 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 ¤t, boost::optional 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 ¤t, boost::optional 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(m_local_mount, m_remote_mount, &fh, - m_peer, current, boost::none); + syncm = std::make_shared(dir_root, m_local_mount, m_remote_mount, + &fh, m_peer, current, boost::none); } r = syncm->init_sync(); diff --git a/src/tools/cephfs_mirror/PeerReplayer.h b/src/tools/cephfs_mirror/PeerReplayer.h index b95316abbca..b107d7cefcf 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.h +++ b/src/tools/cephfs_mirror/PeerReplayer.h @@ -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 ¤t, boost::optional 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 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 ¤t, boost::optional 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> m_deleted; };