]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
[ceph-fuse] Fh ref might leak at umounting
authorZhi Zhang <willzzhang@tencent.com>
Thu, 18 Feb 2016 03:40:47 +0000 (11:40 +0800)
committerZhi Zhang <willzzhang@tencent.com>
Thu, 18 Feb 2016 03:40:47 +0000 (11:40 +0800)
Signed-off-by: Zhi Zhang <zhangz.david@outlook.com>
src/client/Client.cc
src/client/Client.h

index ed67f589d168cb3a63becc503df5ff3ca57cd0d1..294bbcd15e66e2803aead1fd611628f710a7e3f5 100644 (file)
@@ -5490,6 +5490,13 @@ void Client::unmount()
     ldout(cct, 0) << " destroyed lost open file " << fh << " on " << *fh->inode << dendl;
     _release_fh(fh);
   }
+  
+  while (!ll_unclosed_fh.empty()) {
+    set<Fh*>::iterator it = ll_unclosed_fh.begin();
+    ll_unclosed_fh.erase(*it);
+    ldout(cct, 0) << " destroyed lost open file " << *it << " on " << *((*it)->inode) << dendl;
+    _release_fh(*it);
+  }
 
   _ll_drop_pins();
 
@@ -11036,6 +11043,9 @@ int Client::ll_open(Inode *in, int flags, Fh **fhp, int uid, int gid)
 
  out:
   Fh *fhptr = fhp ? *fhp : NULL;
+  if (fhptr) {
+    ll_unclosed_fh.insert(fhptr);
+  }
   tout(cct) << (unsigned long)fhptr << std::endl;
   ldout(cct, 3) << "ll_open " << vino << " " << flags << " = " << r << " (" <<
     fhptr << ")" << dendl;
@@ -11107,6 +11117,9 @@ out:
     attr->st_ino = 0;
 
   Fh *fhptr = fhp ? *fhp : NULL;
+  if (fhptr) {
+    ll_unclosed_fh.insert(fhptr);
+  }
   tout(cct) << (unsigned long)fhptr << std::endl;
   tout(cct) << attr->st_ino << std::endl;
   ldout(cct, 3) << "ll_create " << parent << " " << name << " 0" << oct <<
@@ -11502,6 +11515,8 @@ int Client::ll_release(Fh *fh)
   tout(cct) << "ll_release (fh)" << std::endl;
   tout(cct) << (unsigned long)fh << std::endl;
 
+  if (ll_unclosed_fh.count(fh))
+    ll_unclosed_fh.erase(fh);
   return _release_fh(fh);
 }
 
index a3415b099c09f89c5cdde2952e8acc9304b09457..18e7b3e1699f0a9517f320e719b19fbc321c4a63 100644 (file)
@@ -421,6 +421,7 @@ protected:
   // file handles, etc.
   interval_set<int> free_fd_set;  // unused fds
   ceph::unordered_map<int, Fh*> fd_map;
+  set<Fh*> ll_unclosed_fh;
   
   int get_fd() {
     int fd = free_fd_set.range_start();