]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: never issue caps in file_eval
authorSage Weil <sage@newdream.net>
Tue, 14 Apr 2009 14:29:38 +0000 (07:29 -0700)
committerSage Weil <sage@newdream.net>
Tue, 14 Apr 2009 14:29:38 +0000 (07:29 -0700)
We should do it explicitly when it is appropriate.  Normally, that's
in eval_gather(), or when caps wanted changes, or something
similar.

When we explicitly issue caps, avoid scanning the whole list when
possible.

src/kernel/caps.c
src/mds/Locker.cc
src/mds/Locker.h

index 8c4e4bbd128a1d1f9cfeca73b63c43c9249bcddb..0699a9bbe2d61f8968b34572b89813a544213455 100644 (file)
@@ -1066,8 +1066,8 @@ retry_locked:
             ceph_cap_string(retain),
             ceph_cap_string(__ceph_caps_issued(ci, NULL)),
             (flags & CHECK_CAPS_AUTHONLY) ? " AUTHONLY":"");
-       dout(20, " now %lu hold until min %lu max %lu\n", 
-            jiffies, ci->i_hold_caps_min, ci->i_hold_caps_max);
+       dout(20, " hold for min %ld max %ld\n", 
+            ci->i_hold_caps_min - jiffies, ci->i_hold_caps_max - jiffies);
 
        /*
         * If we no longer need to hold onto old our caps, and we may
index c7ed96acd143940dc4fae85b79093db53b77cb7d..680929103361bc30efc183c3440ae9fe97582318 100644 (file)
@@ -933,6 +933,9 @@ void Locker::file_update_finish(CInode *in, Mutation *mut, bool share, int clien
   mut->cleanup();
   delete mut;
 
+  if (cap && cap->wanted() & ~cap->pending())
+    issue_caps(in, cap);
+
   if (share && in->is_auth() && in->filelock.is_stable())
     share_inode_max_size(in);
 }
@@ -993,7 +996,7 @@ Capability* Locker::issue_new_caps(CInode *in,
 
 
 
-bool Locker::issue_caps(CInode *in)
+bool Locker::issue_caps(CInode *in, Capability *only_cap)
 {
   // allowed caps are determined by the lock mode.
   int all_allowed = in->get_caps_allowed_by_type(CAP_ANY);
@@ -1026,9 +1029,12 @@ bool Locker::issue_caps(CInode *in)
     check_inode_max_size(in, true);
 
   // client caps
-  for (map<int, Capability*>::iterator it = in->client_caps.begin();
-       it != in->client_caps.end();
-       it++) {
+  map<int, Capability*>::iterator it;
+  if (only_cap)
+    it = in->client_caps.find(only_cap->get_client());
+  else
+    it = in->client_caps.begin();
+  for (; it != in->client_caps.end(); it++) {
     Capability *cap = it->second;
     if (cap->is_stale())
       continue;
@@ -1087,6 +1093,9 @@ bool Locker::issue_caps(CInode *in)
        mds->send_message_client(m, it->first);
       }
     }
+
+    if (only_cap)
+      break;
   }
 
   return (nissued == 0);  // true if no re-issued, no callbacks
@@ -1470,7 +1479,7 @@ void Locker::handle_client_caps(MClientCaps *m)
   }
 
   int op = m->get_op();
-  bool do_issue = true;
+  bool can_issue = true;
 
   if (op == CEPH_CAP_OP_RENEW) {
     if (cap->touch()) {
@@ -1562,7 +1571,7 @@ void Locker::handle_client_caps(MClientCaps *m)
        }
       }
       if (m->get_op() == CEPH_CAP_OP_DROP)
-       do_issue = false;
+       can_issue = false;
       
       if (!_do_cap_update(in, cap, m->get_dirty(), m->get_wanted(), follows, m, ack)) {
        // no update, ack now.
@@ -1572,9 +1581,11 @@ void Locker::handle_client_caps(MClientCaps *m)
        
       eval_cap_gather(in);
       if (in->filelock.is_stable())
-       file_eval(&in->filelock, do_issue);
+       file_eval(&in->filelock, can_issue);
       if (in->authlock.is_stable())
        eval(&in->authlock);
+      if (cap->wanted() & ~cap->pending())
+       issue_caps(in, cap);
     }
 
     // done?
@@ -2915,7 +2926,7 @@ void Locker::try_file_eval(ScatterLock *lock)
 
 
 
-void Locker::file_eval(ScatterLock *lock, bool do_issue)
+void Locker::file_eval(ScatterLock *lock, bool can_issue)
 {
   CInode *in = (CInode*)lock->get_parent();
   int loner_wanted, other_wanted;
@@ -2988,12 +2999,6 @@ void Locker::file_eval(ScatterLock *lock, bool do_issue)
            << " on " << *lock->get_parent() << dendl;
     simple_sync(lock);
   }
-  
-  else
-    do_issue = true;
-
-  if (in->is_any_caps() && do_issue)
-    issue_caps(in);
 }
 
 
index b2da6fb26f71aab63b2c44bf5300d0898b677089..720b68d708fdfa5fc9107a0192af52bb7a9a1463 100644 (file)
@@ -177,7 +177,7 @@ protected:
   // file
 public:
   void try_file_eval(ScatterLock *lock);
-  void file_eval(ScatterLock *lock, bool do_issue=true);
+  void file_eval(ScatterLock *lock, bool can_issue=true);
 protected:
   void handle_file_lock(ScatterLock *lock, MLock *m);
   void file_mixed(ScatterLock *lock);
@@ -191,7 +191,7 @@ public:
  public:
   version_t issue_file_data_version(CInode *in);
   Capability* issue_new_caps(CInode *in, int mode, Session *session, SnapRealm *conrealm=0);
-  bool issue_caps(CInode *in);
+  bool issue_caps(CInode *in, Capability *only_cap=0);
   void issue_truncate(CInode *in);
   void revoke_stale_caps(Session *session);
   void resume_stale_caps(Session *session);