From cb13af3bd153fbaf369e4c7d6bad391b2a24ce0c Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Wed, 14 Jan 2026 16:41:50 +0530 Subject: [PATCH] tools/cephfs_mirror: Move remote_mkdir to SyncMechanism This is required as SyncMechanism::get_entry would sync directories during crawl. Fixes: https://tracker.ceph.com/issues/73452 Signed-off-by: Kotresh HR --- src/tools/cephfs_mirror/PeerReplayer.cc | 13 ++++++------- src/tools/cephfs_mirror/PeerReplayer.h | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/tools/cephfs_mirror/PeerReplayer.cc b/src/tools/cephfs_mirror/PeerReplayer.cc index 0ac65efd456..92d53ff1cf7 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.cc +++ b/src/tools/cephfs_mirror/PeerReplayer.cc @@ -636,18 +636,17 @@ int PeerReplayer::propagate_snap_renames( return 0; } -int PeerReplayer::remote_mkdir(const std::string &epath, const struct ceph_statx &stx, - const FHandles &fh) { +int PeerReplayer::SyncMechanism::remote_mkdir(const std::string &epath, const struct ceph_statx &stx) { dout(10) << ": remote epath=" << epath << dendl; - int r = ceph_mkdirat(m_remote_mount, fh.r_fd_dir_root, epath.c_str(), stx.stx_mode & ~S_IFDIR); + int r = ceph_mkdirat(m_remote, m_fh->r_fd_dir_root, epath.c_str(), stx.stx_mode & ~S_IFDIR); if (r < 0 && r != -EEXIST) { derr << ": failed to create remote directory=" << epath << ": " << cpp_strerror(r) << dendl; return r; } - r = ceph_chownat(m_remote_mount, fh.r_fd_dir_root, epath.c_str(), stx.stx_uid, stx.stx_gid, + r = ceph_chownat(m_remote, m_fh->r_fd_dir_root, epath.c_str(), stx.stx_uid, stx.stx_gid, AT_SYMLINK_NOFOLLOW); if (r < 0) { derr << ": failed to chown remote directory=" << epath << ": " << cpp_strerror(r) @@ -655,7 +654,7 @@ int PeerReplayer::remote_mkdir(const std::string &epath, const struct ceph_statx return r; } - r = ceph_chmodat(m_remote_mount, fh.r_fd_dir_root, epath.c_str(), stx.stx_mode & ~S_IFMT, + r = ceph_chmodat(m_remote, m_fh->r_fd_dir_root, epath.c_str(), stx.stx_mode & ~S_IFMT, AT_SYMLINK_NOFOLLOW); if (r < 0) { derr << ": failed to chmod remote directory=" << epath << ": " << cpp_strerror(r) @@ -665,7 +664,7 @@ int PeerReplayer::remote_mkdir(const std::string &epath, const struct ceph_statx struct timespec times[] = {{stx.stx_atime.tv_sec, stx.stx_atime.tv_nsec}, {stx.stx_mtime.tv_sec, stx.stx_mtime.tv_nsec}}; - r = ceph_utimensat(m_remote_mount, fh.r_fd_dir_root, epath.c_str(), times, AT_SYMLINK_NOFOLLOW); + r = ceph_utimensat(m_remote, m_fh->r_fd_dir_root, epath.c_str(), times, AT_SYMLINK_NOFOLLOW); if (r < 0) { derr << ": failed to change [am]time on remote directory=" << epath << ": " << cpp_strerror(r) << dendl; @@ -1882,7 +1881,7 @@ int PeerReplayer::do_synchronize(const std::string &dir_root, const Snapshot &cu } if (S_ISDIR(stx.stx_mode)) { - r = remote_mkdir(epath, stx, fh); + r = syncm->remote_mkdir(epath, stx); if (r < 0) { break; } diff --git a/src/tools/cephfs_mirror/PeerReplayer.h b/src/tools/cephfs_mirror/PeerReplayer.h index f75a508753f..34a27dc73aa 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.h +++ b/src/tools/cephfs_mirror/PeerReplayer.h @@ -199,6 +199,7 @@ private: bool pop_dataq_entry(PeerReplayer::SyncEntry &out); void mark_crawl_finished(); + int remote_mkdir(const std::string &epath, const struct ceph_statx &stx); protected: MountRef m_local; MountRef m_remote; @@ -453,7 +454,6 @@ private: boost::optional prev); int do_sync_snaps(const std::string &dir_root); - int remote_mkdir(const std::string &epath, const struct ceph_statx &stx, const FHandles &fh); int remote_file_op(std::shared_ptr& syncm, const std::string &dir_root, const std::string &epath, const struct ceph_statx &stx, bool sync_check, const FHandles &fh, bool need_data_sync, bool need_attr_sync); -- 2.47.3