Received: by 2002:a05:6358:615c:b0:12b:e873:ff31 with SMTP id 28csp3680611rwt; Fri, 4 Aug 2023 08:10:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0JI96H6WomSrad0lCuYuiUUlqBREiyMG+QAbVO/gwkiMX8X2XOeXr7sZkEDIdIw62PlYL X-Received: by 2002:a05:6a00:21d4:b0:66e:4df5:6c10 with SMTP id t20-20020a056a0021d400b0066e4df56c10mr2113055pfj.34.1691161845238; Fri, 04 Aug 2023 08:10:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691161845; cv=none; d=google.com; s=arc-20160816; b=Vyn0Fw9IbZc/YscBSxjkHcXWa/7fGg1JXCBJRwXt1xodXOqeXd9CTFLdUg05PfPrXL 6hjgNsbYks2Uzgtli3mrTXW+MKb2L7OSayKYJdmzyz1+VqwHE5yuiUKfS9vjoGwJw9So uKFawqhfxUBos+Hs7hvx1Vvjir3gNnlpcQv3i3t/zBHywBeSy53OSIDtNPcBSvKD0cY3 W1C1fWbYESDWGFUcNCosXl9t+AzHlhTrXdFumiJs/SE2JFjL96bTRLnr9reK2j47UAYT k07iQ8PRNqcmlNmsaSikkrs/BuupysEVZa3gzJZRP+m1vuKBD4gQtcMRJpEh4ExOwdMo zWZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=BPOk4LAQU+258S8hwj/BFHvWoB3AgduJ/PxmSqV8SXE=; fh=Zv4kv3RnsdMqlI7gM4qx1aLCYSiRdyeSvOotGwFUZxk=; b=tR54YWUjCPYnQL46Kj+FoT+1BPI/2/t9cVoZDAKedmtYg8eea713OumYND9W+ja+IY TaR+7SQfXVU5q541U+5v8pAyx+2CrunLIfMrRS+JrmKGsY8bfHVr/w0CmdSSR2prTa7l BmT32NCmrLVeKlkAa6M1OvlfMI/Z1pGzaZo7mlTYU1IxloVWUYaXgfJHFHIjLc+LdrjP 0zY8HFykD3Am0Arsr2YypsNXDQEuO1SfzeJGkUBHI5s8nw2UHDWH92RTxYlyvr+A6DaP 1cHnJ9Nh7w/7GD7mHs45Mz3HDl3EaUaLyGdJ62X3aVYWJA6sLC30NqMjl0tSw82IKmQF ALmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DCjMyBAZ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c37-20020a631c65000000b0055c868268f9si1863786pgm.462.2023.08.04.08.09.43; Fri, 04 Aug 2023 08:10:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DCjMyBAZ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229835AbjHDOxK (ORCPT + 99 others); Fri, 4 Aug 2023 10:53:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229812AbjHDOxJ (ORCPT ); Fri, 4 Aug 2023 10:53:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59DFD49C1 for ; Fri, 4 Aug 2023 07:52:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691160743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=BPOk4LAQU+258S8hwj/BFHvWoB3AgduJ/PxmSqV8SXE=; b=DCjMyBAZp73HW3eldqGrWAJgBzY7BiRtWo6fY7hxJhg0yTIks3IUK1+efpluY70AA4KvE4 FSVE4GgtPAThUOraydsTG6ipcC3f+VmR++EHIHBGfOkb26ffHf0PtCvGn0/Qz7dM2c0PBh QSgJm8OO8O7fq+ccB5Exi9j2/Ze0YMg= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-232-qFJvPsM6MC27C5lfYtdbSA-1; Fri, 04 Aug 2023 10:52:22 -0400 X-MC-Unique: qFJvPsM6MC27C5lfYtdbSA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 996CA3C025D3; Fri, 4 Aug 2023 14:52:21 +0000 (UTC) Received: from bcodding.csb.redhat.com (unknown [10.22.50.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 295A040C206F; Fri, 4 Aug 2023 14:52:21 +0000 (UTC) From: Benjamin Coddington To: Chuck Lever III , Jeff Layton Cc: linux-nfs@vger.kernel.org Subject: [PATCH] nfsd: Fix race to FREE_STATEID and cl_revoked Date: Fri, 4 Aug 2023 10:52:20 -0400 Message-Id: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org We have some reports of linux NFS clients that cannot satisfy a linux knfsd server that always sets SEQ4_STATUS_RECALLABLE_STATE_REVOKED even though those clients repeatedly walk all their known state using TEST_STATEID and receive NFS4_OK for all. Its possible for revoke_delegation() to set NFS4_REVOKED_DELEG_STID, then nfsd4_free_stateid() finds the delegation and returns NFS4_OK to FREE_STATEID. Afterward, revoke_delegation() moves the same delegation to cl_revoked. This would produce the observed client/server effect. Fix this by ensuring that the setting of sc_type to NFS4_REVOKED_DELEG_STID and move to cl_revoked happens within the same cl_lock. This will allow nfsd4_free_stateid() to properly remove the delegation from cl_revoked. Link: https://bugzilla.redhat.com/show_bug.cgi?id=2217103 Link: https://bugzilla.redhat.com/show_bug.cgi?id=2176575 Signed-off-by: Benjamin Coddington --- fs/nfsd/nfs4state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 3aefbad4cc09..daf305daa751 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1354,9 +1354,9 @@ static void revoke_delegation(struct nfs4_delegation *dp) trace_nfsd_stid_revoke(&dp->dl_stid); if (clp->cl_minorversion) { + spin_lock(&clp->cl_lock); dp->dl_stid.sc_type = NFS4_REVOKED_DELEG_STID; refcount_inc(&dp->dl_stid.sc_count); - spin_lock(&clp->cl_lock); list_add(&dp->dl_recall_lru, &clp->cl_revoked); spin_unlock(&clp->cl_lock); } -- 2.40.1