From: Venky Shankar Date: Wed, 17 Mar 2021 12:11:59 +0000 (-0400) Subject: cephfs-mirror: adjust PeerReplayer::cleanup_remote_dir() for purging any remote ... X-Git-Tag: v17.1.0~1820^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=78db1eb80be5c8b7185f01d50b2bbe57380afdee;p=ceph.git cephfs-mirror: adjust PeerReplayer::cleanup_remote_dir() for purging any remote (sub)directory 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 --- diff --git a/src/tools/cephfs_mirror/PeerReplayer.cc b/src/tools/cephfs_mirror/PeerReplayer.cc index d1cc57f3dbb..79ff091e95e 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.cc +++ b/src/tools/cephfs_mirror/PeerReplayer.cc @@ -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 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; } diff --git a/src/tools/cephfs_mirror/PeerReplayer.h b/src/tools/cephfs_mirror/PeerReplayer.h index 42d58b57416..95e14cafbe2 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.h +++ b/src/tools/cephfs_mirror/PeerReplayer.h @@ -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,