From: Yan, Zheng Date: Mon, 11 Jul 2016 03:25:37 +0000 (+0800) Subject: client: close directory's snapdir when deleting directory X-Git-Tag: v10.2.3~114^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ffcfe69ef7abaaa3c663de86fb04ea986dc90b15;p=ceph.git client: close directory's snapdir when deleting directory Signed-off-by: Yan, Zheng (cherry picked from commit 3099cabd11a16d22c6707631861bef0aa176ed02) --- diff --git a/src/client/Client.cc b/src/client/Client.cc index e6fd7510d4c9..f885f91351d0 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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::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); diff --git a/src/client/Inode.h b/src/client/Inode.h index b94b26f2a7b3..1f2e36d0b34b 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -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;