Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5291068ybe; Tue, 10 Sep 2019 01:10:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBtWz23wACr46YeBAmCAV7YavMt98uU1eypi4+cd7trDiTfbIXiSV+TM61QqrG5nWTs4Nr X-Received: by 2002:a17:906:b7c9:: with SMTP id fy9mr22644321ejb.237.1568102999952; Tue, 10 Sep 2019 01:09:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568102999; cv=none; d=google.com; s=arc-20160816; b=eEgssurmjh677YgONEwYaVbwGZP/yuOYngiLTgd6/kj1pC8EkDqdT10KFJi7YFOLdP acKWcoWAeuYNDgdxwMyS/gVVuOOpJ4xm9qH6zpIL2oxiJasUORq/6DLYNJ/ef0OeROd9 Pj6UvC+QlRaKOwflm6JwvwnhA7xLHXr22WAvfanCVTwjgTbcptIfV613uzCTzXF5Ita6 HhLlB8TZlxNZVYJOezodKfvW/BFtP22MJgLzF5RZ0pM1sZMoghiS8hk675Cf0qiLAr2D 6w4KavJMPUvrcvwNsv92NCi4bdnaSJx4q8NpxaqBslNSP2Em0V1a4WA5pkJdBOu2Q5Ov YXcw== 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:cc:to:from :dkim-signature; bh=wy1dUH5bibrhCk/Qm7oofyb/CYs8Ue5YUMfLEdziIqQ=; b=u64To/CQctuxPS7pKnJdLuHtzBGAw5ipAzh/0WGAs8NGUu4/1RJKteyUy+0ATh3ejV 8zQLgyY42tukDvmvbuGTAAKf04O3WmLL/8Gbj52CxZpKsiOmBo00vwWOC2IR+pGMfuZl G4qXoV0YoY3U1f9WdscgmGZ/EKbjFybgyrwpHwNvDYbbY+CGHW/6ofpgA+j1Wz47ix+D 0X9D3dTmNVesC230MVKBFckP5ccDWOWd95/Cq0JuQBWqDqWQiRiSQoaH1p97PzLxWxsr puMm2ocMSBjwXF/tayrXytkYaZiKhm26p/JvrBvNZTaFFS9EgBQuSAVj9RwdTTdMOEo+ xMgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pJ2vfWYq; 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 q35si10995805eda.122.2019.09.10.01.09.35; Tue, 10 Sep 2019 01:09:59 -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=pJ2vfWYq; 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 S2405130AbfIIODX (ORCPT + 99 others); Mon, 9 Sep 2019 10:03:23 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:41129 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405126AbfIIODW (ORCPT ); Mon, 9 Sep 2019 10:03:22 -0400 Received: by mail-io1-f68.google.com with SMTP id r26so28823330ioh.8 for ; Mon, 09 Sep 2019 07:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wy1dUH5bibrhCk/Qm7oofyb/CYs8Ue5YUMfLEdziIqQ=; b=pJ2vfWYq8G4Yq+jADOt3h+BBGFjoXuIvkjwtshXMLhF0xMlme7qnQKgtbsfpruJMGU oOltRKf/njzqBaR3kSVQczDfPMDBGBcp4+kKl/UcSOT73eHqOvWQphRDchDiP6ZnzftW q07o7T+jY4HNayVuw0/5iCZVJ22ynWUBFk2o7xu+nDgYPbBuSMcsuxgv4dCGo+4sva+9 vWWXCdGBHuMJja9UyZYh/16MUsBlUl8TMWhXo5TLG0ttIGt8FKMebcFXrpiGRLb1P5GY Bq/CNkOEAy4jn00jvrHoVarzCrpDbKqJnf44vVMn99kbEvTxumdkfnp3mDCUbT5Ei34H wGWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wy1dUH5bibrhCk/Qm7oofyb/CYs8Ue5YUMfLEdziIqQ=; b=G7Twr7hJuE3xz2g6bO2hY1XneFwpXpBuxkujOBuhZ7ekQbiKIXa07WZENHWz52QQ8j HIoK43XK95s3o8MNKuzjCSNPCa0kgGq7ST/oxBpoeAag8WGGVkOM5T5qiY2NKSkhVMFj 4yKqNaUfoxE4bvQEMNBA95KyswJUejiD04WiVP+heu8G0VYokClG0gokuH9NPNWmw/NY aPsUiB2/8o4VJH5ueYosEzJ2HEHyGtiqshKFvU5XT221HEI5fqBJ/ynE0nQ3lAt1NWZx EApGtqiLlHmFs8PLCAb+5fCrBVEajOZN/X5Qn3heFtrAu2Hw2wAtyVaZ7IkvSjzpSUGF Q1yA== X-Gm-Message-State: APjAAAW+CFz8WlP/XU3j8NYHtT04A4v+/celrJU2CbRFJtuQyb4FsWX5 fLW0FpgG7v2A/nvEGJY3s8aBxW/0Bg== X-Received: by 2002:a6b:7a07:: with SMTP id h7mr26669923iom.57.1568037801790; Mon, 09 Sep 2019 07:03:21 -0700 (PDT) Received: from localhost.localdomain (50-36-167-63.alma.mi.frontiernet.net. [50.36.167.63]) by smtp.gmail.com with ESMTPSA id h70sm33727176iof.48.2019.09.09.07.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 07:03:21 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 9/9] NFSv4: Handle NFS4ERR_OLD_STATEID in LOCKU Date: Mon, 9 Sep 2019 10:01:04 -0400 Message-Id: <20190909140104.78818-9-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190909140104.78818-8-trond.myklebust@hammerspace.com> References: <20190909140104.78818-1-trond.myklebust@hammerspace.com> <20190909140104.78818-2-trond.myklebust@hammerspace.com> <20190909140104.78818-3-trond.myklebust@hammerspace.com> <20190909140104.78818-4-trond.myklebust@hammerspace.com> <20190909140104.78818-5-trond.myklebust@hammerspace.com> <20190909140104.78818-6-trond.myklebust@hammerspace.com> <20190909140104.78818-7-trond.myklebust@hammerspace.com> <20190909140104.78818-8-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 a LOCKU request receives a NFS4ERR_OLD_STATEID, then bump the seqid before resending. Ensure we only bump the seqid by 1. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 49f301198008..ecfaf4b1ba5d 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -6377,6 +6377,42 @@ static int nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock * return err; } +/* + * Update the seqid of a lock stateid after receiving + * NFS4ERR_OLD_STATEID + */ +static bool nfs4_refresh_lock_old_stateid(nfs4_stateid *dst, + struct nfs4_lock_state *lsp) +{ + struct nfs4_state *state = lsp->ls_state; + bool ret = false; + + spin_lock(&state->state_lock); + if (!nfs4_stateid_match_other(dst, &lsp->ls_stateid)) + goto out; + if (!nfs4_stateid_is_newer(&lsp->ls_stateid, dst)) + nfs4_stateid_seqid_inc(dst); + else + dst->seqid = lsp->ls_stateid.seqid; + ret = true; +out: + spin_unlock(&state->state_lock); + return ret; +} + +static bool nfs4_sync_lock_stateid(nfs4_stateid *dst, + struct nfs4_lock_state *lsp) +{ + struct nfs4_state *state = lsp->ls_state; + bool ret; + + spin_lock(&state->state_lock); + ret = !nfs4_stateid_match_other(dst, &lsp->ls_stateid); + nfs4_stateid_copy(dst, &lsp->ls_stateid); + spin_unlock(&state->state_lock); + return ret; +} + struct nfs4_unlockdata { struct nfs_locku_args arg; struct nfs_locku_res res; @@ -6448,10 +6484,14 @@ static void nfs4_locku_done(struct rpc_task *task, void *data) task->tk_msg.rpc_cred); /* Fall through */ case -NFS4ERR_BAD_STATEID: - case -NFS4ERR_OLD_STATEID: case -NFS4ERR_STALE_STATEID: - if (!nfs4_stateid_match(&calldata->arg.stateid, - &calldata->lsp->ls_stateid)) + if (nfs4_sync_lock_stateid(&calldata->arg.stateid, + calldata->lsp)) + rpc_restart_call_prepare(task); + break; + case -NFS4ERR_OLD_STATEID: + if (nfs4_refresh_lock_old_stateid(&calldata->arg.stateid, + calldata->lsp)) rpc_restart_call_prepare(task); break; default: @@ -6474,7 +6514,6 @@ static void nfs4_locku_prepare(struct rpc_task *task, void *data) if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0) goto out_wait; - nfs4_stateid_copy(&calldata->arg.stateid, &calldata->lsp->ls_stateid); if (test_bit(NFS_LOCK_INITIALIZED, &calldata->lsp->ls_flags) == 0) { /* Note: exit _without_ running nfs4_locku_done */ goto out_no_action; -- 2.21.0