From c60ef1b806c4a0c60362193675990447d82a65f4 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Sat, 28 Apr 2018 17:17:53 -0700 Subject: [PATCH] mds: trim log during shutdown to clean metadata Otherwise the trimming won't advance so that the remaining inodes are marked clean. Fixes: http://tracker.ceph.com/issues/23923 Signed-off-by: Patrick Donnelly --- src/mds/MDCache.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 6803eeadee2ff..62a4b8f7ce5ab 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -7676,7 +7676,7 @@ bool MDCache::shutdown_pass() trim(UINT64_MAX); dout(5) << "lru size now " << lru.lru_get_size() << "/" << bottom_lru.lru_get_size() << dendl; - // SUBTREES + // Export all subtrees to another active (usually rank 0) if not rank 0 int num_auth_subtree = 0; if (!subtrees.empty() && mds->get_nodeid() != 0 && @@ -7715,6 +7715,7 @@ bool MDCache::shutdown_pass() } if (num_auth_subtree > 0) { + assert(mds->get_nodeid() > 0); dout(7) << "still have " << num_auth_subtree << " auth subtrees" << dendl; show_subtrees(); return false; @@ -7727,6 +7728,15 @@ bool MDCache::shutdown_pass() return false; } + // 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() > 1) { + dout(7) << "still >1 segments, waiting for log to trim" << dendl; + return false; + } + // drop our reference to our stray dir inode for (int i = 0; i < NUM_STRAY; ++i) { if (strays[i] && @@ -7754,13 +7764,6 @@ bool MDCache::shutdown_pass() assert(!migrator->is_exporting()); assert(!migrator->is_importing()); - // flush what we can from the log - mds->mdlog->trim(0); - if (mds->mdlog->get_num_segments() > 1) { - dout(7) << "still >1 segments, waiting for log to trim" << dendl; - return false; - } - if ((myin && myin->is_auth_pinned()) || (mydir && mydir->is_auth_pinned())) { dout(7) << "still have auth pinned objects" << dendl; -- 2.39.5