From: Yan, Zheng Date: Wed, 24 Jun 2015 07:52:10 +0000 (+0800) Subject: client: convert Inode::snapdir_parent to smart pointer X-Git-Tag: v0.94.7~24^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fcafc65e042c0ed913b5b564812180cd29eefb43;p=ceph.git client: convert Inode::snapdir_parent to smart pointer Signed-off-by: Yan, Zheng (cherry picked from commit 89648e7ed56a1299a096b16080e4a52724893bdd) --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 624fbf8fc37e..b8e3ac9490ce 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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]; diff --git a/src/client/Inode.h b/src/client/Inode.h index 2484159e1d60..90107ec0e239 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -239,7 +239,7 @@ struct Inode { SnapRealm *snaprealm; xlist::item snaprealm_item; - Inode *snapdir_parent; // only if we are a snapdir inode + InodeRef snapdir_parent; // only if we are a snapdir inode map 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(),