]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: use MDlog::trim_all() to trim log when deactivating mds
authorYan, Zheng <zyan@redhat.com>
Tue, 9 Oct 2018 10:30:55 +0000 (18:30 +0800)
committerVicente Cheng <freeze.bilsted@gmail.com>
Tue, 8 Jan 2019 01:53:23 +0000 (09:53 +0800)
The problem of MDLog::trim(0) is that it expires current segment.
New log events (scatter nudge) may get added to current segment
when MDLog::trim(0) expires current segement.

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
(cherry picked from commit 49c0f072f60deb5761e6b6a6518d88c59510ee9b)

Conflicts:
src/mds/MDLog.cc
  - do not apply open file table related modification

src/mds/MDCache.cc
src/mds/MDLog.cc

index abc7fc9f69976fd30369d19ce29358b8296e2a9e..48e237030f366be1563b315f1a4272d8f4953e56 100644 (file)
@@ -7642,7 +7642,13 @@ bool MDCache::shutdown_pass()
   // Fully trim the log so that all objects in cache are clean and may be
   // trimmed by a future MDCache::trim. Note that MDSRank::tick does not
   // trim the log such that the cache eventually becomes clean.
-  mds->mdlog->trim(0);
+  if (mds->mdlog->get_num_segments() > 0 &&
+      mds->mdlog->get_current_segment()->num_events > 1) {
+    // current segment contains events other than subtreemap
+    mds->mdlog->start_new_segment();
+    mds->mdlog->flush();
+  }
+  mds->mdlog->trim_all();
   if (mds->mdlog->get_num_segments() > 1) {
     dout(7) << "still >1 segments, waiting for log to trim" << dendl;
     return false;
@@ -7691,9 +7697,11 @@ bool MDCache::shutdown_pass()
   if (!mds->mdlog->is_capped()) {
     dout(7) << "capping the log" << dendl;
     mds->mdlog->cap();
-    mds->mdlog->trim();
   }
   
+  if (!mds->mdlog->empty())
+    mds->mdlog->trim(0);
+
   if (!mds->mdlog->empty()) {
     dout(7) << "waiting for log to flush.. " << mds->mdlog->get_num_events() 
            << " in " << mds->mdlog->get_num_segments() << " segments" << dendl;
index 0080ca4fc8f6111246283df5883216072cd40946..1083ab356638bfbe0f36c0be046fb5bd2f81baf8 100644 (file)
@@ -700,7 +700,8 @@ int MDLog::trim_all()
 
   map<uint64_t,LogSegment*>::iterator p = segments.begin();
   while (p != segments.end() &&
-        p->first < last_seq && p->second->end <= safe_pos) {
+        p->first < last_seq &&
+        p->second->end < safe_pos) { // next segment should have been started
     LogSegment *ls = p->second;
     ++p;