]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: make sure snapflush is sent before normal cap message
authorYan, Zheng <zyan@redhat.com>
Wed, 29 Jun 2016 12:49:40 +0000 (20:49 +0800)
committerYan, Zheng <zyan@redhat.com>
Wed, 20 Jul 2016 02:37:09 +0000 (10:37 +0800)
MDS does null snapflush when it receives normal cap message. So client
must send snapflush first.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
(cherry picked from commit d3916717e2edc8000400f678fa7134ca1406a074)

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

index 65173e1d62a07e7aaa8651b9226a4fe32e3cb2fe..1a514ed55b88ca8e1a50663d6696d5322a845067 100644 (file)
@@ -1993,6 +1993,7 @@ MetaSession *Client::_open_mds_session(mds_rank_t mds)
   session->inst = mdsmap->get_inst(mds);
   session->con = messenger->get_connection(session->inst);
   session->state = MetaSession::STATE_OPENING;
+  session->mds_state = MDSMap::STATE_NULL;
   mds_sessions[mds] = session;
 
   // Maybe skip sending a request to open if this MDS daemon
@@ -2572,9 +2573,9 @@ void Client::handle_mds_map(MMDSMap* m)
     } else if (oldstate == newstate)
       continue;  // no change
     
-    if (newstate == MDSMap::STATE_RECONNECT &&
-       mds_sessions.count(p->first)) {
-      MetaSession *session = mds_sessions[p->first];
+    MetaSession *session = p->second;
+    session->mds_state = newstate;
+    if (newstate == MDSMap::STATE_RECONNECT) {
       session->inst = mdsmap->get_inst(p->first);
       session->con = messenger->get_connection(session->inst);
       send_reconnect(session);
@@ -2583,11 +2584,11 @@ void Client::handle_mds_map(MMDSMap* m)
     if (newstate >= MDSMap::STATE_ACTIVE) {
       if (oldstate < MDSMap::STATE_ACTIVE) {
        // kick new requests
-       kick_requests(p->second);
-       kick_flushing_caps(p->second);
-       signal_context_list(p->second->waiting_for_open);
-       kick_maxsize_requests(p->second);
-       wake_inode_waiters(p->second);
+       kick_requests(session);
+       kick_flushing_caps(session);
+       signal_context_list(session->waiting_for_open);
+       kick_maxsize_requests(session);
+       wake_inode_waiters(session);
       }
       connect_mds_targets(p->first);
     }
@@ -3364,6 +3365,19 @@ void Client::check_caps(Inode *in, bool is_delayed)
     }
 
   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);
+    }
+
     int flushing;
     ceph_tid_t flush_tid;
     if (in->auth_cap == cap && in->dirty_caps) {
@@ -4151,7 +4165,7 @@ void Client::early_kick_flushing_caps(MetaSession *session)
     if ((in->flushing_caps & in->auth_cap->issued) == in->flushing_caps)
       continue;
 
-    ldout(cct, 20) << " reflushing caps (revoked) on " << *in
+    ldout(cct, 20) << " reflushing caps (early_kick) on " << *in
                   << " to mds." << session->mds_num << dendl;
 
     session->early_flushing_caps.insert(in);
index 853bf7a295239915a699a3637aba1aa668537b11..aeb883c91d0cefe104c98de8fc25fe9526fea46d 100644 (file)
@@ -37,6 +37,7 @@ struct MetaSession {
     STATE_STALE,
   } state;
 
+  int mds_state;
   bool readonly;
 
   list<Context*> waiting_for_open;
@@ -55,8 +56,8 @@ struct MetaSession {
   MetaSession()
     : mds_num(-1), con(NULL),
       seq(0), cap_gen(0), cap_renew_seq(0), num_caps(0),
-      state(STATE_NEW), readonly(false), s_cap_iterator(NULL),
-      release(NULL)
+      state(STATE_NEW), mds_state(0), readonly(false),
+      s_cap_iterator(NULL), release(NULL)
   {}
   ~MetaSession();