]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fix bug #24491 _ll_drop_pins may access invalid iterator 22791/head
authorLiuYangkuan <liuyangkuan@gmail.com>
Mon, 11 Jun 2018 15:51:16 +0000 (11:51 -0400)
committerPrashant D <pdhange@redhat.com>
Mon, 2 Jul 2018 02:44:08 +0000 (22:44 -0400)
Fixes: https://tracker.ceph.com/issues/24491
Signed-off-by: Liu Yangkuan <liuyangkuan@gmail.com>
(cherry picked from commit 97188fef8596f098aa43aa745a217b40a6c29ea4)

src/client/Client.cc

index 3167ddae0eaf5a9ad90fb6c5d63cabe9d5a57510..51f79838c717f0d32d8cee00299ceb026c454628 100644 (file)
@@ -10464,6 +10464,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();
@@ -10471,8 +10472,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);
+    }
   }
 }