]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: close opened dirs when umounting
authorYan, Zheng <zyan@redhat.com>
Wed, 9 Mar 2016 04:04:59 +0000 (12:04 +0800)
committerYan, Zheng <zyan@redhat.com>
Wed, 9 Mar 2016 06:40:06 +0000 (14:40 +0800)
Fixes: #14996
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/client/Client.cc
src/client/Client.h

index 31f31f86e99d3ee2589ecb64514b894e83f1dbd5..67b6d74b313ecc8b814d8708b7a7df0f0b017395 100644 (file)
@@ -337,6 +337,12 @@ void Client::tear_down_cache()
   }
   fd_map.clear();
 
+  while (!opened_dirs.empty()) {
+    dir_result_t *dirp = *opened_dirs.begin();
+    ldout(cct, 1) << "tear_down_cache forcing close of dir " << dirp << " ino " << dirp->inode->ino << dendl;
+    _closedir(dirp);
+  }
+
   // caps!
   // *** FIXME ***
 
@@ -5486,6 +5492,12 @@ void Client::unmount()
     _release_fh(fh);
   }
 
+  while (!opened_dirs.empty()) {
+    dir_result_t *dirp = *opened_dirs.begin();
+    ldout(cct, 0) << " destroyed lost open dir " << dirp << " on " << *dirp->inode << dendl;
+    _closedir(dirp);
+  }
+
   _ll_drop_pins();
 
   while (unsafe_sync_write > 0) {
@@ -6691,6 +6703,7 @@ int Client::_opendir(Inode *in, dir_result_t **dirpp, int uid, int gid)
   if (!in->is_dir())
     return -ENOTDIR;
   *dirpp = new dir_result_t(in);
+  opened_dirs.insert(*dirpp);
   if (in->dir) {
     (*dirpp)->release_count = in->dir->release_count;
     (*dirpp)->ordered_count = in->dir->ordered_count;
@@ -6723,6 +6736,7 @@ void Client::_closedir(dir_result_t *dirp)
     dirp->inode.reset();
   }
   _readdir_drop_dirp_buffer(dirp);
+  opened_dirs.erase(dirp);
   delete dirp;
 }
 
@@ -10974,13 +10988,7 @@ int Client::ll_opendir(Inode *in, int flags, dir_result_t** dirpp,
       return r;
   }
 
-  int r = 0;
-  if (vino.snapid == CEPH_SNAPDIR) {
-    *dirpp = new dir_result_t(in);
-  } else {
-    r = _opendir(in, dirpp, uid, gid);
-  }
-
+  int r = _opendir(in, dirpp, uid, gid);
   tout(cct) << (unsigned long)*dirpp << std::endl;
 
   ldout(cct, 3) << "ll_opendir " << vino << " = " << r << " (" << *dirpp << ")"
index 74752bf005bd50f0286fdff2bf33dacaa6fcac73..40a97af888436ff46d771f7ebf62ee86fe771afe 100644 (file)
@@ -30,6 +30,7 @@ using std::set;
 using std::map;
 using std::fstream;
 
+#include "include/unordered_set.h"
 #include "include/unordered_map.h"
 
 #include "include/filepath.h"
@@ -421,6 +422,8 @@ protected:
   // file handles, etc.
   interval_set<int> free_fd_set;  // unused fds
   ceph::unordered_map<int, Fh*> fd_map;
+
+  ceph::unordered_set<dir_result_t*> opened_dirs;
   
   int get_fd() {
     int fd = free_fd_set.range_start();