From: Yan, Zheng Date: Thu, 20 Feb 2014 08:09:57 +0000 (+0800) Subject: client: fix race between cap issue and revoke X-Git-Tag: v0.79~179^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c1e40c60ac6a5100f7a1b3896bcd91af3b7154b9;p=ceph.git client: fix race between cap issue and revoke 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 --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 9de24bb8116..a129f6d16ba 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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::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::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)