Skip to content

Commit

Permalink
mds: use MDlog::trim_all() to trim log when deactivating mds
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ukernel committed Oct 9, 2018
1 parent 1bf2a5c commit 9c412d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/mds/MDCache.cc
Expand Up @@ -7668,7 +7668,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;
Expand Down Expand Up @@ -7717,7 +7723,7 @@ bool MDCache::shutdown_pass()
if (!mds->mdlog->is_capped()) {
dout(7) << "capping the log" << dendl;
mds->mdlog->cap();
mds->mdlog->trim();
mds->mdlog->trim(0);
}

if (!mds->mdlog->empty()) {
Expand Down
6 changes: 4 additions & 2 deletions src/mds/MDLog.cc
Expand Up @@ -720,7 +720,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),
Expand All @@ -731,7 +732,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;

Expand Down

0 comments on commit 9c412d3

Please sign in to comment.