]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix seg fault in expire_recursive 45099/head
author胡玮文 <huww98@outlook.com>
Thu, 6 Jan 2022 07:43:29 +0000 (15:43 +0800)
committerVenky Shankar <vshankar@redhat.com>
Mon, 21 Feb 2022 10:00:35 +0000 (15:30 +0530)
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>
(cherry picked from commit d48a2cf7e2481cf9758f2934464ec6d9c35d898b)

src/mds/MDCache.cc

index dc4358d3962770b0e07b597d0f3103e2fd5d9057..b87121914d44bcac979e81c18d8a9341bab76308 100644 (file)
@@ -3732,8 +3732,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();