]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: don't issue/revoke caps before client has caps
authorYan, Zheng <zheng.z.yan@intel.com>
Sun, 13 Apr 2014 12:07:33 +0000 (20:07 +0800)
committerYan, Zheng <zheng.z.yan@intel.com>
Sun, 13 Apr 2014 12:38:04 +0000 (20:38 +0800)
If early reply is not allowed, MDS does not send reply to client immediately
after Locker::issue_new_caps adds new caps. So MDS can revoke the caps before
sending reply to client.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
src/mds/CInode.cc
src/mds/Locker.cc
src/mds/MDCache.cc
src/mds/Migrator.cc

index 2f5c842cdb658ca7af6bace710f68f2228cd2c02..53a0f4435caeb9473fb1d6c48555ee3471688d1a 100644 (file)
@@ -2996,6 +2996,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session,
       issue = cap->pending();
       cap->set_last_issue();
       cap->set_last_issue_stamp(ceph_clock_now(g_ceph_context));
+      cap->clear_new();
       e.cap.caps = issue;
       e.cap.wanted = cap->wanted();
       e.cap.cap_id = cap->get_cap_id();
index 932a585a84a25b566b13d5f2df4a50938a1be7cf..6baf53485e063aacf1c80147cd29a4474614e075 100644 (file)
@@ -1709,6 +1709,7 @@ Capability* Locker::issue_new_caps(CInode *in,
     // new cap
     cap = in->add_client_cap(my_client, session, realm);
     cap->set_wanted(my_want);
+    cap->mark_new();
     cap->inc_suppress(); // suppress file cap messages for new cap (we'll bundle with the open() reply)
     is_new = true;
   } else {
@@ -1842,7 +1843,11 @@ bool Locker::issue_caps(CInode *in, Capability *only_cap)
        seq = cap->issue((wanted|likes) & allowed);
       int after = cap->pending();
 
-      if (seq > 0) {
+      if (cap->is_new()) {
+       // haven't send caps to client yet
+       if (before & ~after)
+         cap->confirm_receipt(seq, after);
+      } else {
         dout(7) << "   sending MClientCaps to client." << it->first
                << " seq " << cap->get_last_seq()
                << " new pending " << ccap_string(after) << " was " << ccap_string(before) 
index 362f0f61dbf26660a08ec8660f04315299b03464..49f33080f5bf59822425f44ab4026afa7d90b004 100644 (file)
@@ -5478,6 +5478,8 @@ void MDCache::do_cap_import(Session *session, CInode *in, Capability *cap,
     if (cap->get_last_seq() == 0) // reconnected cap
       cap->inc_last_seq();
     cap->set_last_issue();
+    cap->set_last_issue_stamp(ceph_clock_now(g_ceph_context));
+    cap->clear_new();
     MClientCaps *reap = new MClientCaps(CEPH_CAP_OP_IMPORT,
                                        in->ino(),
                                        realm->inode->ino(),
index 84c0a0e3d29f2d1dcf6b981636f3401c92d7e5c5..cde0f704c9244455833abb025223db1b2cae89c9 100644 (file)
@@ -2574,7 +2574,6 @@ void Migrator::import_finish(CDir *dir, bool notify, bool last)
        assert(session);
        Capability *cap = in->get_client_cap(q->first);
        assert(cap);
-       cap->clear_new();
        cap->merge(q->second, true);
        mds->mdcache->do_cap_import(session, in, cap, q->second.cap_id, q->second.seq,
                                    q->second.mseq - 1, it->second.peer, CEPH_CAP_FLAG_AUTH);