]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: convert Inode::snapdir_parent to smart pointer
authorYan, Zheng <zyan@redhat.com>
Wed, 24 Jun 2015 07:52:10 +0000 (15:52 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 12 Nov 2015 07:35:23 +0000 (15:35 +0800)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
(cherry picked from commit 89648e7ed56a1299a096b16080e4a52724893bdd)

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

index 624fbf8fc37e598c860464b5458396122b43f0a4..b8e3ac9490ce91e869e260d97311c3524ad2f204 100644 (file)
@@ -1258,12 +1258,12 @@ mds_rank_t Client::choose_target_mds(MetaRequest *req)
       ldout(cct, 10) << "choose_target_mds " << *in << " is snapped, using nonsnap parent" << dendl;
       while (in->snapid != CEPH_NOSNAP) {
         if (in->snapid == CEPH_SNAPDIR)
-       in = in->snapdir_parent;
+         in = in->snapdir_parent.get();
         else if (!in->dn_set.empty())
           /* In most cases there will only be one dentry, so getting it
            * will be the correct action. If there are multiple hard links,
            * I think the MDS should be able to redirect as needed*/
-       in = in->get_first_parent()->dir->parent_inode;
+         in = in->get_first_parent()->dir->parent_inode;
         else {
           ldout(cct, 10) << "got unlinked inode, can't look at parent" << dendl;
           break;
@@ -2465,11 +2465,10 @@ void Client::put_inode(Inode *in, int n)
     bool unclean = objectcacher->release_set(&in->oset);
     assert(!unclean);
     put_qtree(in);
-    if (in->snapdir_parent)
-      put_inode(in->snapdir_parent);
     inode_map.erase(in->vino());
     in->cap_item.remove_myself();
     in->snaprealm_item.remove_myself();
+    in->snapdir_parent.reset();
     if (in == root) {
       root = 0;
       root_ancestor = 0;
@@ -8160,7 +8159,6 @@ Inode *Client::open_snapdir(Inode *diri)
     in->dirfragtree.clear();
     inode_map[vino] = in;
     in->snapdir_parent = diri;
-    diri->get();
     ldout(cct, 10) << "open_snapdir created snapshot inode " << *in << dendl;
   } else {
     in = inode_map[vino];
index 2484159e1d6053c97efb6557ee6722dafb7f2ed8..90107ec0e2390cf5fcd6dc7118792fd815f4165e 100644 (file)
@@ -239,7 +239,7 @@ struct Inode {
 
   SnapRealm *snaprealm;
   xlist<Inode*>::item snaprealm_item;
-  Inode *snapdir_parent;  // only if we are a snapdir inode
+  InodeRef snapdir_parent;  // only if we are a snapdir inode
   map<snapid_t,CapSnap*> cap_snaps;   // pending flush to mds
 
   //int open_by_mode[CEPH_FILE_MODE_NUM];
@@ -301,7 +301,7 @@ struct Inode {
       dirty_caps(0), flushing_caps(0), flushing_cap_seq(0), shared_gen(0), cache_gen(0),
       snap_caps(0), snap_cap_refs(0),
       cap_item(this), flushing_cap_item(this), last_flush_tid(0),
-      snaprealm(0), snaprealm_item(this), snapdir_parent(0),
+      snaprealm(0), snaprealm_item(this),
       oset((void *)this, newlayout->fl_pg_pool, ino),
       reported_size(0), wanted_max_size(0), requested_max_size(0),
       _ref(0), ll_ref(0), dir(0), dn_set(),