From f5d4626e8b746dd97896296f37c07c6ffee7eb29 Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Wed, 14 Jul 2021 05:31:43 -0400 Subject: [PATCH] cephfs-mirror: record directory path cancel in DirRegistry When removing a directory path from mirroring, cephfs-mirror records this state in a thread-local storage. The replayer thread backs-off in midst of mirroring the directory snapshots for this directory path. However, the state (canceled state) is never cleared causing the thread to incorrectly assume that other directory paths (which are picked up by this thread) need backing-off, hence, marking these directory paths as failed (to synchronize snapshots). Fix is to store this state in the directory specific store which is allocated when a thread picks up a directory path for synchronization. Signed-off-by: Venky Shankar (cherry picked from commit 1a956be9baf0f21e64d81a684cd8f90cb6481f6a) --- src/tools/cephfs_mirror/PeerReplayer.cc | 2 +- src/tools/cephfs_mirror/PeerReplayer.h | 12 ++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/tools/cephfs_mirror/PeerReplayer.cc b/src/tools/cephfs_mirror/PeerReplayer.cc index 6c2e6ee5b884c..44796cb4973af 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.cc +++ b/src/tools/cephfs_mirror/PeerReplayer.cc @@ -282,7 +282,7 @@ void PeerReplayer::remove_directory(string_view dir_root) { if (it1 == m_registered.end()) { m_snap_sync_stats.erase(_dir_root); } else { - it1->second.replayer->cancel(); + it1->second.canceled = true; } m_cond.notify_all(); } diff --git a/src/tools/cephfs_mirror/PeerReplayer.h b/src/tools/cephfs_mirror/PeerReplayer.h index f320642786954..886c9532944b8 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.h +++ b/src/tools/cephfs_mirror/PeerReplayer.h @@ -88,21 +88,13 @@ private: return 0; } - void cancel() { - canceled = true; - } - - bool is_canceled() const { - return canceled; - } - private: PeerReplayer *m_peer_replayer; - bool canceled = false; }; struct DirRegistry { int fd; + bool canceled = false; SnapshotReplayerThread *replayer; }; @@ -244,7 +236,7 @@ private: return true; } auto &dr = m_registered.at(dir_root); - if (dr.replayer->is_canceled()) { + if (dr.canceled) { *retval = -ECANCELED; return true; } -- 2.39.5