]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: cleanup tracking of early kicked flushing caps
authorYan, Zheng <zyan@redhat.com>
Thu, 20 Jun 2019 01:52:49 +0000 (09:52 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 31 Oct 2019 10:22:35 +0000 (18:22 +0800)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
(cherry picked from commit d1942c4fb50f50330c7603feb497f40f71aa9d9e)

src/client/Client.cc
src/client/Inode.h
src/client/MetaSession.h

index 5b15069e33f23695f43fbd898e1c6461adea001a..a23767db1128deb99802c38a89dff15be906e19a 100644 (file)
@@ -3539,17 +3539,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;
@@ -4411,22 +4410,19 @@ void Client::kick_flushing_caps(MetaSession *session)
 
   for (xlist<Inode*>::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<Inode*>::iterator p = session->flushing_caps.begin(); !p.end(); ++p) {
     Inode *in = *p;
     assert(in->auth_cap);
@@ -4434,13 +4430,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;
 
     if (in->cap_snaps.size())
       flush_snaps(in, true);
@@ -4863,8 +4861,9 @@ void Client::handle_cap_import(MetaSession *session, Inode *in, MClientCaps *m)
   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)
index f8505c8f9693940f96743422eee002312ea75c66..77136d4403baeb60bf908ff2c5375e019bf66755 100644 (file)
@@ -111,6 +111,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;
index 8aad3dbe104fd18e050174b0993bef754c21d0d2..f740dda20409b3fbb5a486e93518008c8e9e92ff 100644 (file)
@@ -44,7 +44,6 @@ struct MetaSession {
   xlist<MetaRequest*> requests;
   xlist<MetaRequest*> unsafe_requests;
   std::set<ceph_tid_t> flushing_caps_tids;
-  std::set<Inode*> early_flushing_caps;
 
   boost::intrusive_ptr<MClientCapRelease> release;