Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1321700ybp; Wed, 9 Oct 2019 12:12:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOaKxojArJ7o1V4vtyO7CoVysG2QjCrsLb29yLKfmiYsG2ucniAG/H1zCYq/VQBsmUUNUD X-Received: by 2002:a05:6402:2022:: with SMTP id ay2mr4424512edb.219.1570648365768; Wed, 09 Oct 2019 12:12:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570648365; cv=none; d=google.com; s=arc-20160816; b=TaNOQQqOxFG/HWqib9fIkdVXL78b9f2pZYeeBQBdBhG50iJZpXshwQRwlKn1y8kNU8 /Wn3zSriA9WXMut8C9lgDxsMWGaJ7x41fQfAr3Z9Uaa7CE42iLTOpLwH71muddqN5jUv gf1PkIeEvC0u5amTySQFZA69k4xRwLrBhSZxAdsSx+OCLLm/a1vfq1h10QX/XhqDQiQa GQKaox/CnOYsvxQTXch0Z0mkj57PGBwMh4NIIkPeCFqBfBjVaNYcJphfvoyjppAnTueq yoIGGFI6mKXiD+JQrgyIdRo7H2rcvodZnhI7nI3vIGCLEsN60wrhvb38CSvC3XmMW7hs URdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=SpmjXOP3fAJQHC8ec46VpiTHNHuyMjX4WzY9jwgIY30=; b=OK1V9MfyO2S0OSIFBMhDWtZO7+WhYo0gNEQ3q1MPfXy5vZO4/stf3Xu51V9CzE7XiK JAjenAxt9kM+O5ks16EPJj38tNYM1FOEb2N4J3RKbkl3yUxRxUkylePUzvXxGlFMPFAX AxrRmIJBLREQdbu0XrF8qE1L2Vz/YiXTpdC3MQjbjcwXCnpv+c9xr298k/jRDUTytMAL BOTDthudfbZQXGJnay70ZRGDS16id9dcIM92CiuoDA2gplnIcZXs+4d5waOV/QJS5ORX fY2x82bwyHfzDGXvInN1UhMASbFurX6jnPhr3dQmOuKz7z9Zhn7atWEPiYCog4VEfzjQ Guqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2si1856662edw.29.2019.10.09.12.12.10; Wed, 09 Oct 2019 12:12:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732137AbfJITLj (ORCPT + 99 others); Wed, 9 Oct 2019 15:11:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47440 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732131AbfJITLi (ORCPT ); Wed, 9 Oct 2019 15:11:38 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 858E310C0934; Wed, 9 Oct 2019 19:11:38 +0000 (UTC) Received: from coeurl.usersys.redhat.com (ovpn-121-39.rdu2.redhat.com [10.10.121.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68FE360A35; Wed, 9 Oct 2019 19:11:38 +0000 (UTC) Received: by coeurl.usersys.redhat.com (Postfix, from userid 1000) id B928D20BF9; Wed, 9 Oct 2019 15:11:37 -0400 (EDT) From: Scott Mayhew To: bfields@fieldses.org, chuck.lever@oracle.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH] nfsd4: fix up replay_matches_cache() Date: Wed, 9 Oct 2019 15:11:37 -0400 Message-Id: <20191009191137.28007-1-smayhew@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]); Wed, 09 Oct 2019 19:11:38 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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. Fixes: 53da6a53e1d4 ("nfsd4: catch some false session retries") Signed-off-by: Scott Mayhew --- fs/nfsd/nfs4state.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index c65aeaa812d4..08f6eb2b73f8 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -3548,12 +3548,17 @@ static bool replay_matches_cache(struct svc_rqst *rqstp, (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)) -- 2.17.2