From: 胡玮文 Date: Thu, 6 Jan 2022 07:43:29 +0000 (+0800) Subject: mds: fix seg fault in expire_recursive X-Git-Tag: v15.2.17~36^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3ffc8882710ce47dc9f8cba3a4f8f4b629b5614d;p=ceph.git mds: fix seg fault in expire_recursive Range-based for should not be used when we are altering the container. Use iterator explicitly instead. Fixes: https://tracker.ceph.com/issues/53805 Signed-off-by: 胡玮文 (cherry picked from commit d48a2cf7e2481cf9758f2934464ec6d9c35d898b) --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index adf46a839e61..88d2b648d02a 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -3733,8 +3733,9 @@ bool MDCache::expire_recursive(CInode *in, expiremap &expiremap) return true; } - for (auto &it : subdir->items) { - CDentry *dn = it.second; + for (auto it = subdir->items.begin(); it != subdir->items.end();) { + CDentry *dn = it->second; + it++; CDentry::linkage_t *dnl = dn->get_linkage(); if (dnl->is_primary()) { CInode *tin = dnl->get_inode();