]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix seg fault in expire_recursive 44477/head
author胡玮文 <huww98@outlook.com>
Thu, 6 Jan 2022 07:43:29 +0000 (15:43 +0800)
committer胡玮文 <huww98@outlook.com>
Fri, 7 Jan 2022 17:00:31 +0000 (01:00 +0800)
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: 胡玮文 <huww98@outlook.com>
src/mds/MDCache.cc

index 9438925ffd65dda3d40f1ba536405eabca9b9a98..ef6d3c4c82ae3a93fe1f775cdc605db371fe36ac 100644 (file)
@@ -3741,8 +3741,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();