]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds/MDLog: try to commit the open file table when there has diry items
authorXiubo Li <xiubli@redhat.com>
Thu, 24 Feb 2022 09:25:25 +0000 (17:25 +0800)
committerXiubo Li <xiubli@redhat.com>
Tue, 30 Aug 2022 02:43:01 +0000 (10:43 +0800)
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 <xiubli@redhat.com>
(cherry picked from commit 7c39dc8fb8985a68013e93cea274d4535bde93e3)

src/mds/MDLog.cc
src/mds/MDLog.h

index b005d8bad099be1403f399cfd91d21de4f25ada3..408909d4a3fd260586a577a8677ed5e93ebbf94b 100644 (file)
@@ -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<uint64_t,LogSegment*>::iterator p = segments.begin();
index bb91c39e2cd717919b3d35b43a74b654058ac06d..13a56aa0dea5312089203c74d4caf797b64a7c95 100644 (file)
@@ -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);