From 8496730f4854a172498ad918de12198fc7e443d8 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Tue, 22 Feb 2022 15:14:06 +0800 Subject: mds: switch to use heartbeat_reset_grace instead of hard code Signed-off-by: Xiubo Li --- src/mds/MDCache.cc | 20 ++++++++++---------- src/mds/OpenFileTable.cc | 4 ++-- src/mds/journal.cc | 26 +++++++++++++------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index c4d5901e800..7b5be62875a 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -3765,13 +3765,13 @@ void MDCache::trim_unlinked_inodes() q.push_back(in); } - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } for (auto& in : q) { remove_inode_recursive(in); - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } } @@ -5417,7 +5417,7 @@ bool MDCache::process_imported_caps() } else { open_ino(p.first, (int64_t)-1, fin, false); } - if (!(cap_imports_num_opening % 1000)) + if (!(cap_imports_num_opening % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } @@ -5603,7 +5603,7 @@ void MDCache::choose_lock_states_and_reconnect_caps() rejoin_pending_snaprealms.insert(in); } - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } } @@ -5772,7 +5772,7 @@ void MDCache::export_remaining_imported_caps() } } - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } @@ -6246,7 +6246,7 @@ void MDCache::reissue_all_caps() n += mds->locker->issue_caps(in); } - if ((count % 1000) + n >= 1000) + if ((count % mds->heartbeat_reset_grace()) + n >= mds->heartbeat_reset_grace()) mds->heartbeat_reset(); count += n; } @@ -6367,7 +6367,7 @@ void MDCache::identify_files_to_recover() rejoin_check_q.push_back(in); } - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } } @@ -6379,13 +6379,13 @@ void MDCache::start_files_to_recover() if (in->filelock.get_state() == LOCK_XLOCKSNAP) mds->locker->issue_caps(in); mds->locker->check_inode_max_size(in); - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } rejoin_check_q.clear(); for (CInode *in : rejoin_recover_q) { mds->locker->file_recover(&in->filelock); - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } if (!rejoin_recover_q.empty()) { @@ -12457,7 +12457,7 @@ void MDCache::force_readonly() CInode *in = p.second; if (in->is_head()) mds->locker->eval(in, CEPH_CAP_LOCKS); - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } diff --git a/src/mds/OpenFileTable.cc b/src/mds/OpenFileTable.cc index aae5df6b94f..0b68c3ddaf6 100644 --- a/src/mds/OpenFileTable.cc +++ b/src/mds/OpenFileTable.cc @@ -1090,7 +1090,7 @@ void OpenFileTable::_prefetch_dirfrags() ceph_assert(dir->get_inode()->dirfragtree.is_leaf(dir->get_frag())); dir->fetch(gather.new_sub()); - if (!(++num_opening_dirfrags % 1000)) + if (!(++num_opening_dirfrags % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } @@ -1166,7 +1166,7 @@ void OpenFileTable::_prefetch_inodes() mdcache->open_ino(ino, pool, fin, false); } - if (!(num_opening_inodes % 1000)) + if (!(num_opening_inodes % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } diff --git a/src/mds/journal.cc b/src/mds/journal.cc index 729d394bd9e..0059c07c8ea 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -1362,7 +1362,7 @@ void EMetaBlob::replay(MDSRank *mds, LogSegment *logseg, MDPeerUpdate *peerup) in->state_clear(CInode::STATE_AUTH); ceph_assert(g_conf()->mds_kill_journal_replay_at != 2); - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } @@ -1397,7 +1397,7 @@ void EMetaBlob::replay(MDSRank *mds, LogSegment *logseg, MDPeerUpdate *peerup) if (lump.is_importing()) dn->mark_auth(); - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } @@ -1435,7 +1435,7 @@ void EMetaBlob::replay(MDSRank *mds, LogSegment *logseg, MDPeerUpdate *peerup) // Make null dentries the first things we trim dout(10) << "EMetaBlob.replay pushing to bottom of lru " << *dn << dendl; - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } } @@ -1468,7 +1468,7 @@ void EMetaBlob::replay(MDSRank *mds, LogSegment *logseg, MDPeerUpdate *peerup) else dir->state_set(CDir::STATE_AUTH); - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } } @@ -1500,7 +1500,7 @@ void EMetaBlob::replay(MDSRank *mds, LogSegment *logseg, MDPeerUpdate *peerup) dir->state_clear(CDir::STATE_AUTH); mds->mdcache->adjust_subtree_auth(dir, CDIR_AUTH_UNDEF); - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } } @@ -1513,7 +1513,7 @@ void EMetaBlob::replay(MDSRank *mds, LogSegment *logseg, MDPeerUpdate *peerup) ceph_assert(p->first->is_dir()); mds->mdcache->adjust_subtree_after_rename(p->first, p->second, false); - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } } @@ -1531,7 +1531,7 @@ void EMetaBlob::replay(MDSRank *mds, LogSegment *logseg, MDPeerUpdate *peerup) } else mds->mdcache->remove_inode_recursive(in); - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } } @@ -1544,7 +1544,7 @@ void EMetaBlob::replay(MDSRank *mds, LogSegment *logseg, MDPeerUpdate *peerup) if (client) client->got_journaled_agree(p.second, logseg); - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } @@ -1634,7 +1634,7 @@ void EMetaBlob::replay(MDSRank *mds, LogSegment *logseg, MDPeerUpdate *peerup) ceph_assert(in); mds->mdcache->add_recovered_truncate(in, logseg); - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } for (const auto& p : truncate_finish) { @@ -1645,7 +1645,7 @@ void EMetaBlob::replay(MDSRank *mds, LogSegment *logseg, MDPeerUpdate *peerup) mds->mdcache->remove_recovered_truncate(in, ls); } - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } @@ -1667,7 +1667,7 @@ void EMetaBlob::replay(MDSRank *mds, LogSegment *logseg, MDPeerUpdate *peerup) dout(10) << "EMetaBlob.replay destroyed " << *p << ", not in cache" << dendl; } - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } mds->mdcache->open_file_table.note_destroyed_inos(logseg->seq, destroyed_inodes); @@ -1689,7 +1689,7 @@ void EMetaBlob::replay(MDSRank *mds, LogSegment *logseg, MDPeerUpdate *peerup) } } - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } @@ -1705,7 +1705,7 @@ void EMetaBlob::replay(MDSRank *mds, LogSegment *logseg, MDPeerUpdate *peerup) } } - if (!(++count % 1000)) + if (!(++count % mds->heartbeat_reset_grace())) mds->heartbeat_reset(); } -- cgit v1.2.3