From dd783803f44d8cc424fdf33fef0a6a9203be3447 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 26 Jul 2023 14:34:01 +0800 Subject: [PATCH] mds: defer trim() until after the last cache_rejoin ack being received Just before the last cache_rejoin ack being received the entire subtree, together with the inode subtree root belongs to, were trimmed the isolated_inodes list couldn't be correctly erased. We should defer calling the trim() until the last cache_rejoin ack being received. Fixes: https://tracker.ceph.com/issues/62036 Signed-off-by: Xiubo Li --- src/mds/MDCache.cc | 9 ++++++++- src/mds/MDCache.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 325da1ae4c9..6e27a1d20c5 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -13470,6 +13470,13 @@ void MDCache::handle_mdsmap(const MDSMap &mdsmap, const MDSMap &oldmap) { } } +bool MDCache::is_ready_to_trim_cache(void) +{ + // null rejoin_done means rejoin has finished and all the rejoin acks + // have been well received. + return is_open() && !rejoin_done; +} + void MDCache::upkeep_main(void) { std::unique_lock lock(upkeep_mutex); @@ -13490,7 +13497,7 @@ void MDCache::upkeep_main(void) if (active_with_clients) { trim_client_leases(); } - if (is_open() || mds->is_standby_replay()) { + if (is_ready_to_trim_cache() || mds->is_standby_replay()) { trim(); } if (active_with_clients) { diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 94347b8249c..ab76d244065 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -1368,6 +1368,8 @@ class MDCache { void upkeep_main(void); + bool is_ready_to_trim_cache(void); + uint64_t cache_memory_limit; double cache_reservation; double cache_health_threshold; -- 2.39.5