From: Olga Kornievskaia <aglo@umich.edu>
To: Trond Myklebust <trondmy@gmail.com>
Cc: Anna Schumaker <Anna.Schumaker@netapp.com>,
linux-nfs <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH 8/9] NFSv4: Handle NFS4ERR_OLD_STATEID in CLOSE/OPEN_DOWNGRADE
Date: Wed, 11 Sep 2019 16:13:54 -0400 [thread overview]
Message-ID: <CAN-5tyFLWbWR4_2bw_6WKiT71=WPCRZF=gk-vAQ+-tHDtFwrPg@mail.gmail.com> (raw)
In-Reply-To: <20190909140104.78818-8-trond.myklebust@hammerspace.com>
Hi Trond,
This patch is causing me "problem" (can be seen using generic/323).
This test creates 100 processes that each want to open the same file,
then close it. Each open gets a stateid with an increasing seqid (the
last received by the client is stateid seqid=100). With the patch,
upon close I see 1st CLOSE use stateid seqid=1 which ends up failing
with ERR_OLD_STATEID and retried until stateid seqid=100 (which was
the current id). Reverting the patch give back sending the CLOSE with
seqid=100. While nothing failing, I don't think the client's behavior
is correct.
On Tue, Sep 10, 2019 at 4:10 AM Trond Myklebust <trondmy@gmail.com> wrote:
>
> If a CLOSE or OPEN_DOWNGRADE operation receives a NFS4ERR_OLD_STATEID
> then bump the seqid before resending. Ensure we only bump the seqid
> by 1.
>
> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> ---
> fs/nfs/nfs4_fs.h | 2 --
> fs/nfs/nfs4proc.c | 41 ++++++++++++++++++++++++++++++++++++++---
> fs/nfs/nfs4state.c | 16 ----------------
> 3 files changed, 38 insertions(+), 21 deletions(-)
>
> diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
> index e8f74ed98e42..16b2e5cc3e94 100644
> --- a/fs/nfs/nfs4_fs.h
> +++ b/fs/nfs/nfs4_fs.h
> @@ -491,8 +491,6 @@ extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl);
> extern int nfs4_select_rw_stateid(struct nfs4_state *, fmode_t,
> const struct nfs_lock_context *, nfs4_stateid *,
> const struct cred **);
> -extern bool nfs4_refresh_open_stateid(nfs4_stateid *dst,
> - struct nfs4_state *state);
> extern bool nfs4_copy_open_stateid(nfs4_stateid *dst,
> struct nfs4_state *state);
>
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index 025dd5efbf34..49f301198008 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -3308,6 +3308,42 @@ nfs4_wait_on_layoutreturn(struct inode *inode, struct rpc_task *task)
> return pnfs_wait_on_layoutreturn(inode, task);
> }
>
> +/*
> + * Update the seqid of an open stateid after receiving
> + * NFS4ERR_OLD_STATEID
> + */
> +static bool nfs4_refresh_open_old_stateid(nfs4_stateid *dst,
> + struct nfs4_state *state)
> +{
> + __be32 seqid_open;
> + u32 dst_seqid;
> + bool ret;
> + int seq;
> +
> + for (;;) {
> + ret = false;
> + seq = read_seqbegin(&state->seqlock);
> + if (!nfs4_state_match_open_stateid_other(state, dst)) {
> + if (read_seqretry(&state->seqlock, seq))
> + continue;
> + break;
> + }
> + seqid_open = state->open_stateid.seqid;
> + dst_seqid = be32_to_cpu(dst->seqid);
> +
> + if (read_seqretry(&state->seqlock, seq))
> + continue;
> + if ((s32)(dst_seqid - be32_to_cpu(seqid_open)) >= 0)
> + dst->seqid = cpu_to_be32(dst_seqid + 1);
> + else
> + dst->seqid = seqid_open;
> + ret = true;
> + break;
> + }
> +
> + return ret;
> +}
> +
> struct nfs4_closedata {
> struct inode *inode;
> struct nfs4_state *state;
> @@ -3382,7 +3418,7 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
> break;
> case -NFS4ERR_OLD_STATEID:
> /* Did we race with OPEN? */
> - if (nfs4_refresh_open_stateid(&calldata->arg.stateid,
> + if (nfs4_refresh_open_old_stateid(&calldata->arg.stateid,
> state))
> goto out_restart;
> goto out_release;
> @@ -3451,8 +3487,7 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
> } else if (is_rdwr)
> calldata->arg.fmode |= FMODE_READ|FMODE_WRITE;
>
> - if (!nfs4_valid_open_stateid(state) ||
> - !nfs4_refresh_open_stateid(&calldata->arg.stateid, state))
> + if (!nfs4_valid_open_stateid(state))
> call_close = 0;
> spin_unlock(&state->owner->so_lock);
>
> diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
> index cad4e064b328..e23945174da4 100644
> --- a/fs/nfs/nfs4state.c
> +++ b/fs/nfs/nfs4state.c
> @@ -1015,22 +1015,6 @@ static int nfs4_copy_lock_stateid(nfs4_stateid *dst,
> return ret;
> }
>
> -bool nfs4_refresh_open_stateid(nfs4_stateid *dst, struct nfs4_state *state)
> -{
> - bool ret;
> - int seq;
> -
> - do {
> - ret = false;
> - seq = read_seqbegin(&state->seqlock);
> - if (nfs4_state_match_open_stateid_other(state, dst)) {
> - dst->seqid = state->open_stateid.seqid;
> - ret = true;
> - }
> - } while (read_seqretry(&state->seqlock, seq));
> - return ret;
> -}
> -
> bool nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state)
> {
> bool ret;
> --
> 2.21.0
>
next prev parent reply other threads:[~2019-09-11 20:14 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-09 14:00 [PATCH 1/9] pNFS: Ensure we do clear the return-on-close layout stateid on fatal errors Trond Myklebust
2019-09-09 14:00 ` [PATCH 2/9] NFSv4: Clean up pNFS return-on-close error handling Trond Myklebust
2019-09-09 14:00 ` [PATCH 3/9] NFSv4: Handle NFS4ERR_DELAY correctly in return-on-close Trond Myklebust
2019-09-09 14:00 ` [PATCH 4/9] NFSv4: Handle RPC level errors in LAYOUTRETURN Trond Myklebust
2019-09-09 14:01 ` [PATCH 5/9] NFSv4: Add a helper to increment stateid seqids Trond Myklebust
2019-09-09 14:01 ` [PATCH 6/9] pNFS: Handle NFS4ERR_OLD_STATEID on layoutreturn by bumping the state seqid Trond Myklebust
2019-09-09 14:01 ` [PATCH 7/9] NFSv4: Fix OPEN_DOWNGRADE error handling Trond Myklebust
2019-09-09 14:01 ` [PATCH 8/9] NFSv4: Handle NFS4ERR_OLD_STATEID in CLOSE/OPEN_DOWNGRADE Trond Myklebust
2019-09-09 14:01 ` [PATCH 9/9] NFSv4: Handle NFS4ERR_OLD_STATEID in LOCKU Trond Myklebust
2019-09-16 19:37 ` Olga Kornievskaia
2019-09-11 20:13 ` Olga Kornievskaia [this message]
2019-09-11 20:56 ` [PATCH 8/9] NFSv4: Handle NFS4ERR_OLD_STATEID in CLOSE/OPEN_DOWNGRADE Trond Myklebust
2019-09-12 15:01 ` Olga Kornievskaia
2019-09-12 15:04 ` Olga Kornievskaia
2019-09-16 19:39 ` Olga Kornievskaia
2019-09-12 15:14 ` [PATCH 6/9] pNFS: Handle NFS4ERR_OLD_STATEID on layoutreturn by bumping the state seqid Olga Kornievskaia
2019-09-12 16:29 ` Trond Myklebust
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAN-5tyFLWbWR4_2bw_6WKiT71=WPCRZF=gk-vAQ+-tHDtFwrPg@mail.gmail.com' \
--to=aglo@umich.edu \
--cc=Anna.Schumaker@netapp.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trondmy@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).