]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fix race between cap issue and revoke
authorYan, Zheng <zheng.z.yan@intel.com>
Thu, 20 Feb 2014 08:09:57 +0000 (16:09 +0800)
committerYan, Zheng <zheng.z.yan@intel.com>
Thu, 27 Feb 2014 03:59:59 +0000 (11:59 +0800)
If we receive new caps from the auth MDS and the non-auth MDS is
revoking the newly issued caps, we should release the caps from
the non-auth MDS. The scenario is filelock's state changes from
SYNC to LOCK. Non-auth MDS revokes Fc cap, the client gets Fc cap
from the auth MDS at the same time.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
src/client/Client.cc

index 9de24bb8116e717aa4f141e434dc2090e7702b5b..a129f6d16bac0d7763ef65d0b401dbb2e1b5ff11 100644 (file)
@@ -2944,6 +2944,18 @@ void Client::add_update_cap(Inode *in, MetaSession *mds_session, uint64_t cap_id
           << " on " << *in
           << dendl;
 
+  if ((issued & ~old_caps) && in->auth_cap == cap) {
+    // non-auth MDS is revoking the newly grant caps ?
+    for (map<int,Cap*>::iterator it = in->caps.begin(); it != in->caps.end(); ++it) {
+      if (it->second == cap)
+       continue;
+      if (it->second->implemented & ~it->second->issued & issued) {
+       check_caps(in, true);
+       break;
+      }
+    }
+  }
+
   if (issued & ~old_caps)
     signal_cond_list(in->waitfor_caps);
 }
@@ -3765,6 +3777,18 @@ void Client::handle_cap_grant(MetaSession *session, Inode *in, Cap *cap, MClient
     ldout(cct, 10) << "  grant, new caps are " << ccap_string(new_caps & ~old_caps) << dendl;
     cap->issued = new_caps;
     cap->implemented |= new_caps;
+
+    if (cap == in->auth_cap) {
+      // non-auth MDS is revoking the newly grant caps ?
+      for (map<int,Cap*>::iterator it = in->caps.begin(); it != in->caps.end(); ++it) {
+       if (it->second == cap)
+         continue;
+       if (it->second->implemented & ~it->second->issued & new_caps) {
+         check = true;
+         break;
+       }
+      }
+    }
   }
 
   if (check)