From: Xiubo Li Date: Wed, 26 Jul 2023 06:34:01 +0000 (+0800) Subject: mds: defer trim() until after the last cache_rejoin ack being received X-Git-Tag: v18.2.5~601^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b4f476b2d2c9d723b646ec8f2714aa7f69dd71d3;p=ceph.git 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 (cherry picked from commit dd783803f44d8cc424fdf33fef0a6a9203be3447) --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 5480e6dcd5ef..b892908d7333 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -13483,6 +13483,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); @@ -13503,7 +13510,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 f1b58c28d111..f65cfc3beac9 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -1351,6 +1351,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;