Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp23637286rwd; Sat, 1 Jul 2023 05:13:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7jsMBncd4dp1gaxQWERfRxDeMXhQZf6DLHcxHk1W3qoYgC2lRHVBjrI10X2zVkw12x2z3n X-Received: by 2002:a05:6870:b94:b0:1b0:15ca:479 with SMTP id lg20-20020a0568700b9400b001b015ca0479mr7881280oab.55.1688213603689; Sat, 01 Jul 2023 05:13:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688213603; cv=none; d=google.com; s=arc-20160816; b=tvfgMimb88oe1pBTSoMI2LQF8piPo95cHjDsLFvGlcuKQ6Ag918HCcPOzH7aJgxS3N y78Jh5+O4XOSn6IJNL1ek50iQ0bEhALoGa/O/K956R3e0/NpsGB4rj+/UPrb/57Kfjit kKfmm+EgXl74vcaFZApPiaNQfnEDUvkjC213wziknv2vpg+C/du9aL0nLHf1FnasO6Iy n9rt8LM0/l+EHhx6hZqNaNWEe5TbSXL1qV0qEQByztTmbL8H4F4IMWFqGDyCpeViOxOR es4ysUVlhbYp+4zqPRbj0opwLOip6mf9ukwFnxpJLSlmCTRno34c3APXRB+pVqkjnQVv 7rqg== 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=kEHGmY1pqMlJdyUe2iWb0kBBqP+sYKT2BDnD+9vMHYg=; fh=ky80CPA1Hp3kwTDw0D/yN/cnG5wWJXTA9MYqCnokaWI=; b=S9YTgkkitQApp1vW4JA+EGTMOm7mNL4+uBmLf3yREnSB6bpGGtLiYyQfeh3i8ImVbW I1Vm+PQoI8iwRw0QLHaZ8BWAHNoRDWwi4ivwg/c/EZ1pDksAOvMJIRo/6f5/jdnozjOo jeDFk9jvn/6/SVczqF4mE+/XHE7pgbwAoRxklpluWv+IOQ2sXQAlHs0DRcF3uEiRKx1u vh3DfVYOLRzZJsqYmZ2zu/RLDYitTYicTqJf8xs0nOLn9JRsqrvE0YRvfIim0rslkH21 4OjNOA4wZIDFMYR4kSismPPPhmWidKf4C2YRLaQM/WhJhEQ72aPseItbeyxuNMnwa0RE 0vDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KgWg+K8x; 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 t9-20020a17090abc4900b0026306d2d484si9702584pjv.111.2023.07.01.05.12.58; Sat, 01 Jul 2023 05:13:23 -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=KgWg+K8x; 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 S229507AbjGALQT (ORCPT + 99 others); Sat, 1 Jul 2023 07:16:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbjGALQS (ORCPT ); Sat, 1 Jul 2023 07:16:18 -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 A57C33C05 for ; Sat, 1 Jul 2023 04:15:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688210130; 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=kEHGmY1pqMlJdyUe2iWb0kBBqP+sYKT2BDnD+9vMHYg=; b=KgWg+K8xytjxk+POtcy52zNJ+psZaYnjusqH1qUHLDo5wtyuZ0VK77EHFShR1dZp4G0fPL 7fFGK7d8E6q0yM1YXtzFw5iCd+xfNY+OTd3SDBGh4xi4V4qMOU/56N+H/AIUqNhqZcJu6a uG/m63m7kPX5bkWuv+0H1B1Q6B4hxtM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [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-67-H4PUysMvNPCjeHBeM68hNQ-1; Sat, 01 Jul 2023 07:15:27 -0400 X-MC-Unique: H4PUysMvNPCjeHBeM68hNQ-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 2C99A380350D; Sat, 1 Jul 2023 11:15:27 +0000 (UTC) Received: from bcodding.csb.redhat.com (unknown [10.22.50.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9717D1121314; Sat, 1 Jul 2023 11:15:26 +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 v3] NFSv4: Fix dropped lock for racing OPEN and delegation return Date: Sat, 1 Jul 2023 07:15:25 -0400 Message-Id: <93929ecf62e79670f1e3a1878757fc9fa443aa7c.1688210094.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..f350f41e1967 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; + else 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