]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix stale session handling for multiple mds 904/head
authorYan, Zheng <zheng.z.yan@intel.com>
Sun, 15 Dec 2013 02:11:16 +0000 (10:11 +0800)
committerYan, Zheng <zheng.z.yan@intel.com>
Mon, 16 Dec 2013 06:24:52 +0000 (14:24 +0800)
Don't add new caps to stale session when importing inodes. Don't
touch session when importing caps because it confuses the stale
session detection.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
src/mds/CInode.cc
src/mds/Capability.h
src/mds/Locker.cc
src/mds/Server.cc
src/mds/SessionMap.h

index d5d5a19a4352ee58a0928b93c878179058afc56f..94a11c986f35556c23fda67c5855863b6c468940 100644 (file)
@@ -2486,8 +2486,10 @@ Capability *CInode::add_client_cap(client_t client, Session *session, SnapRealm
   Capability *cap = new Capability(this, ++mdcache->last_cap_id, client);
   assert(client_caps.count(client) == 0);
   client_caps[client] = cap;
-  if (session)
-    session->add_cap(cap);
+
+  session->add_cap(cap);
+  if (session->is_stale())
+    cap->mark_stale();
   
   cap->client_follows = first-1;
   
index 6e35ba815da98d9baeaf21ba72e4626212d05fe3..d56e9153865dbee14904569bf7dfe2328ac4785b 100644 (file)
@@ -297,13 +297,17 @@ public:
     return Export(cap_id, _wanted, issued(), pending(), client_follows, last_sent, mseq+1, last_issue_stamp);
   }
   void merge(Export& other, bool auth_cap) {
-    // issued + pending
-    int newpending = other.pending | pending();
-    if (other.issued & ~newpending)
-      issue(other.issued | newpending);
-    else
-      issue(newpending);
-    last_issue_stamp = other.last_issue_stamp;
+    if (!is_stale()) {
+      // issued + pending
+      int newpending = other.pending | pending();
+      if (other.issued & ~newpending)
+       issue(other.issued | newpending);
+      else
+       issue(newpending);
+      last_issue_stamp = other.last_issue_stamp;
+    } else {
+      inc_last_seq();
+    }
 
     client_follows = other.client_follows;
 
@@ -313,21 +317,25 @@ public:
       mseq = other.mseq;
   }
   void merge(int otherwanted, int otherissued) {
-    // issued + pending
-    int newpending = pending();
-    if (otherissued & ~newpending)
-      issue(otherissued | newpending);
-    else
-      issue(newpending);
+    if (!is_stale()) {
+      // issued + pending
+      int newpending = pending();
+      if (otherissued & ~newpending)
+       issue(otherissued | newpending);
+      else
+       issue(newpending);
+    } else {
+      inc_last_seq();
+    }
 
     // wanted
     _wanted = _wanted | otherwanted;
   }
 
   void revoke() {
-    if (pending())
-      issue(0);
-    confirm_receipt(last_sent, 0);
+    if (pending() & ~CEPH_CAP_PIN)
+      issue(CEPH_CAP_PIN);
+    confirm_receipt(last_sent, CEPH_CAP_PIN);
   }
 
   // serializers
index eb30055933245456ddf6247a1ef49d3db22ab188..25e7c82f98c8b43c048967bf3c14bfcb5bb2871b 100644 (file)
@@ -1855,7 +1855,7 @@ void Locker::revoke_stale_caps(Session *session)
     cap->mark_stale();
     CInode *in = cap->get_inode();
     int issued = cap->issued();
-    if (issued) {
+    if (issued & ~CEPH_CAP_PIN) {
       dout(10) << " revoking " << ccap_string(issued) << " on " << *in << dendl;      
       cap->revoke();
 
index fa46636241b530be451189cbe85e62f763070a79..b74178b265e9de41feeab7fa236875c0ddfe7090 100644 (file)
@@ -368,7 +368,7 @@ version_t Server::prepare_force_open_sessions(map<client_t,entity_inst_t>& cm,
             session->is_opening() ||
             session->is_stale());
     session->inc_importing();
-    mds->sessionmap.touch_session(session);
+//  mds->sessionmap.touch_session(session);
   }
   return pv;
 }
@@ -706,6 +706,7 @@ void Server::reconnect_tick()
         ++p) {
       Session *session = mds->sessionmap.get_session(entity_name_t::CLIENT(p->v));
       dout(1) << "reconnect gave up on " << session->info.inst << dendl;
+      kill_session(session);
       failed_reconnects++;
     }
     client_reconnect_gather.clear();
index ebb1ac5d7817988ac6cb65b434be4cc5a9f250c5..0eb7e7c909e27e61cc507a2cd20e572d0494dda3 100644 (file)
@@ -281,12 +281,13 @@ public:
   }
   Session* get_or_add_session(const entity_inst_t& i) {
     Session *s;
-    if (session_map.count(i.name))
+    if (session_map.count(i.name)) {
       s = session_map[i.name];
-    else
+    } else {
       s = session_map[i.name] = new Session;
-    s->info.inst = i;
-    s->last_cap_renew = ceph_clock_now(g_ceph_context);
+      s->info.inst = i;
+      s->last_cap_renew = ceph_clock_now(g_ceph_context);
+    }
     return s;
   }
   void add_session(Session *s) {