From 89648e7ed56a1299a096b16080e4a52724893bdd Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Wed, 24 Jun 2015 15:52:10 +0800 Subject: [PATCH] client: convert Inode::snapdir_parent to smart pointer Signed-off-by: Yan, Zheng --- src/client/Client.cc | 8 +++----- src/client/Inode.h | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 7b1b3e0a230af..fff1b2bf41655 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -1267,12 +1267,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; @@ -2571,11 +2571,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; @@ -8477,7 +8476,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 a4d4f731a0440..f18f65272d931 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -243,7 +243,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]; @@ -307,7 +307,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(), -- 2.39.5