]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
uclient: Kick requests and renew caps on stale.
authorGreg Farnum <gregf@hq.newdream.net>
Fri, 26 Jun 2009 23:28:32 +0000 (16:28 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Fri, 26 Jun 2009 23:28:32 +0000 (16:28 -0700)
src/TODO
src/client/Client.cc
src/client/Client.h

index 7e0a964616ca22ddbf301099d5e17a151afa604c..471440cb72357bff8465b414d9a90e14de616a84 100644 (file)
--- a/src/TODO
+++ b/src/TODO
@@ -143,14 +143,7 @@ osd
 - optimize remove wrt recovery pushes?
 
 userspace client
-- handle session STALE
-- time out caps, wake up waiters on renewal
-  - link caps with mds session
-- fix lease validation to check session ttl
 - clean up client mds session vs mdsmap behavior?
-- clean up on session close
-  - hose all caps
-  - kick any requests
 - stop using mds's inode_t?
 - fix readdir vs fragment race by keeping a separate frag pos, and ignoring dentries below it
 
index a1269c2de6b410d9fb152593134e5fdffd09ce89..1b47d7f0f2d90e5c2270e45f12314bafddedd523 100644 (file)
@@ -889,7 +889,8 @@ void Client::handle_client_session(MClientSession *m)
   case CEPH_SESSION_CLOSE:
     mds_sessions.erase(from);
     mount_cond.Signal();
-    // FIXME: kick requests (hard) so that they are redirected.  or fail.
+    remove_session_caps(from);
+    kick_requests(from, true);
     break;
 
   case CEPH_SESSION_RENEWCAPS:
@@ -900,6 +901,7 @@ void Client::handle_client_session(MClientSession *m)
 
   case CEPH_SESSION_STALE:
     mds_sessions[from].was_stale = true;
+    renew_caps(from);
     break;
   default:
     assert(0);
@@ -912,7 +914,6 @@ void Client::handle_client_session(MClientSession *m)
   delete m;
 }
 
-
 void Client::send_request(MetaRequest *request, int mds)
 {
   MClientRequest *r = request->request;
@@ -926,6 +927,8 @@ void Client::send_request(MetaRequest *request, int mds)
     r->set_retry_attempt(request->retry_attempt);
     r->set_dentry_wanted();
   }
+  else
+    request->retry_attempt++;
   request->request = 0;
 
   r->set_mdsmap_epoch(mdsmap->get_epoch());
@@ -1130,7 +1133,7 @@ void Client::handle_mds_map(MMDSMap* m)
   // kick requests?
   if (frommds >= 0 &&
       mdsmap->get_state(frommds) == MDSMap::STATE_ACTIVE) {
-    kick_requests(frommds);
+    kick_requests(frommds, false);
     //failed_mds.erase(from);
   }
 
@@ -1198,7 +1201,7 @@ void Client::send_reconnect(int mds)
 }
 
 
-void Client::kick_requests(int mds)
+void Client::kick_requests(int mds, bool signal)
 {
   dout(10) << "kick_requests for mds" << mds << dendl;
 
@@ -1206,8 +1209,12 @@ void Client::kick_requests(int mds)
        p != mds_requests.end();
        ++p) 
     if (p->second->mds.count(mds)) {
-      p->second->retry_attempt++;   // inc retry counter
-      send_request(p->second, mds);
+      if (signal) {
+       p->second->caller_cond->Signal();
+      }
+      else {
+       send_request(p->second, mds);
+      }
     }
 }
 
@@ -1794,6 +1801,12 @@ void Client::remove_all_caps(Inode *in)
     remove_cap(in, in->caps.begin()->first);
 }
 
+void Client::remove_session_caps(int mds_num) {
+  MDSSession* mds = &mds_sessions[mds_num];
+  while (mds->caps.size())
+    remove_cap((*mds->caps.begin())->inode, mds_num);
+}
+
 void Client::mark_caps_dirty(Inode *in, int caps)
 {
   dout(10) << "mark_caps_dirty " << *in << " " << ccap_string(in->dirty_caps) << " -> "
@@ -2524,11 +2537,11 @@ void Client::renew_caps()
   }
 }
 
-void Client::renew_caps(const int session) {
-  dout(10) << "renew_caps(session number)" << dendl;
-  mds_sessions[session].last_cap_renew_request = g_clock.now();
+void Client::renew_caps(const int mds) {
+  dout(10) << "renew_caps mds" << mds << dendl;
+  mds_sessions[mds].last_cap_renew_request = g_clock.now();
   messenger->send_message(new MClientSession(CEPH_SESSION_REQUEST_RENEWCAPS),
-                         mdsmap->get_inst(session));
+                         mdsmap->get_inst(mds));
 
 }
 
@@ -5021,7 +5034,7 @@ void Client::ms_handle_remote_reset(const entity_addr_t& addr, entity_name_t las
     }
 
     // or requests
-    kick_requests(mds);
+    //kick_requests(mds, false);
   }
   else 
     objecter->ms_handle_remote_reset(addr, last);
index bea621056f205e1de85676232fdb08202a441a9f..4ee16d8c980b05995f272d4bcf25ab6ffcabcb1d 100644 (file)
@@ -649,7 +649,7 @@ public:
                             int use_mds=-1);
   int choose_target_mds(MClientRequest *req);
   void send_request(MetaRequest *request, int mds);
-  void kick_requests(int mds);
+  void kick_requests(int mds, bool signal);
   void handle_client_request_forward(MClientRequestForward *reply);
   void handle_client_reply(MClientReply *reply);
 
@@ -865,6 +865,7 @@ protected:
                      int flags);
   void remove_cap(Inode *in, int mds);
   void remove_all_caps(Inode *in);
+  void remove_session_caps(int mds_num);
   void mark_caps_dirty(Inode *in, int caps);
 
   void maybe_update_snaprealm(SnapRealm *realm, snapid_t snap_created, snapid_t snap_highwater,