Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp18099428rwd; Tue, 27 Jun 2023 11:35:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ45bqP+aAaQRewdbY6TZIrCa+SljLG6nmwfnvmu0O3hUF1blOEb0z8q7Ddv9KrXPgZwEzuE X-Received: by 2002:a17:907:6d8c:b0:992:1b2:4090 with SMTP id sb12-20020a1709076d8c00b0099201b24090mr3599661ejc.64.1687890916111; Tue, 27 Jun 2023 11:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687890916; cv=none; d=google.com; s=arc-20160816; b=UafkLjfLohRvnZKF4RVhcGXuT18cV36HQtMgJMynXS8osRY0THaUD9c8xrvPZZmJEJ leyJ24qTIWMDwO8hRMx34QyUol3N+yTvymsjC/63Yf0riVJKzBo/Q+dehQClH1ZFolyh ijGY6RajZQ6jDO6srVxJ/a4WwJWM0G4LjDkroS+2ec6er4c3GmAj+JIZD4WRJ1IhS3S3 1Hy18DK9sz8Q/NE/eV8OQNCURJE3mubgJIU56eDQwp3AtR7Lz4noSG6K6TXi03a3/bym HhEruNG69ewokxJ/O4xeJS7u8az4HuCOQXR4JAlvf0g/UvTkatRP/IL5VqH8nh1FTIyq DfbQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3ZIwHKoZ2Q0MBCw+53Zg48a81zOE65M97HqJdLz39Sg=; fh=ky80CPA1Hp3kwTDw0D/yN/cnG5wWJXTA9MYqCnokaWI=; b=PENDJZTKUyqm/PnXzmVPrs3sP3kmgZetBOHLO44GeSLE7iqpm0Up/Sgumci9IwfneU SrpvhhTO939YXBctRxU5rAP1XEKAIWk6nHocBVcQ7NIEpZaPKOGtmRLA5Shwf9NMR1iV y7opmjUj5zi5FQa0Rk310rH+C7R6YetufLdPvYuy2MTSljKwiWuboi62dBf3wyqHjl0x whTnmddPQNjffCCUubfD0SMB2FCSgH/qj9Dwyc70Z5xrtAAaDYxrA2s65sOm6Ozi1Jca H2dY6L6E2IuTmq85PBUsVDT+NtEuuCYFvbJNN7kPQ88AivRWD2FQ+VfNaV68xjQ7HPq0 sVeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UuAaIf33; 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 f23-20020a170906825700b0098e42bef737si3347125ejx.242.2023.06.27.11.34.44; Tue, 27 Jun 2023 11:35:16 -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=UuAaIf33; 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 S230364AbjF0SeF (ORCPT + 99 others); Tue, 27 Jun 2023 14:34:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230063AbjF0Sdx (ORCPT ); Tue, 27 Jun 2023 14:33:53 -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 2045C358B for ; Tue, 27 Jun 2023 11:32:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687890715; 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: in-reply-to:in-reply-to:references:references; bh=3ZIwHKoZ2Q0MBCw+53Zg48a81zOE65M97HqJdLz39Sg=; b=UuAaIf33IEKxW0nrK09p/Yfv7Fap2+FmhkpxG5O2axX5YdjXqJchPrFx9DpoMA09HCE6hY yfRf3IzxNVXYghxMcnxz+qveWCuMxJtbMB7newFHT60kJWIbWT5NEFXMNG93SbBsYYv89J e3f5rRmTBvbwJ9x4wOLdsT0UgriUEmw= 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-156-G5UIng78OFWZawy30wS5Yg-1; Tue, 27 Jun 2023 14:31:53 -0400 X-MC-Unique: G5UIng78OFWZawy30wS5Yg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ACF458631DB; Tue, 27 Jun 2023 18:31:52 +0000 (UTC) Received: from bcodding.csb.redhat.com (unknown [10.22.50.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2914F200BA86; Tue, 27 Jun 2023 18:31:52 +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 2/2] NFSv4: Fix dropped lock for racing OPEN and delegation return Date: Tue, 27 Jun 2023 14:31:50 -0400 Message-Id: <01047e4baa85ca541a5a43f88f588b15163292dc.1687890438.git.bcodding@redhat.com> In-Reply-To: <5577791deaa898578c8e8f86336eaca053d9efdd.1687890438.git.bcodding@redhat.com> References: <5577791deaa898578c8e8f86336eaca053d9efdd.1687890438.git.bcodding@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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_H5,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. 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". We want a fix that is much more focused to the original problem. Fix this issue by returning -EAGAIN from the nfs4_handle_delegation_recall_error() on OLD_STATEID, and use that as a signal for the delegation return code to retry the LOCK operation. We should at this point be able to send along the updated stateid. Signed-off-by: Benjamin Coddington --- fs/nfs/delegation.c | 4 +++- fs/nfs/nfs4proc.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index cf7365581031..23aeb02319a5 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -160,7 +160,9 @@ static int nfs_delegation_claim_locks(struct nfs4_state *state, const nfs4_state if (nfs_file_open_context(fl->fl_file)->state != state) continue; spin_unlock(&flctx->flc_lock); - status = nfs4_lock_delegation_recall(fl, state, stateid); + do { + status = nfs4_lock_delegation_recall(fl, state, stateid); + } while (status == -EAGAIN); if (status < 0) goto out; spin_lock(&flctx->flc_lock); diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 6bb14f6cfbc0..399db73a57f4 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -2262,6 +2262,7 @@ static int nfs4_handle_delegation_recall_error(struct nfs_server *server, struct case -NFS4ERR_BAD_HIGH_SLOT: case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: case -NFS4ERR_DEADSESSION: + case -NFS4ERR_OLD_STATEID: return -EAGAIN; case -NFS4ERR_STALE_CLIENTID: case -NFS4ERR_STALE_STATEID: -- 2.40.1