From 3cadbfbb1106f4cd5bc18b1f55c0c6e95f3264ed Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Fri, 14 Mar 2014 16:26:34 +0800 Subject: [PATCH] mds: fix potential invalid pointer dereference pin importing inode until subtree importing finishes Signed-off-by: Yan, Zheng --- src/mds/Migrator.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mds/Migrator.cc b/src/mds/Migrator.cc index 1a4422182b3e0..62a6300caaab7 100644 --- a/src/mds/Migrator.cc +++ b/src/mds/Migrator.cc @@ -2389,6 +2389,7 @@ void Migrator::import_reverse(CDir *dir) if (cap->is_new()) in->remove_client_cap(q->first); } + in->put(CInode::PIN_IMPORTINGCAPS); } for (map::iterator p = stat.client_map.begin(); p != stat.client_map.end(); @@ -2579,6 +2580,7 @@ void Migrator::import_finish(CDir *dir, bool notify, bool last) q->second.mseq - 1, it->second.peer, CEPH_CAP_FLAG_AUTH); } p->second.clear(); + in->replica_caps_wanted = 0; } for (map::iterator p = it->second.client_map.begin(); p != it->second.client_map.end(); @@ -2642,9 +2644,11 @@ void Migrator::import_finish(CDir *dir, bool notify, bool last) // re-eval imported caps for (map >::iterator p = peer_exports.begin(); p != peer_exports.end(); - ++p) + ++p) { if (p->first->is_auth()) mds->locker->eval(p->first, CEPH_CAP_LOCKS, true); + p->first->put(CInode::PIN_IMPORTINGCAPS); + } // send pending import_maps? mds->mdcache->maybe_send_pending_resolves(); @@ -2775,8 +2779,10 @@ void Migrator::finish_import_inode_caps(CInode *in, int peer, bool auth_cap, } } - in->replica_caps_wanted = 0; - in->put(CInode::PIN_IMPORTINGCAPS); + if (peer >= 0) { + in->replica_caps_wanted = 0; + in->put(CInode::PIN_IMPORTINGCAPS); + } } int Migrator::decode_import_dir(bufferlist::iterator& blp, -- 2.39.5