]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: close directory's snapdir when deleting directory
authorYan, Zheng <zyan@redhat.com>
Mon, 11 Jul 2016 03:25:37 +0000 (11:25 +0800)
committerYan, Zheng <zyan@redhat.com>
Wed, 20 Jul 2016 02:42:32 +0000 (10:42 +0800)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
(cherry picked from commit 3099cabd11a16d22c6707631861bef0aa176ed02)

src/client/Client.cc
src/client/Inode.h

index e6fd7510d4c9f31e1bf843048ed00cfa6d2900cc..f885f91351d08e5a8ad1840b30e7263e0233fb9f 100644 (file)
@@ -1797,12 +1797,11 @@ void Client::put_request(MetaRequest *request)
     request->take_other_inode(&other_in);
     delete request;
 
-    if (other_in) {
-      if (other_in->dir &&
-         (op == CEPH_MDS_OP_RMDIR ||
-          op == CEPH_MDS_OP_RENAME ||
-          op == CEPH_MDS_OP_RMSNAP))
-       _try_to_trim_inode(other_in.get(), false);
+    if (other_in &&
+       (op == CEPH_MDS_OP_RMDIR ||
+        op == CEPH_MDS_OP_RENAME ||
+        op == CEPH_MDS_OP_RMSNAP)) {
+      _try_to_trim_inode(other_in.get(), false);
     }
   }
 }
@@ -2848,7 +2847,10 @@ void Client::put_inode(Inode *in, int n)
 
     in->cap_item.remove_myself();
     in->snaprealm_item.remove_myself();
-    in->snapdir_parent.reset();
+    if (in->snapdir_parent) {
+      in->snapdir_parent->flags &= ~I_SNAPDIR_OPEN;
+      in->snapdir_parent.reset();
+    }
     if (in == root) {
       root = 0;
       root_ancestor = 0;
@@ -4821,6 +4823,12 @@ void Client::_try_to_trim_inode(Inode *in, bool sched_inval)
     }
   }
 
+  if (ref > 0 && (in->flags & I_SNAPDIR_OPEN)) {
+    InodeRef snapdir = open_snapdir(in);
+    _try_to_trim_inode(snapdir.get(), false);
+    --ref;
+  }
+
   if (ref > 0 && in->ll_ref > 0 && sched_inval) {
     set<Dentry*>::iterator q = in->dn_set.begin();
     while (q != in->dn_set.end()) {
@@ -9399,6 +9407,7 @@ Inode *Client::open_snapdir(Inode *diri)
 
     in->dirfragtree.clear();
     in->snapdir_parent = diri;
+    diri->flags |= I_SNAPDIR_OPEN;
     inode_map[vino] = in;
     if (use_faked_inos())
       _assign_faked_ino(in);
index b94b26f2a7b34a18d822336cd3cb450ad7f0bd3a..1f2e36d0b34b325092f2043ecc712741e8a62701 100644 (file)
@@ -149,8 +149,9 @@ public:
 };
 
 // inode flags
-#define I_COMPLETE 1
-#define I_DIR_ORDERED 2
+#define I_COMPLETE     1
+#define I_DIR_ORDERED  2
+#define I_SNAPDIR_OPEN 8
 
 struct Inode {
   Client *client;