]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cap stale -> resume works
authorSage Weil <sage@newdream.net>
Sat, 5 Jan 2008 02:16:51 +0000 (18:16 -0800)
committerSage Weil <sage@newdream.net>
Sat, 5 Jan 2008 02:16:51 +0000 (18:16 -0800)
src/mds/CInode.cc
src/mds/CInode.h
src/mds/Locker.cc
src/mds/Server.cc
src/messages/MClientSession.h

index a1184a16b75568e593c1b330bc1f30d55f0627e8..463be08b4e3b3630ee93045bc8ad5d5a529aaff7 100644 (file)
@@ -82,7 +82,7 @@ ostream& operator<<(ostream& out, CInode& in)
          it != in.get_client_caps().end();
          it++) {
       if (it != in.get_client_caps().begin()) out << ",";
-      out << it->first;
+      out << it->first << "=" << it->second->issued();
     }
     out << "}";
   }
index b5c67140ae5cd202650e397b6cb36362983ea6e0..8181be69c66ece9f0f5170424f90a183037f858a 100644 (file)
@@ -416,7 +416,20 @@ public:
       }
     return w;
   }
+  bool is_loner_cap() {
+    if (!mds_caps_wanted.empty())
+      return false;
 
+    int n = 0;
+    for (map<int,Capability*>::iterator it = client_caps.begin();
+         it != client_caps.end();
+         it++) 
+      if (!it->second->is_stale()) {
+       if (n) return false;
+       n++;
+      }
+    return (n == 1);
+  }
 
   void replicate_relax_locks() {
     //dout(10) << " relaxing locks on " << *this << dendl;
index 99e646004a2a769b25c52171a988a40199f24f35..e11c0ca619938b8ad09760d89ae7884f773ed534 100644 (file)
@@ -572,9 +572,13 @@ void Locker::revoke_stale_caps(Session *session)
     if (issued) {
       dout(10) << " revoking " << cap_string(issued) << " on " << *in << dendl;      
       cap->revoke();
-      file_eval(&in->filelock);
-      if (!in->is_auth())
+      file_eval_gather(&in->filelock);
+      if (in->is_auth()) {
+       if (in->filelock.is_stable())
+         file_eval(&in->filelock);
+      } else {
        request_inode_file_caps(in);
+      }
     } else {
       dout(10) << " nothing issued on " << *in << dendl;
     }
@@ -592,7 +596,8 @@ void Locker::resume_stale_caps(Session *session)
     if (cap->is_stale()) {
       dout(10) << " clearing stale flag on " << *in << dendl;
       cap->set_stale(false);
-      file_eval(&in->filelock);
+      if (in->is_auth() && in->filelock.is_stable())
+       file_eval(&in->filelock);
       issue_caps(in);
     }
   }
@@ -2447,7 +2452,7 @@ void Locker::file_eval(FileLock *lock)
 {
   CInode *in = (CInode*)lock->get_parent();
   int wanted = in->get_caps_wanted();
-  bool loner = (in->client_caps.size() == 1) && in->mds_caps_wanted.empty();
+  bool loner = in->is_loner_cap();
   dout(7) << "file_eval wanted=" << cap_string(wanted)
          << "  filelock=" << *lock << " on " << *lock->get_parent()
          << "  loner=" << loner
index 5c8acec58ca37598387edbf9db1ce0d7f4509b1f..ef3a053a542c9d4c826b71df400c3516e2c28801 100644 (file)
@@ -314,7 +314,7 @@ void Server::find_idle_sessions()
     dout(10) << "new stale session " << session->inst << " last " << session->last_cap_renew << dendl;
     mds->sessionmap.set_state(session, Session::STATE_STALE);
     mds->locker->revoke_stale_caps(session);
-    mds->messenger->send_message(new MClientSession(CEPH_SESSION_STALE, g_clock.now()),
+    mds->messenger->send_message(new MClientSession(CEPH_SESSION_STALE, session->get_push_seq()),
                                 session->inst);
   }
 
index 7c709c9639f6371c459a03a135c02018da0b6a59..16a35ee1cdca3eda671f6994a94c4950e0054886 100644 (file)
@@ -35,7 +35,7 @@ public:
   }
 
   int32_t op;
-  version_t seq;  // used when requesting close only
+  version_t seq;  // used when requesting close, declaring stale
   utime_t stamp;
 
   MClientSession() : Message(CEPH_MSG_CLIENT_SESSION) { }