Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp22297938rwd; Fri, 30 Jun 2023 06:27:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlGH0M6bBwc389pfenG75oWSHkU0c8iZoBjvF2wmODt3bbwbtCFq9K+yyPKCNBDk32gS+iQf X-Received: by 2002:a92:c80d:0:b0:345:c8ce:ff49 with SMTP id v13-20020a92c80d000000b00345c8ceff49mr1940756iln.11.1688131669883; Fri, 30 Jun 2023 06:27:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688131669; cv=none; d=google.com; s=arc-20160816; b=fg+ZSIO/HWNJ9yosop4HaZRzB/B94CzvvyQM31E1eVrIRWbhPwqtu8kvEh+vKlmq1l H4KPf7qFOTWcUxdqXGEVUDGiweH2ZkruDzNZxmoyEd+TzmP9ajeTrskX6opxS6U9yxef xZTY5X20hA8hkyFMIrPqFZ0YCr57Mfcj0//4iJYD5c+BwO9cwGIz1rqU1fepfDF2XEIC wMlSqmBwJJmILbZ64nbGDfHpr7xhCz9o31wbISxiYV4VwBwYhCOn4kBkDyWe0dAwcrDQ 7ux+P0FcdNfrVN1WmG71fBANGQ9P+Y0F0XQVXgQIhj4Oa4dGBI6irAECBt1/dRjoR2rd 3aoQ== 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=7+h+cT0KLIqwZmvYcotSB3FClbMsUogxCPafGAVI4zE=; fh=ky80CPA1Hp3kwTDw0D/yN/cnG5wWJXTA9MYqCnokaWI=; b=mu6LtPDHwjae2nRYVbx+79IQN9le5AxfRj9PBvyMV87gf3WMqTm/em+ZiNDu7zqqhP +IxC83G1WogjFYHmqsLdX1ONEaJo6iiFbr1VLsyCCntCzrzIIEMUa6BdhbUKdSbs4adB l22qYB7xjvQ89gOheeRvTDPca2qOCZjjugGLd0igTSP0/fYZ1gg8Ny2IEa6kslMYWWqm YnqiCmnrTeL7NdpzdLoskdMrToFJfoac/ibXpATJ+9l+E0422Zf9YB5VzwtrMScjTgor FP1D1ari4pxYnmtCjMUgb8/rN+n6lQdmaKXtdf5W2mJyOsi2qMDXIaR/WXV/3XB6j5Ra 1b5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Fctjwbia; 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 u189-20020a6385c6000000b0055387ef9633si12451467pgd.804.2023.06.30.06.27.28; Fri, 30 Jun 2023 06:27:49 -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=Fctjwbia; 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 S232535AbjF3NTS (ORCPT + 99 others); Fri, 30 Jun 2023 09:19:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232571AbjF3NTL (ORCPT ); Fri, 30 Jun 2023 09:19:11 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 651D33A98 for ; Fri, 30 Jun 2023 06:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688131100; 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=7+h+cT0KLIqwZmvYcotSB3FClbMsUogxCPafGAVI4zE=; b=FctjwbiaZhN8/uF5ewWm2t+5IsyPU+4IY7R7yfJowMXuWk6EPc2g0NF3SaJh+2k48mWHL5 k/MET92Cy/2qYP5m1lBTvCYQMFUh2XdcCGZXfjo8b33a0327R/k+gVwuCvqk2lREO0ogUX eaDgp7OfHI3eQCCe8Ztf+7VRf8bF2do= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-355-00DxZ6I1N36hx4SD5dwAcA-1; Fri, 30 Jun 2023 09:18:15 -0400 X-MC-Unique: 00DxZ6I1N36hx4SD5dwAcA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 56C0C856F67; Fri, 30 Jun 2023 13:18:14 +0000 (UTC) Received: from bcodding.csb.redhat.com (unknown [10.22.50.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7F271121314; Fri, 30 Jun 2023 13:18:13 +0000 (UTC) From: Benjamin Coddington To: trond.myklebust@hammerspace.com, anna@kernel.org Cc: Olga.Kornievskaia@netapp.com, linux-nfs@vger.kernel.org Subject: [PATCH v2] NFSv4: Fix dropped lock for racing OPEN and delegation return Date: Fri, 30 Jun 2023 09:18:13 -0400 Message-Id: <50f5a8389be39630e9babeb9caba8377773c1cf2.1688131022.git.bcodding@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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, T_SCC_BODY_TEXT_LINE 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 Commmit f5ea16137a3f ("NFSv4: Retry LOCK on OLD_STATEID during delegation return") attempted to solve this problem by using nfs4's generic async error handling, but introduced a regression where v4.0 lock recovery would hang. The additional complexity introduced by overloading that error handling is not necessary for this case. This patch expects that commit to be reverted. The problem as originally explained in the above commit is: There's a small window where a LOCK sent during a delegation return can race with another OPEN on client, but the open stateid has not yet been updated. In this case, the client doesn't handle the OLD_STATEID error from the server and will lose this lock, emitting: "NFS: nfs4_handle_delegation_recall_error: unhandled error -10024". Fix this by using the old_stateid refresh helpers if the server replies with OLD_STATEID. Suggested-by: Trond Myklebust Signed-off-by: Benjamin Coddington --- fs/nfs/nfs4proc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 6bb14f6cfbc0..bdfb4ac144d2 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -7180,8 +7180,15 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata) } else if (!nfs4_update_lock_stateid(lsp, &data->res.stateid)) goto out_restart; break; - case -NFS4ERR_BAD_STATEID: case -NFS4ERR_OLD_STATEID: + if (data->arg.new_lock_owner != 0 && + nfs4_refresh_open_old_stateid(&data->arg.open_stateid, + lsp->ls_state)) + goto out_restart; + if (nfs4_refresh_lock_old_stateid(&data->arg.lock_stateid, lsp)) + goto out_restart; + fallthrough; + case -NFS4ERR_BAD_STATEID: case -NFS4ERR_STALE_STATEID: case -NFS4ERR_EXPIRED: if (data->arg.new_lock_owner != 0) { -- 2.40.1