diff options
author | Yan, Zheng <zyan@redhat.com> | 2018-10-09 12:30:55 +0200 |
---|---|---|
committer | Yan, Zheng <zyan@redhat.com> | 2018-10-29 04:42:00 +0100 |
commit | 49c0f072f60deb5761e6b6a6518d88c59510ee9b (patch) | |
tree | 600b0b7da6808728d025c8a11eb2ba4e0ccb7c5e /src | |
parent | mds: don't cap log when there are replicated objects (diff) | |
download | ceph-49c0f072f60deb5761e6b6a6518d88c59510ee9b.tar.xz ceph-49c0f072f60deb5761e6b6a6518d88c59510ee9b.zip |
mds: use MDlog::trim_all() to trim log when deactivating mds
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/mds/MDCache.cc | 12 | ||||
-rw-r--r-- | src/mds/MDLog.cc | 6 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 84cd42ec0dd..e9db4bbc550 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -7675,7 +7675,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; @@ -7724,9 +7730,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; diff --git a/src/mds/MDLog.cc b/src/mds/MDLog.cc index a57ed58d411..e6effef2ed6 100644 --- a/src/mds/MDLog.cc +++ b/src/mds/MDLog.cc @@ -721,7 +721,8 @@ int MDLog::trim_all() uint64_t last_seq = 0; if (!segments.empty()) { last_seq = get_last_segment_seq(); - if (!mds->mdcache->open_file_table.is_any_committing() && + if (!capped && + !mds->mdcache->open_file_table.is_any_committing() && last_seq > mds->mdcache->open_file_table.get_committing_log_seq()) { submit_mutex.Unlock(); mds->mdcache->open_file_table.commit(new C_OFT_Committed(this, last_seq), @@ -732,7 +733,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; |