]> 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>
Wed, 3 Aug 2022 08:08:20 +0000 (16:08 +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 15502868a60e30c2a2ec44cfc13dc57c83c75b11..c2c3173fb1ebf3eb8f21fd9a191d99ab9a5bb42a 100644 (file)
@@ -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<uint64_t,LogSegment*>::iterator p = segments.begin();
index b6b0be60f9d57a31f1cd564577b8aac8f221bb19..51f0b3480c8f23e0e9bc0aa0989b1918f3381543 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);