From 028eb3fdfb2346b3ed1ebfc3c3198ec99e21154c Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Fri, 21 Jun 2019 16:24:51 +0800 Subject: [PATCH] mds: cleanup truncating inodes when standby replay mds trim log segments Standby replay mds first trims expired log segments, then replays new log segments. It's possible a 'truncate_start' log event is in expired, but its 'truncate_finish' counterpart is the new log segments. When mds replays the 'truncate_finish' log event, log segment that contains the 'truncate_start' is already trimmed, so mds does nothing. This causes leak of Inode::PIN_TRUNCATING and trigger assertion when removing corresponding inode. Fixes: https://tracker.ceph.com/issues/40477 Signed-off-by: "Yan, Zheng" (cherry picked from commit 32121878dd0eef11e481162ebf924a14a91dd341) Conflicts: src/mds/MDCache.cc --- src/mds/MDCache.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 3bb86b9b30d..fb37bf94680 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -7247,6 +7247,12 @@ void MDCache::standby_trim_segment(LogSegment *ls) CInode *in = ls->dirty_dirfrag_dirfragtree.front(); in->dirfragtreelock.remove_dirty(); } + while (!ls->truncating_inodes.empty()) { + auto it = ls->truncating_inodes.begin(); + CInode *in = *it; + ls->truncating_inodes.erase(it); + in->put(CInode::PIN_TRUNCATING); + } } /* This function DOES put the passed message before returning */ -- 2.47.3