]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: file size recovery when client goes stale
authorSage Weil <sage@newdream.net>
Thu, 15 May 2008 00:53:48 +0000 (17:53 -0700)
committerSage Weil <sage@newdream.net>
Thu, 15 May 2008 00:53:48 +0000 (17:53 -0700)
src/mds/CInode.cc
src/mds/CInode.h
src/mds/Locker.cc
src/mds/MDCache.cc
src/mds/Server.cc

index 5e6d4dad2753f14fbcf984d6622e02023e3aeb11..d78b1b4f02ff3a5202780f2c660d8c7276b6f00d 100644 (file)
@@ -65,6 +65,8 @@ ostream& operator<<(ostream& out, CInode& in)
   out << " v" << in.get_version();
 
   if (in.state_test(CInode::STATE_AMBIGUOUSAUTH)) out << " AMBIGAUTH";
+  if (in.state_test(CInode::STATE_NEEDSRECOVER)) out << " needsrecover";
+  if (in.state_test(CInode::STATE_RECOVERING)) out << " recovering";
   if (in.is_freezing_inode()) out << " FREEZING=" << in.auth_pin_freeze_allowance;
   if (in.is_frozen_inode()) out << " FROZEN";
 
index a6f3a8702c11ffb2eb7c69ff87f17c1ea382b40f..6a9060c7d1c74584bb1045570aa34382a3796489 100644 (file)
@@ -100,6 +100,8 @@ class CInode : public MDSCacheObject {
   static const int STATE_FROZEN =      (1<<8);
   static const int STATE_AMBIGUOUSAUTH = (1<<9);
   static const int STATE_EXPORTINGCAPS = (1<<10);
+  static const int STATE_NEEDSRECOVER = (1<<11);
+  static const int STATE_RECOVERING = (1<<11);
 
   // -- waiters --
   //static const int WAIT_SLAVEAGREE  = (1<<0);
@@ -135,12 +137,6 @@ class CInode : public MDSCacheObject {
   off_t last_journaled;       // log offset for the last time i was journaled
   off_t last_open_journaled;  // log offset for the last journaled EOpen
 
-  // file recovery flag (when caps go stale)
-  bool _needs_file_recovery;
-  bool needs_file_recover() { return _needs_file_recovery; }
-  void mark_needs_file_recover() { _needs_file_recovery = true; }
-  void clear_needs_file_recover() { _needs_file_recovery = false; }
-
   //bool hack_accessed;
   //utime_t hack_load_stamp;
 
@@ -241,7 +237,6 @@ public:
   CInode(MDCache *c, bool auth=true) : 
     mdcache(c),
     last_journaled(0), last_open_journaled(0), 
-    _needs_file_recovery(false),
     //hack_accessed(true),
     stickydir_ref(0),
     parent(0), projected_parent(0),
index 57ef45789d6d9616c4c548bd96be6e6a1a2f8a70..7709f9b6bcbdf24b0b9a9cb71f7b05a1774eeda2 100644 (file)
@@ -653,7 +653,9 @@ void Locker::revoke_stale_caps(Session *session)
     if (issued) {
       dout(10) << " revoking " << cap_string(issued) << " on " << *in << dendl;      
       cap->revoke();
-      file_eval_gather(&in->filelock);
+      in->state_set(CInode::STATE_NEEDSRECOVER);
+      if (!in->filelock.is_stable())
+       file_eval_gather(&in->filelock);
       if (in->is_auth()) {
        if (in->filelock.is_stable())
          file_eval(&in->filelock);
@@ -2588,8 +2590,12 @@ void Locker::file_rdlock_finish(FileLock *lock, MDRequest *mdr)
   mdr->rdlocks.erase(lock);
   mdr->locks.erase(lock);
 
-  if (!lock->is_rdlocked())
-    file_eval_gather(lock);
+  if (!lock->is_rdlocked()) {
+    if (!lock->is_stable())
+      file_eval_gather(lock);
+    else if (lock->get_parent()->is_auth())
+      file_eval(lock);
+  }
 }
 
 bool Locker::file_wrlock_start(FileLock *lock)
@@ -2757,6 +2763,17 @@ void Locker::file_eval_gather(FileLock *lock)
       !lock->is_wrlocked() &&
       lock->get_num_client_lease() == 0 &&
       ((issued & ~lock->caps_allowed()) == 0)) {
+
+    if (in->state_test(CInode::STATE_NEEDSRECOVER)) {
+      dout(7) << "file_eval_gather finished gather, but need to recover" << dendl;
+      mds->mdcache->queue_file_recover(in);
+      mds->mdcache->do_file_recover();
+    }
+    if (in->state_test(CInode::STATE_RECOVERING)) {
+      dout(7) << "file_eval_gather finished gather, but still recovering" << dendl;
+      return;
+    }
+
     dout(7) << "file_eval_gather finished gather" << dendl;
     
     switch (lock->get_state()) {
index c35b5f4528af4077acb87263984b622d568aa2d6..c334ef52e9b0c338c0db51edc012699db7ad3785 100644 (file)
@@ -2790,9 +2790,9 @@ void MDCache::rejoin_send_acks()
 void MDCache::queue_file_recover(CInode *in)
 {
   dout(10) << "queue_file_recover " << *in << dendl;
-  in->mark_needs_file_recover();
+  in->state_clear(CInode::STATE_NEEDSRECOVER);
+  in->state_set(CInode::STATE_RECOVERING);
   in->auth_pin();
-  assert(in->filelock.get_state() == LOCK_LOCK);
   //in->filelock.get_xlock(0);
   file_recover_queue.insert(in);
 }
@@ -2856,7 +2856,7 @@ void MDCache::_recovered(CInode *in, int r)
   in->get_projected_inode()->size = in->inode.size;
 
   file_recovering.erase(in);
-  in->clear_needs_file_recover();
+  in->state_clear(CInode::STATE_RECOVERING);
 
   in->auth_unpin();
   //in->filelock.put_xlock();
index 8d89fb51b96403f1d24b7f286165df75ced5a6a2..6cc91036c8d55ab4e76d80d93d21272a289ace91 100644 (file)
@@ -212,6 +212,7 @@ void Server::_session_logged(Session *session, bool open, version_t pv)
       CInode *in = cap->get_inode();
       dout(20) << " killing capability " << cap_string(cap->issued()) << " on " << *in << dendl;
       in->remove_client_cap(session->inst.name.num());
+      mds->locker->try_file_eval(&in->filelock);
     }
     while (!session->leases.empty()) {
       ClientLease *r = session->leases.front();