]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs-mirror: adjust PeerReplayer::cleanup_remote_dir() for purging any remote ...
authorVenky Shankar <vshankar@redhat.com>
Wed, 17 Mar 2021 12:11:59 +0000 (08:11 -0400)
committerVenky Shankar <vshankar@redhat.com>
Tue, 25 May 2021 12:44:43 +0000 (08:44 -0400)
Right now, the only path to cleanup (purge) is the remote file
system directory root (for configured snapshot directories).
With incremental sync, we would need the ability to cleanup
selective directories under configured snapshot directories.
Furthermore, the path passed to the function ise used to checking
if the mirror daemon needs to backoff due to mirroring being
disabled, daemon shutdown etc.

So, adjust the function prototype to accept the directory root
and the relative path to be cleaned up under this directory.

Signed-off-by: Venky Shankar <vshankar@redhat.com>
src/tools/cephfs_mirror/PeerReplayer.cc
src/tools/cephfs_mirror/PeerReplayer.h

index d1cc57f3dbb9e4191dab3848ed7e1cb7b2ae64bc..79ff091e95e269853d32b342296356cb2553fadd 100644 (file)
@@ -714,11 +714,16 @@ int PeerReplayer::remote_file_op(const std::string &dir_path,
   return 0;
 }
 
-int PeerReplayer::cleanup_remote_dir(const std::string &dir_path) {
-  dout(20) << ": dir_path=" << dir_path << dendl;
+int PeerReplayer::cleanup_remote_dir(const std::string &dir_root, const std::string &path) {
+  dout(20) << ": dir_root=" << dir_root << ", path=" << path
+           << dendl;
 
   std::stack<SyncEntry> rm_stack;
   ceph_dir_result *tdirp;
+  auto dir_path = dir_root;
+  if (!path.empty()) {
+    dir_path = entry_path(dir_root, path);
+  }
   int r = ceph_opendir(m_remote_mount, dir_path.c_str(), &tdirp);
   if (r < 0) {
     derr << ": failed to open remote directory=" << dir_path << ": "
@@ -739,7 +744,7 @@ int PeerReplayer::cleanup_remote_dir(const std::string &dir_path) {
 
   rm_stack.emplace(SyncEntry(dir_path, tdirp, tstx));
   while (!rm_stack.empty()) {
-    if (should_backoff(dir_path, &r)) {
+    if (should_backoff(dir_root, &r)) {
       dout(0) << ": backing off r=" << r << dendl;
       break;
     }
index 42d58b574168f3682271981c819f7c3ff15caf77..95e14cafbe2a46dd01425410175c0d52117273df 100644 (file)
@@ -258,7 +258,7 @@ private:
   int synchronize(const std::string &dir_path, uint64_t snap_id, const std::string &snap_name);
   int do_synchronize(const std::string &path, const std::string &snap_name);
 
-  int cleanup_remote_dir(const std::string &dir_path);
+  int cleanup_remote_dir(const std::string &dir_root, const std::string &path={});
   int remote_mkdir(const std::string &local_path, const std::string &remote_path,
                    const struct ceph_statx &stx);
   int remote_file_op(const std::string &dir_path,