summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorYan, Zheng <zyan@redhat.com>2020-03-10 19:34:20 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-04-29 16:31:11 +0200
commit2ebb10f20ac8811ebd5ff08744c863ea41828e83 (patch)
tree1f4e6520322b7126fbb7b17edc00eefe99b44737 /fs
parenta7eba547137b9e699cea0d363ec2e31c5ef5f281 (diff)
ceph: don't skip updating wanted caps when cap is stale
[ Upstream commit 0aa971b6fd3f92afef6afe24ef78d9bb14471519 ] 1. try_get_cap_refs() fails to get caps and finds that mds_wanted does not include what it wants. It returns -ESTALE. 2. ceph_get_caps() calls ceph_renew_caps(). ceph_renew_caps() finds that inode has cap, so it calls ceph_check_caps(). 3. ceph_check_caps() finds that issued caps (without checking if it's stale) already includes caps wanted by open file, so it skips updating wanted caps. Above events can cause an infinite loop inside ceph_get_caps(). Signed-off-by: "Yan, Zheng" <zyan@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/ceph/caps.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 4c0b220e20ba..5241102b81a8 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -1972,8 +1972,12 @@ retry_locked:
}
/* want more caps from mds? */
- if (want & ~(cap->mds_wanted | cap->issued))
- goto ack;
+ if (want & ~cap->mds_wanted) {
+ if (want & ~(cap->mds_wanted | cap->issued))
+ goto ack;
+ if (!__cap_is_valid(cap))
+ goto ack;
+ }
/* things we might delay */
if ((cap->issued & ~retain) == 0 &&