From: Yan, Zheng Date: Tue, 10 Mar 2020 11:34:20 +0000 (+0800) Subject: ceph: don't skip updating wanted caps when cap is stale X-Git-Tag: v5.7-rc1~39^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0aa971b6fd3f92afef6afe24ef78d9bb14471519;p=thirdparty%2Fkernel%2Flinux.git ceph: don't skip updating wanted caps when cap is stale 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" Reviewed-by: Jeff Layton Signed-off-by: Ilya Dryomov --- diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 086bb3adc08a0..be1ae4b92cfd3 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -2008,8 +2008,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)