]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs_mirror: sync snap dir root mode with remote dir
authorMilind Changire <mchangir@redhat.com>
Thu, 9 Feb 2023 09:27:14 +0000 (14:57 +0530)
committerMilind Changire <mchangir@redhat.com>
Mon, 4 Sep 2023 08:51:57 +0000 (14:21 +0530)
Fixes: https://tracker.ceph.com/issues/58678
Signed-off-by: Milind Changire <mchangir@redhat.com>
(cherry picked from commit f44b28416ab463c0c1bda6a58e2172ec41724c15)

src/tools/cephfs_mirror/PeerReplayer.cc
src/tools/cephfs_mirror/PeerReplayer.h

index aaf97b8684c479fe1a5213fa6479f04051b044cd..6ff1c057e3c6d9aeeb5925f1ea004d218054b607 100644 (file)
@@ -1125,6 +1125,27 @@ int PeerReplayer::pre_sync_check_and_open_handles(
   return 0;
 }
 
+// sync the mode of the remote dir_root with that of the local dir_root
+int PeerReplayer::sync_perms(const std::string& path) {
+  int r = 0;
+  struct ceph_statx tstx;
+
+  r = ceph_statx(m_local_mount, path.c_str(), &tstx, CEPH_STATX_MODE,
+                AT_STATX_DONT_SYNC | AT_SYMLINK_NOFOLLOW);
+  if (r < 0) {
+    derr << ": failed to fetch stat for local path: "
+        << cpp_strerror(r) << dendl;
+    return r;
+  }
+  r = ceph_chmod(m_remote_mount, path.c_str(), tstx.stx_mode);
+  if (r < 0) {
+    derr << ": failed to set mode for remote path: "
+        << cpp_strerror(r) << dendl;
+    return r;
+  }
+  return 0;
+}
+
 void PeerReplayer::post_sync_close_handles(const FHandles &fh) {
   dout(20) << dendl;
 
@@ -1496,8 +1517,13 @@ void PeerReplayer::run(SnapshotReplayerThread *replayer) {
         dout(5) << ": picked dir_root=" << *dir_root << dendl;
         int r = register_directory(*dir_root, replayer);
         if (r == 0) {
-          sync_snaps(*dir_root, locker);
-          unregister_directory(*dir_root);
+         r = sync_perms(*dir_root);
+         if (r < 0) {
+           _inc_failed_count(*dir_root);
+         } else {
+           sync_snaps(*dir_root, locker);
+         }
+         unregister_directory(*dir_root);
         }
       }
 
index 886c9532944b8828cc6936bac9a50d35e363423f..10768f3761f35841a83808a695517e72511e1615 100644 (file)
@@ -311,6 +311,7 @@ private:
                      const FHandles &fh, bool need_data_sync, bool need_attr_sync);
   int copy_to_remote(const std::string &dir_root, const std::string &epath, const struct ceph_statx &stx,
                      const FHandles &fh);
+  int sync_perms(const std::string& path);
 };
 
 } // namespace mirror