From d1942c4fb50f50330c7603feb497f40f71aa9d9e Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Thu, 20 Jun 2019 09:52:49 +0800 Subject: [PATCH] client: cleanup tracking of early kicked flushing caps Signed-off-by: "Yan, Zheng" --- src/client/Client.cc | 37 ++++++++++++++++++------------------- src/client/Inode.h | 1 + src/client/MetaSession.h | 1 - 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 315c1cce85e5..ba1feca29b09 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -3587,17 +3587,16 @@ void Client::check_caps(Inode *in, unsigned flags) } ack: - // re-send old cap/snapcap flushes first. - if (session->mds_state >= MDSMap::STATE_RECONNECT && - session->mds_state < MDSMap::STATE_ACTIVE && - session->early_flushing_caps.count(in) == 0) { - ldout(cct, 20) << " reflushing caps (check_caps) on " << *in - << " to mds." << session->mds_num << dendl; - session->early_flushing_caps.insert(in); - if (in->cap_snaps.size()) - flush_snaps(in, true); - if (in->flushing_caps) - flush_caps(in, session, flags & CHECK_CAPS_SYNCHRONOUS); + if (&cap == in->auth_cap) { + if (in->flags & I_KICK_FLUSH) { + ldout(cct, 20) << " reflushing caps (check_caps) on " << *in + << " to mds." << mds << dendl; + in->flags &= ~I_KICK_FLUSH; + if (in->cap_snaps.size()) + flush_snaps(in, true); + if (in->flushing_caps) + flush_caps(in, session, flags & CHECK_CAPS_SYNCHRONOUS); + } } int flushing; @@ -4457,22 +4456,19 @@ void Client::kick_flushing_caps(MetaSession *session) for (xlist::iterator p = session->flushing_caps.begin(); !p.end(); ++p) { Inode *in = *p; - if (session->early_flushing_caps.count(in)) + if (!(in->flags & I_KICK_FLUSH)) continue; + in->flags &= ~I_KICK_FLUSH; ldout(cct, 20) << " reflushing caps on " << *in << " to mds." << mds << dendl; if (in->cap_snaps.size()) flush_snaps(in, true); if (in->flushing_caps) flush_caps(in, session); } - - session->early_flushing_caps.clear(); } void Client::early_kick_flushing_caps(MetaSession *session) { - session->early_flushing_caps.clear(); - for (xlist::iterator p = session->flushing_caps.begin(); !p.end(); ++p) { Inode *in = *p; Cap *cap = in->auth_cap; @@ -4481,13 +4477,15 @@ 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. - if ((in->flushing_caps & in->auth_cap->issued) == in->flushing_caps) + if ((in->flushing_caps & in->auth_cap->issued) == in->flushing_caps) { + in->flags |= I_KICK_FLUSH; continue; + } ldout(cct, 20) << " reflushing caps (early_kick) on " << *in << " to mds." << session->mds_num << dendl; - session->early_flushing_caps.insert(in); + in->flags &= ~I_KICK_FLUSH; // send_reconnect() also will reset these sequence numbers. make sure // sequence numbers in cap flush message match later reconnect message. @@ -4896,8 +4894,9 @@ void Client::handle_cap_import(MetaSession *session, Inode *in, const MConstRef< if (realm) put_snap_realm(realm); - if (in->auth_cap && in->auth_cap->session->mds_num == mds) { + if (in->auth_cap && in->auth_cap->session == session) { // reflush any/all caps (if we are now the auth_cap) + in->flags &= ~I_KICK_FLUSH; if (in->cap_snaps.size()) flush_snaps(in, true); if (in->flushing_caps) diff --git a/src/client/Inode.h b/src/client/Inode.h index bba7f920aa1a..dcc51d32d209 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -113,6 +113,7 @@ struct CapSnap { #define I_DIR_ORDERED 2 #define I_CAP_DROPPED 4 #define I_SNAPDIR_OPEN 8 +#define I_KICK_FLUSH 16 struct Inode { Client *client; diff --git a/src/client/MetaSession.h b/src/client/MetaSession.h index 958d0bd96c19..94881c370cac 100644 --- a/src/client/MetaSession.h +++ b/src/client/MetaSession.h @@ -52,7 +52,6 @@ struct MetaSession { xlist requests; xlist unsafe_requests; std::set flushing_caps_tids; - std::set early_flushing_caps; ceph::ref_t release; -- 2.47.3