]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: avoid re-sending cap flushes twice during MDS recovers
authorYan, Zheng <zyan@redhat.com>
Tue, 12 Jan 2016 09:04:59 +0000 (17:04 +0800)
committerYan, Zheng <zyan@redhat.com>
Wed, 13 Jan 2016 07:28:54 +0000 (15:28 +0800)
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 <zyan@redhat.com>
src/client/Client.cc
src/client/MetaSession.h

index 9a0c36a5f467303682d47fc649533d512ab90d5c..f506eac78879d2d5b02c975a5a61d609581f0752 100644 (file)
@@ -3892,6 +3892,8 @@ void Client::flush_caps(Inode *in, MetaSession *session)
   for (map<ceph_tid_t,int>::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<Inode*>::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<ceph_tid_t,int>::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);
     }
   }
 }
index e21be8351527470c705072de140922adb96aab62..2eb8cd6d82bdede1a0b18fee290aea5040841900 100644 (file)
@@ -47,6 +47,7 @@ struct MetaSession {
   xlist<MetaRequest*> requests;
   xlist<MetaRequest*> unsafe_requests;
   std::set<ceph_tid_t> flushing_caps_tids;
+  std::set<ceph_tid_t> kicked_flush_tids;
 
   Cap *s_cap_iterator;