From: Yan, Zheng Date: Tue, 12 Jan 2016 09:04:59 +0000 (+0800) Subject: client: avoid re-sending cap flushes twice during MDS recovers X-Git-Tag: v10.0.3~12^2~2^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=af1a3b2afffc3a8f9f0c886c70425d57cf7d7012;p=ceph.git client: avoid re-sending cap flushes twice during MDS recovers During MDS recovers, client may send same cap flushes twice. The first time is when MDS enters reconnect stage (only for flushing caps which are also revoked), the second time is when MDS goes active. If we send cap flushes when enters reconnect stage, we should avoiding sending again. Signed-off-by: Yan, Zheng --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 9a0c36a5f467..f506eac78879 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -3892,6 +3892,8 @@ void Client::flush_caps(Inode *in, MetaSession *session) for (map::iterator p = in->flushing_cap_tids.begin(); p != in->flushing_cap_tids.end(); ++p) { + if (session->kicked_flush_tids.count(p->first)) + continue; send_cap(in, session, cap, (get_caps_used(in) | in->caps_dirty()), in->caps_wanted(), (cap->issued | cap->implemented), p->second, p->first); @@ -3951,10 +3953,14 @@ void Client::kick_flushing_caps(MetaSession *session) if (in->flushing_caps) flush_caps(in, session); } + + session->kicked_flush_tids.clear(); } void Client::early_kick_flushing_caps(MetaSession *session) { + session->kicked_flush_tids.clear(); + for (xlist::iterator p = session->flushing_caps.begin(); !p.end(); ++p) { Inode *in = *p; if (!in->flushing_caps) @@ -3965,20 +3971,19 @@ void Client::early_kick_flushing_caps(MetaSession *session) // if flushing caps were revoked, we re-send the cap flush in client reconnect // stage. This guarantees that MDS processes the cap flush message before issuing // the flushing caps to other client. - bool send_now = (in->flushing_caps & in->auth_cap->issued) != in->flushing_caps; + if ((in->flushing_caps & in->auth_cap->issued) == in->flushing_caps) + continue; - if (send_now) - ldout(cct, 20) << " reflushing caps (revoked) on " << *in - << " to mds." << session->mds_num << dendl; + ldout(cct, 20) << " reflushing caps (revoked) on " << *in + << " to mds." << session->mds_num << dendl; for (map::iterator q = in->flushing_cap_tids.begin(); q != in->flushing_cap_tids.end(); ++q) { - if (send_now) { - send_cap(in, session, cap, (get_caps_used(in) | in->caps_dirty()), - in->caps_wanted(), (cap->issued | cap->implemented), - q->second, q->first); - } + send_cap(in, session, cap, (get_caps_used(in) | in->caps_dirty()), + in->caps_wanted(), (cap->issued | cap->implemented), + q->second, q->first); + session->kicked_flush_tids.insert(q->first); } } } diff --git a/src/client/MetaSession.h b/src/client/MetaSession.h index e21be8351527..2eb8cd6d82bd 100644 --- a/src/client/MetaSession.h +++ b/src/client/MetaSession.h @@ -47,6 +47,7 @@ struct MetaSession { xlist requests; xlist unsafe_requests; std::set flushing_caps_tids; + std::set kicked_flush_tids; Cap *s_cap_iterator;