From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0F95C38A2F for ; Sat, 18 Apr 2020 14:51:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD02C21D79 for ; Sat, 18 Apr 2020 14:51:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587221493; bh=lSpX98LlHpBgkq+KsmD2J8feAmxZfyFHyjH3hCAT2tg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=trjZ4jy4opeh6+STDzlQoPfTS+w/VtwHv89gbtSWKWjtmrNnASxHmOPG5O+PqXuKm 5Lwi4qcpRVMduCZ4V/EAe2jt3BPrnMq2rwFA5o7L7URzCAIPm61TpIu878nHHfwRkW UgSenRHFL/1JevM//h6pJxiS8F6smNsMI0UZddrc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729065AbgDROvc (ORCPT ); Sat, 18 Apr 2020 10:51:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:52818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728388AbgDROmh (ORCPT ); Sat, 18 Apr 2020 10:42:37 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A5D9D22245; Sat, 18 Apr 2020 14:42:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587220957; bh=lSpX98LlHpBgkq+KsmD2J8feAmxZfyFHyjH3hCAT2tg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AXnxeqi27dTCI1sP8p2exFdrcFSCM2MBgEpf7q+XYMnyxCnDF8YInv1pcyvRqFZ3L vy23XeIx2TfPZ9wOoBMAAnRVcE0Hd6TUPItyoEToHxEL9w1C53Ab3A23e584zsXzqs SMSt+nltTILqzGHVKNjXx35DlSAkFRRVBmwLAhtg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Yan, Zheng" , Jeff Layton , Ilya Dryomov , Sasha Levin , ceph-devel@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 08/47] ceph: don't skip updating wanted caps when cap is stale Date: Sat, 18 Apr 2020 10:41:48 -0400 Message-Id: <20200418144227.9802-8-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200418144227.9802-1-sashal@kernel.org> References: <20200418144227.9802-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Yan, Zheng" [ 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" Reviewed-by: Jeff Layton Signed-off-by: Ilya Dryomov Signed-off-by: Sasha Levin --- fs/ceph/caps.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 4c0b220e20bab..5241102b81a82 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -1972,8 +1972,12 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags, } /* 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 && -- 2.20.1