From patchwork Tue Jan 7 20:54:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 234367 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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, 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 A051AC282DD for ; Tue, 7 Jan 2020 21:08:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 62AB220678 for ; Tue, 7 Jan 2020 21:08:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578431322; bh=uVBvV2Nb/uTe5XdSsCAhOEwc3wM/BVjBR7QlHHVPaRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=XJnzFH5z/akIHud5IiZGhWi8DLwVTh+LPDk/dcZF6kmUE871HvQXXaEVRyX/DfpaF DQdrttQ0IAWPMkK70Az9DuL7w/Ay26rd3/UIt61YAlWz4RVEjLG3bfcTrO/lTthpwa KK9DHJjaGoFYvOGQadBtHYy9snSG20jT+FnEgCE4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729546AbgAGVIl (ORCPT ); Tue, 7 Jan 2020 16:08:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:33174 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729722AbgAGVIj (ORCPT ); Tue, 7 Jan 2020 16:08:39 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3ADE920678; Tue, 7 Jan 2020 21:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578431318; bh=uVBvV2Nb/uTe5XdSsCAhOEwc3wM/BVjBR7QlHHVPaRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZkzHk+8PXiPM5S5tkNz4dMJnWfncJ0u39XmT01/qXu8p1K7Wf9w9zXQyj5sPOa99I o6us/7DsMrYp2pxGd+Tjqq7WD6PPiVy+LrkmlkuwNxOfhIyhvo77qX2/TQyDW0fLH9 WwZQ0bzlEliYWu6IFWXdkrnj0mZdLWc1ER8ArKHU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Scott Mayhew , "J. Bruce Fields" Subject: [PATCH 4.19 081/115] nfsd4: fix up replay_matches_cache() Date: Tue, 7 Jan 2020 21:54:51 +0100 Message-Id: <20200107205304.751841084@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200107205240.283674026@linuxfoundation.org> References: <20200107205240.283674026@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Scott Mayhew commit 6e73e92b155c868ff7fce9d108839668caf1d9be upstream. When running an nfs stress test, I see quite a few cached replies that don't match up with the actual request. The first comment in replay_matches_cache() makes sense, but the code doesn't seem to match... fix it. This isn't exactly a bugfix, as the server isn't required to catch every case of a false retry. So, we may as well do this, but if this is fixing a problem then that suggests there's a client bug. Fixes: 53da6a53e1d4 ("nfsd4: catch some false session retries") Signed-off-by: Scott Mayhew Signed-off-by: J. Bruce Fields Signed-off-by: Greg Kroah-Hartman --- fs/nfsd/nfs4state.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -3072,12 +3072,17 @@ static bool replay_matches_cache(struct (bool)seq->cachethis) return false; /* - * If there's an error than the reply can have fewer ops than - * the call. But if we cached a reply with *more* ops than the - * call you're sending us now, then this new call is clearly not - * really a replay of the old one: + * If there's an error then the reply can have fewer ops than + * the call. */ - if (slot->sl_opcnt < argp->opcnt) + if (slot->sl_opcnt < argp->opcnt && !slot->sl_status) + return false; + /* + * But if we cached a reply with *more* ops than the call you're + * sending us now, then this new call is clearly not really a + * replay of the old one: + */ + if (slot->sl_opcnt > argp->opcnt) return false; /* This is the only check explicitly called by spec: */ if (!same_creds(&rqstp->rq_cred, &slot->sl_cred))