From a74434079088129244b7aae6ccc6df7094282eba Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Sat, 22 Apr 2017 12:27:12 +0800 Subject: [PATCH] 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" (cherry picked from commit 799703a4acb49db0b6cc99a23e4326767e694c3a) --- src/mds/Locker.cc | 10 ++++++---- src/mds/Server.cc | 5 ----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 410ad14f4fc84..e1e1618c21d88 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -1905,10 +1905,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 e95b74e6489f4..016af8ae9215e 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -4695,9 +4695,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); } } @@ -4793,8 +4790,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 -- 2.39.5