Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp79908ybx; Thu, 31 Oct 2019 16:16:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqyma0rQusNxsO1/fuMt3+BAl49jAHka7oOc3dDCITwal8FLd92b31qbidME++1ErcvnhEnh X-Received: by 2002:a05:6402:1049:: with SMTP id e9mr9282307edu.91.1572563812399; Thu, 31 Oct 2019 16:16:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572563812; cv=none; d=google.com; s=arc-20160816; b=sIJt898QSsM2dloRH2tpWWdZE+njNj96jJWYZnSYOQ33xA7f7iwN9pSIhHgC9pABNA KqC/7dWUwEPWt6I1IDWxqWg8IzSX2veglCsRhwUQkWJhlnYKv5cVCu16rHxTJ1C2gQU+ +A1/uHaKE7fCKhQzLLpCzgngV1gikdBV3Cpo5F2v2+MB4whEJYIQDWvQbHbNCN0gmxJT q3SFvdEK8AqMBZGz6jY1MkCYXAZ/4FyJKNYEREvgAAaq8tLyTCW8wWIDPTTpfWzqeOqs cXSpdWABYXQ1PWOgWAa2z0/iCR4G5YtMYLYfunm4RdrDjyr76M71wqfbnAAFzU+XmpUW +l7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=EwYPYULTeO/0uNpMARXXa2UdlMr9jw2KBzS6WN4/c2U=; b=fk3n/6LRLd4B8P82DWINa2eGPZserA47qv2fW2DaaMKtv8ZwWtl8RGQhe/xFmO6526 CunfVoGi+QpjLvPY3tfhcgmFQ0enZhY4fYzPh4NHpGYlr4TBdqxwWQ2aBuTy5B/+W4V4 RqTRKRyRvEqa7BbtCYJpDLi9Vgimdb3xqG0RDBs6EydeIN6bJ6ftn7dH7A8eKMh9/UxF 9hPqFP1RDHflzN2dmLDEEiBJGVhLp6c9oiTKgRq9pO6GMczMMHaAwGJ+2ca2EVP2aXVD D1OZqxrmgfss+CN/OxdGR8y6YWeOHwvAn/wtOfKvRrKYspKzrObSQNC+4jkptttRFA34 thmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rxRrcLte; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r14si4627058eju.413.2019.10.31.16.16.28; Thu, 31 Oct 2019 16:16:52 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rxRrcLte; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729527AbfJaWnb (ORCPT + 99 others); Thu, 31 Oct 2019 18:43:31 -0400 Received: from mail-yb1-f194.google.com ([209.85.219.194]:42391 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728182AbfJaWnb (ORCPT ); Thu, 31 Oct 2019 18:43:31 -0400 Received: by mail-yb1-f194.google.com with SMTP id 4so3103968ybq.9 for ; Thu, 31 Oct 2019 15:43:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=EwYPYULTeO/0uNpMARXXa2UdlMr9jw2KBzS6WN4/c2U=; b=rxRrcLteyOLYpNV+SLZdaLTViFe8qQqT2w3QwmdUq++Pq20SK8Xh0glbGQkcEXX+9z ARnQXshOAlhOBNWMKmpwpt0KvXQGUeAjvsvG/AH5WL+neSLCwWdVhelDt74pOq86ytKs HfeZEfx2GzkGcSpvs6Jcem0mJE5CYSn83ouLSKBgV2RpZuaDSUNAAg4btSX8MPaRXM6d FtD/i/JXviuMbg2RhJdPrqOx3W/XKuYBvGvAMnsRJ57L12nl2dijb0BNgpTdN434XY9g YYJW80rgjavRV3x4/teqtIltmtlslyzzmxp5AdvPheGdZ+ZKAGpgLM9QjQmcMhDQOjXD Assw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EwYPYULTeO/0uNpMARXXa2UdlMr9jw2KBzS6WN4/c2U=; b=DMQaM1MKgzfg92q1BPx4olwJOrIgeaoXs4DkJijY7ZPmaTLEFSNZRUHXYcs6G3g+6V 17xKuyJEUQ0/STc6BkNx9bHFJsDEWsAdeXHU2FzoxG1xpUMFh4bEDYfgwiGAMY2SE/Cr bpCkPSKbVeBr/r/z+0gv/BAWoO61OidtOgie3JsiHsPN05L3s63FxAu+P2DFQpND9xUt ZLt6F0D/8TJ4vR1FPSTHClcF0Q2dPEctKUUm74UTpRnx/Kf2k/0Up1q1llQpuabyBeA6 9Fd8IdYjw7ZuXqCSmsppk31YuQUyAZYAe69ebgksRnuKOTblZhzK6F5lQr4Kz9f7Wk5x tJfA== X-Gm-Message-State: APjAAAWulgfwJHgfgVDXt8gp+qyvTdpy+kOtlpBe4xFy0g0BGNuDDo20 08B3L0bWz0d6zFB1c8QH5npE8Aw= X-Received: by 2002:a25:c586:: with SMTP id v128mr6691614ybe.387.1572561809473; Thu, 31 Oct 2019 15:43:29 -0700 (PDT) Received: from localhost.localdomain ([50.105.87.1]) by smtp.gmail.com with ESMTPSA id d192sm1720287ywb.3.2019.10.31.15.43.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 15:43:28 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 19/20] NFSv4: Handle NFS4ERR_OLD_STATEID in delegreturn Date: Thu, 31 Oct 2019 18:40:50 -0400 Message-Id: <20191031224051.8923-20-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191031224051.8923-19-trond.myklebust@hammerspace.com> References: <20191031224051.8923-1-trond.myklebust@hammerspace.com> <20191031224051.8923-2-trond.myklebust@hammerspace.com> <20191031224051.8923-3-trond.myklebust@hammerspace.com> <20191031224051.8923-4-trond.myklebust@hammerspace.com> <20191031224051.8923-5-trond.myklebust@hammerspace.com> <20191031224051.8923-6-trond.myklebust@hammerspace.com> <20191031224051.8923-7-trond.myklebust@hammerspace.com> <20191031224051.8923-8-trond.myklebust@hammerspace.com> <20191031224051.8923-9-trond.myklebust@hammerspace.com> <20191031224051.8923-10-trond.myklebust@hammerspace.com> <20191031224051.8923-11-trond.myklebust@hammerspace.com> <20191031224051.8923-12-trond.myklebust@hammerspace.com> <20191031224051.8923-13-trond.myklebust@hammerspace.com> <20191031224051.8923-14-trond.myklebust@hammerspace.com> <20191031224051.8923-15-trond.myklebust@hammerspace.com> <20191031224051.8923-16-trond.myklebust@hammerspace.com> <20191031224051.8923-17-trond.myklebust@hammerspace.com> <20191031224051.8923-18-trond.myklebust@hammerspace.com> <20191031224051.8923-19-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If the server returns NFS4ERR_OLD_STATEID in response to our delegreturn, we want to sync to the most recent seqid for the delegation stateid. However if we are already at the most recent, we have two possibilities: - an OPEN reply is still outstanding and will return a new seqid - an earlier OPEN reply was dropped on the floor due to a timeout. In the latter case, we may end up unable to complete the delegreturn, so we want to bump the seqid to a value greater than the cached value. While this may cause us to lose the delegation in the former case, it should now be safe to assume that the client will replay the OPEN if necessary in order to get a new valid stateid. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 1 + fs/nfs/nfs4proc.c | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 48f3c6c9672f..fe57b2b5314a 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -1252,6 +1252,7 @@ bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode) delegation = rcu_dereference(NFS_I(inode)->delegation); if (delegation != NULL && nfs4_stateid_match_other(dst, &delegation->stateid) && + nfs4_stateid_is_newer(&delegation->stateid, dst) && !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { dst->seqid = delegation->stateid.seqid; ret = true; diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index c7e4a9ba8420..33a8e53e976c 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -6196,10 +6196,9 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) task->tk_status = 0; break; case -NFS4ERR_OLD_STATEID: - if (nfs4_refresh_delegation_stateid(&data->stateid, data->inode)) - goto out_restart; - task->tk_status = 0; - break; + if (!nfs4_refresh_delegation_stateid(&data->stateid, data->inode)) + nfs4_stateid_seqid_inc(&data->stateid); + goto out_restart; case -NFS4ERR_ACCESS: if (data->args.bitmask) { data->args.bitmask = NULL; -- 2.23.0