]> 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>
Fri, 15 Jul 2016 01:15:55 +0000 (09:15 +0800)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/client/Client.cc
src/client/Inode.cc
src/client/Inode.h

index fae1fecea3af79a7c75cda08a95e22b67168627b..0f0fb4a60313a03bf1e1262a73bca207da231e32 100644 (file)
@@ -1777,12 +1777,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);
     }
   }
 }
@@ -4824,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()) {
@@ -9487,6 +9492,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 68446e7deefae033e137a1e1893fbada85362428..99f763a0c198541058942290e6f730dadfd0ff9f 100644 (file)
@@ -15,7 +15,11 @@ Inode::~Inode()
 {
   cap_item.remove_myself();
   snaprealm_item.remove_myself();
-  snapdir_parent.reset();
+
+  if (snapdir_parent) {
+    snapdir_parent->flags &= ~I_SNAPDIR_OPEN;
+    snapdir_parent.reset();
+  }
 
   if (!oset.objects.empty()) {
     lsubdout(client->cct, client, 0) << __func__ << ": leftover objects on inode 0x"
index daead05e19a49ab5f3e01eadda04d70b50982614..b7ed726a2df1bdffb41eabfd02cbbc2181f8eb61 100644 (file)
@@ -78,6 +78,7 @@ struct CapSnap {
 #define I_COMPLETE     1
 #define I_DIR_ORDERED  2
 #define I_CAP_DROPPED  4
+#define I_SNAPDIR_OPEN 8
 
 struct Inode {
   Client *client;