From: Jeff Layton <jlayton@kernel.org>
To: Benjamin Coddington <bcodding@redhat.com>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH] nfsd: allow setting SEQ4_STATUS_RECALLABLE_STATE_REVOKED
Date: Tue, 29 Aug 2023 16:13:49 -0400 [thread overview]
Message-ID: <543eaec0c99605c672e151a5181aa1ddcdb4d6b9.camel@kernel.org> (raw)
In-Reply-To: <cd03fb7419f886c8c79bb2ee4889dbc0768a1652.1693326366.git.bcodding@redhat.com>
On Tue, 2023-08-29 at 12:26 -0400, Benjamin Coddington wrote:
> This patch sets the SEQ4_STATUS_RECALLABLE_STATE_REVOKED bit for a single
> SEQUENCE response after writing "revoke" to the client's ctl file in procfs.
> It has been generally useful to test various NFS client implementations, so
> I'm sending it along for others to find and use.
>
> Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
> ---
> fs/nfsd/nfs4state.c | 19 +++++++++++++++----
> fs/nfsd/state.h | 1 +
> 2 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index daf305daa751..f91e2857df65 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -2830,18 +2830,28 @@ static ssize_t client_ctl_write(struct file *file, const char __user *buf,
> {
> char *data;
> struct nfs4_client *clp;
> + ssize_t rc = size;
>
> data = simple_transaction_get(file, buf, size);
> if (IS_ERR(data))
> return PTR_ERR(data);
> - if (size != 7 || 0 != memcmp(data, "expire\n", 7))
> +
> + if (size != 7)
> return -EINVAL;
> +
> clp = get_nfsdfs_clp(file_inode(file));
> if (!clp)
> return -ENXIO;
> - force_expire_client(clp);
> +
> + if (!memcmp(data, "revoke\n", 7))
> + set_bit(NFSD4_CLIENT_CL_REVOKED, &clp->cl_flags);
> + else if (!memcmp(data, "expire\n", 7))
> + force_expire_client(clp);
> + else
> + rc = -EINVAL;
> +
> drop_client(clp);
> - return 7;
> + return rc;
> }
>
> static const struct file_operations client_ctl_fops = {
> @@ -4042,7 +4052,8 @@ nfsd4_sequence(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> default:
> seq->status_flags = 0;
> }
> - if (!list_empty(&clp->cl_revoked))
> + if (!list_empty(&clp->cl_revoked) ||
> + test_and_clear_bit(NFSD4_CLIENT_CL_REVOKED, &clp->cl_flags))
> seq->status_flags |= SEQ4_STATUS_RECALLABLE_STATE_REVOKED;
> out_no_session:
> if (conn)
> diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
> index d49d3060ed4f..a9154b7da022 100644
> --- a/fs/nfsd/state.h
> +++ b/fs/nfsd/state.h
> @@ -369,6 +369,7 @@ struct nfs4_client {
> #define NFSD4_CLIENT_CB_FLAG_MASK (1 << NFSD4_CLIENT_CB_UPDATE | \
> 1 << NFSD4_CLIENT_CB_KILL)
> #define NFSD4_CLIENT_CB_RECALL_ANY (6)
> +#define NFSD4_CLIENT_CL_REVOKED (7)
> unsigned long cl_flags;
> const struct cred *cl_cb_cred;
> struct rpc_clnt *cl_cb_client;
Seems like a useful knob.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2023-08-29 20:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-29 16:26 [PATCH] nfsd: allow setting SEQ4_STATUS_RECALLABLE_STATE_REVOKED Benjamin Coddington
2023-08-29 20:13 ` Jeff Layton [this message]
2023-08-29 20:35 ` Chuck Lever
2023-08-29 21:05 ` Benjamin Coddington
2023-08-30 0:27 ` NeilBrown
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=543eaec0c99605c672e151a5181aa1ddcdb4d6b9.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=bcodding@redhat.com \
--cc=linux-nfs@vger.kernel.org \
/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