]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
client: fix bug #24491 _ll_drop_pins may access invalid iterator
authorLiuYangkuan <liuyangkuan@gmail.com>
Mon, 11 Jun 2018 15:51:16 +0000 (11:51 -0400)
committerLiuYangkuan <liuyangkuan@gmail.com>
Tue, 12 Jun 2018 03:34:21 +0000 (23:34 -0400)
Fixes: https://tracker.ceph.com/issues/24491
Signed-off-by: Liu Yangkuan <liuyangkuan@gmail.com>
src/client/Client.cc

index 213b78465d4f83cf3a06ab9f44e6bea5330276cd..f4bfb7177fa9d626259f2076c1e05fb9642291c1 100644 (file)
@@ -10455,6 +10455,7 @@ int Client::_ll_put(Inode *in, int num)
 void Client::_ll_drop_pins()
 {
   ldout(cct, 10) << __func__ << dendl;
+  std::set<InodeRef> to_be_put; //this set will be deconstructed item by item when exit
   ceph::unordered_map<vinodeno_t, Inode*>::iterator next;
   for (ceph::unordered_map<vinodeno_t, Inode*>::iterator it = inode_map.begin();
        it != inode_map.end();
@@ -10462,8 +10463,10 @@ void Client::_ll_drop_pins()
     Inode *in = it->second;
     next = it;
     ++next;
-    if (in->ll_ref)
+    if (in->ll_ref){
+      to_be_put.insert(in);
       _ll_put(in, in->ll_ref);
+    }
   }
 }