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: v16.2.11~334^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ce189521db32407616eab7fb3d562c9a30af58ef;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 (cherry picked from commit 7c39dc8fb8985a68013e93cea274d4535bde93e3) --- diff --git a/src/mds/MDLog.cc b/src/mds/MDLog.cc index b005d8bad09..408909d4a3f 100644 --- a/src/mds/MDLog.cc +++ b/src/mds/MDLog.cc @@ -579,6 +579,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; @@ -682,17 +702,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(); @@ -728,14 +738,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 bb91c39e2cd..13a56aa0dea 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);