Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4574144ybe; Mon, 16 Sep 2019 14:44:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPWWa4OPwldgeCgr2zwPQqjFiBCqkuJdoL5egiMmd1udCJDv/ITgaKHLnst48b+qs1RS9y X-Received: by 2002:a05:6402:1adc:: with SMTP id ba28mr1519815edb.103.1568670273129; Mon, 16 Sep 2019 14:44:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568670273; cv=none; d=google.com; s=arc-20160816; b=LHGlWaV1f1HeMicOJmVwSIr2wSYDBgGUH9c4ejsMhF91cPbwIa/3so5Dar/Khb+juD GI9NR7XKVL0y7hAcc3tgnr3o7Fn03tWG1Ds8oeGnxv1RiQSTx1ydbUkTLmuPHrmZDcmp S0tStMIbcbaUVV6ph7XCGSRHKR8Ee65FEXgXhbAYPMwO0wWMAJ5+oSWuVPBXpZBUNSox OJu70YrIjBlpc426gfLOgdVF/Z2vBy3jzekhaOOiuMPVB5cPn9/E+vtWU13oMQulUy95 4en87o2qMu3yYI06JAcvop/17aFnccSCX3S/ykJ0K8MlXd79vVozC0KuCcjqf9W+Wk7m niFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=SQY5DuhZCx0TpkptBCZ+Ky14hADgXgeD6CGa6QU6kQc=; b=VPz2hULjRzE/DzmQJjxck/S1pv5G1CZG1AXXBc9akbOc6OP6FRW70SM5EV0MFGUGl7 elXZ++uXLWUEIvjnp+N9VZC6Qa266qhmZOPRep2ead4eJLzqdoqqNMuuF2ZqWy0IoVk4 bCldgiTp+2oQSE8VW97klXFnK5i291+QKlPEU8YBV62Z2QEL2TQmRrj46C3rVk+rGj6q 67vA5v1qMjQFnBlUU1d6ti6Sg362N7CkT0eM3/SlOjpNgjOXft7gkyAUvhlh6kU7cx8v f7hzAA47f/ELNjIoMJfTQHZ1vP/YksZ9iEQzSSqMQItqKFZUOfb0sQLQCk0+LoA87MAC XxLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umich.edu header.s=google-2016-06-03 header.b=SgcCBDsg; 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=NONE dis=NONE) header.from=umich.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z35si199820edd.340.2019.09.16.14.44.08; Mon, 16 Sep 2019 14:44:33 -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=@umich.edu header.s=google-2016-06-03 header.b=SgcCBDsg; 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=NONE dis=NONE) header.from=umich.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728221AbfIPTh7 (ORCPT + 99 others); Mon, 16 Sep 2019 15:37:59 -0400 Received: from mail-vk1-f194.google.com ([209.85.221.194]:37106 "EHLO mail-vk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbfIPTh7 (ORCPT ); Mon, 16 Sep 2019 15:37:59 -0400 Received: by mail-vk1-f194.google.com with SMTP id v78so207117vke.4 for ; Mon, 16 Sep 2019 12:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umich.edu; s=google-2016-06-03; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SQY5DuhZCx0TpkptBCZ+Ky14hADgXgeD6CGa6QU6kQc=; b=SgcCBDsgMmKgnJuTuBTtCZyu2qF75NSqBuh+plkwNS0QPi/Q4ut1m3e4n1DxBHwZCn LKfNT225DxXTSxkQ7jTGA1HQ2MVKxp2O1YBVslPjKU2GB3/rmFF0rhi0zzviHI9ZovOZ qTodwW7FLax2pdvCxsgd+8JpdmpR/VlT+zlTSWXty1Jw7LTZ4yltIIrTd6O31QhJYnIV hmzikyBIY+FJVAPMSOIGNv39RlS96HLEQapTTGl35rKoBhHCRn5K6i6U4OwU0A9xdrQK DTwEQ23g6rgirplZpFnzcElcRniRkiCcD6gMmCPjtpHtvdkLwO7sYmBdoDLyW7i7C4YF mMTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SQY5DuhZCx0TpkptBCZ+Ky14hADgXgeD6CGa6QU6kQc=; b=scCOIq+YaZh7Y+R5bePEEoHl9C4issEQSQzmT9mAC7ltygAYbh86Lh1MJlRzsC/5R5 7C7kplpNgqU1sK+smjDhucEO9cdjNv91FTTVhg3RiZSafcjRrOl3iOl2Nj6gyv54hbsm q+u6DA/qygqzZoz0SV7BvqcYO1kKzcyYELNOEwbdHeaf6ajrZvz6jcBOWw9YWpJ6vH7i XB9pKCG1EmwGwF3mB0j4MuTTbDMVZBNcZAW4PNi55YAh6SOxq8r1XUho4tra+hlllr5f qaVjyLECTv/J4Nkl+y4UzJwaMkEJEsLfDOV1cMnynQ6b4WtuZkwmQD4nBz+PN1KUmh7G +Zgg== X-Gm-Message-State: APjAAAU7UX+puF+R1vIFgh06uDo8iu+Nj/pdnU38yrimvz4MFvqtBOsH WheKk+5qiBMUIQ94t1+9EvhmlvE1ARzz5c/q4HQ= X-Received: by 2002:a1f:a4b:: with SMTP id 72mr7963vkk.83.1568662678489; Mon, 16 Sep 2019 12:37:58 -0700 (PDT) MIME-Version: 1.0 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> <20190909140104.78818-9-trond.myklebust@hammerspace.com> In-Reply-To: <20190909140104.78818-9-trond.myklebust@hammerspace.com> From: Olga Kornievskaia Date: Mon, 16 Sep 2019 15:37:47 -0400 Message-ID: Subject: Re: [PATCH 9/9] NFSv4: Handle NFS4ERR_OLD_STATEID in LOCKU To: Trond Myklebust Cc: Anna Schumaker , linux-nfs Content-Type: text/plain; charset="UTF-8" Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Hi Trond, I have a problem with this patch. It sends an unlock with stateid of all zeros (gets a BAD_STATEID) and then sends an unlock with a normal stateid. This can be seen running nfstest_locking --nfsversion 4.1. On Tue, Sep 10, 2019 at 4:09 AM Trond Myklebust wrote: > > 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 >