From: Yan, Zheng Date: Sat, 22 Apr 2017 04:27:12 +0000 (+0800) Subject: mds: issue new caps when sending reply to client X-Git-Tag: v12.0.3~35^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=799703a4acb49db0b6cc99a23e4326767e694c3a;p=ceph.git mds: issue new caps when sending reply to client After Locker::issue_new_caps() adds new Capability data struct, do not issue caps immediately. Let CInode::encode_inodestate() do the job instead. This can avoid various races that early reply is not allowed, caps that haven't been sent to client gets revoked. Fixes: http://tracker.ceph.com/issues/19635 Signed-off-by: "Yan, Zheng" --- diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 58c8795b7a84..05c605d7362e 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -1968,10 +1968,12 @@ bool Locker::issue_caps(CInode *in, Capability *only_cap) << " wanted " << ccap_string(wanted) << dendl; - // skip if suppress, and not revocation - if (cap->is_suppress() && !(pending & ~allowed)) { - dout(20) << " suppressed and !revoke, skipping client." << it->first << dendl; - continue; + if (!(pending & ~allowed)) { + // skip if suppress or new, and not revocation + if (cap->is_new() || cap->is_suppress()) { + dout(20) << " !revoke and new|suppressed, skipping client." << it->first << dendl; + continue; + } } // notify clients about deleted inode, to make sure they release caps ASAP. diff --git a/src/mds/Server.cc b/src/mds/Server.cc index d62720b46096..73f33a438a11 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -4780,9 +4780,6 @@ void Server::handle_client_mknod(MDRequestRef& mdr) newi->filelock.set_state(LOCK_EXCL); newi->authlock.set_state(LOCK_EXCL); newi->xattrlock.set_state(LOCK_EXCL); - cap->issue_norevoke(CEPH_CAP_AUTH_EXCL|CEPH_CAP_AUTH_SHARED| - CEPH_CAP_XATTR_EXCL|CEPH_CAP_XATTR_SHARED| - CEPH_CAP_ANY_FILE_WR); } } @@ -4879,8 +4876,6 @@ void Server::handle_client_mkdir(MDRequestRef& mdr) newi->filelock.set_state(LOCK_EXCL); newi->authlock.set_state(LOCK_EXCL); newi->xattrlock.set_state(LOCK_EXCL); - cap->issue_norevoke(CEPH_CAP_AUTH_EXCL|CEPH_CAP_AUTH_SHARED| - CEPH_CAP_XATTR_EXCL|CEPH_CAP_XATTR_SHARED); } // make sure this inode gets into the journal