From: Xiubo Li Date: Thu, 24 Feb 2022 09:25:25 +0000 (+0800) Subject: mds/MDLog: try to commit the open file table when there has diry items X-Git-Tag: v18.0.0~575^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7c39dc8fb8985a68013e93cea274d4535bde93e3;p=ceph.git mds/MDLog: try to commit the open file table when there has diry items When there have dirty items, maybe there has no any new log event, for exmaple when opening the files it can skip the OPEN logs. Or maybe the journal segments could be expired but the open file table dirty items still in the cache. Signed-off-by: Xiubo Li --- diff --git a/src/mds/MDLog.cc b/src/mds/MDLog.cc index 15502868a60..c2c3173fb1e 100644 --- a/src/mds/MDLog.cc +++ b/src/mds/MDLog.cc @@ -581,6 +581,26 @@ public: } }; +void MDLog::try_to_commit_open_file_table(uint64_t last_seq) +{ + ceph_assert(ceph_mutex_is_locked_by_me(submit_mutex)); + + if (capped) // shutting down the MDS + return; + + if (mds->mdcache->open_file_table.is_any_committing()) + return; + + // when there have dirty items, maybe there has no any new log event + if (mds->mdcache->open_file_table.is_any_dirty() || + last_seq > mds->mdcache->open_file_table.get_committed_log_seq()) { + submit_mutex.unlock(); + mds->mdcache->open_file_table.commit(new C_OFT_Committed(this, last_seq), + last_seq, CEPH_MSG_PRIO_HIGH); + submit_mutex.lock(); + } +} + void MDLog::trim(int m) { unsigned max_segments = g_conf()->mds_log_max_segments; @@ -684,17 +704,7 @@ void MDLog::trim(int m) } } - if (!capped && - !mds->mdcache->open_file_table.is_any_committing()) { - uint64_t last_seq = get_last_segment_seq(); - if (mds->mdcache->open_file_table.is_any_dirty() || - last_seq > mds->mdcache->open_file_table.get_committed_log_seq()) { - submit_mutex.unlock(); - mds->mdcache->open_file_table.commit(new C_OFT_Committed(this, last_seq), - last_seq, CEPH_MSG_PRIO_HIGH); - submit_mutex.lock(); - } - } + try_to_commit_open_file_table(get_last_segment_seq()); // discard expired segments and unlock submit_mutex _trim_expired_segments(); @@ -730,14 +740,7 @@ int MDLog::trim_all() uint64_t last_seq = 0; if (!segments.empty()) { last_seq = get_last_segment_seq(); - if (!capped && - !mds->mdcache->open_file_table.is_any_committing() && - last_seq > mds->mdcache->open_file_table.get_committed_log_seq()) { - submit_mutex.unlock(); - mds->mdcache->open_file_table.commit(new C_OFT_Committed(this, last_seq), - last_seq, CEPH_MSG_PRIO_DEFAULT); - submit_mutex.lock(); - } + try_to_commit_open_file_table(last_seq); } map::iterator p = segments.begin(); diff --git a/src/mds/MDLog.h b/src/mds/MDLog.h index b6b0be60f9d..51f0b3480c8 100644 --- a/src/mds/MDLog.h +++ b/src/mds/MDLog.h @@ -298,6 +298,8 @@ private: void _prepare_new_segment(); void _journal_segment_subtree_map(MDSContext *onsync); + void try_to_commit_open_file_table(uint64_t last_seq); + void try_expire(LogSegment *ls, int op_prio); void _maybe_expired(LogSegment *ls, int op_prio); void _expired(LogSegment *ls);