linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Mi Jinlong <mijinlong@cn.fujitsu.com>
Cc: NFS <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH v2] nfs41: implement DESTROY_CLIENTID operation
Date: Thu, 20 Oct 2011 08:33:32 -0400	[thread overview]
Message-ID: <20111020123332.GO5444@fieldses.org> (raw)
In-Reply-To: <4E9FEF2B.5080709@cn.fujitsu.com>

On Thu, Oct 20, 2011 at 05:51:39PM +0800, Mi Jinlong wrote:
> According to rfc5661 18.50, implement DESTROY_CLIENTID operation.

This looks good, thanks, queueing up for 3.2.--b.

> 
> Signed-off-by: Mi Jinlong <mijinlong@cn.fujitsu.com>
> 
> ---
>  fs/nfsd/nfs4proc.c  |    2 +-
>  fs/nfsd/nfs4state.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
>  fs/nfsd/nfs4xdr.c   |   12 +++++++++++-
>  fs/nfsd/xdr4.h      |    5 +++++
>  4 files changed, 61 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index e807776..8412a22 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -1433,7 +1433,7 @@ static struct nfsd4_operation nfsd4_ops[] = {
>  		.op_name = "OP_SEQUENCE",
>  	},
>  	[OP_DESTROY_CLIENTID] = {
> -		.op_func = NULL,
> +		.op_func = (nfsd4op_func)nfsd4_destroy_clientid,
>  		.op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP,
>  		.op_name = "OP_DESTROY_CLIENTID",
>  	},
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 3787ec1..d94ad19 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -1858,6 +1858,50 @@ out:
>  	return status;
>  }
>  
> +static inline bool has_resources(struct nfs4_client *clp)
> +{
> +	return !list_empty(&clp->cl_openowners)
> +		|| !list_empty(&clp->cl_delegations)
> +		|| !list_empty(&clp->cl_sessions);
> +}
> +
> +__be32
> +nfsd4_destroy_clientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_destroy_clientid *dc)
> +{
> +	struct nfs4_client *conf, *unconf, *clp;
> +	int status = 0;
> +
> +	nfs4_lock_state();
> +	unconf = find_unconfirmed_client(&dc->clientid);
> +	conf = find_confirmed_client(&dc->clientid);
> +
> +	if (conf) {
> +		clp = conf;
> +
> +		if (!is_client_expired(conf) && has_resources(conf)) {
> +			status = nfserr_clientid_busy;
> +			goto out;
> +		}
> +
> +		/* rfc5661 18.50.3 */
> +		if (cstate->session && conf == cstate->session->se_client) {
> +			status = nfserr_clientid_busy;
> +			goto out;
> +		}
> +	} else if (unconf)
> +		clp = unconf;
> +	else {
> +		status = nfserr_stale_clientid;
> +		goto out;
> +	}
> +
> +	expire_client(clp);
> +out:
> +	nfs4_unlock_state();
> +	dprintk("%s return %d\n", __func__, ntohl(status));
> +	return status;
> +}
> +
>  __be32
>  nfsd4_reclaim_complete(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_reclaim_complete *rc)
>  {
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index c8bf405..5d9fff5 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -1326,6 +1326,16 @@ xdr_error:
>  	goto out;
>  }
>  
> +static __be32 nfsd4_decode_destroy_clientid(struct nfsd4_compoundargs *argp, struct nfsd4_destroy_clientid *dc)
> +{
> +	DECODE_HEAD;
> +
> +	READ_BUF(8);
> +	COPYMEM(&dc->clientid, 8);
> +
> +	DECODE_TAIL;
> +}
> +
>  static __be32 nfsd4_decode_reclaim_complete(struct nfsd4_compoundargs *argp, struct nfsd4_reclaim_complete *rc)
>  {
>  	DECODE_HEAD;
> @@ -1447,7 +1457,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
>  	[OP_SET_SSV]		= (nfsd4_dec)nfsd4_decode_notsupp,
>  	[OP_TEST_STATEID]	= (nfsd4_dec)nfsd4_decode_test_stateid,
>  	[OP_WANT_DELEGATION]	= (nfsd4_dec)nfsd4_decode_notsupp,
> -	[OP_DESTROY_CLIENTID]	= (nfsd4_dec)nfsd4_decode_notsupp,
> +	[OP_DESTROY_CLIENTID]	= (nfsd4_dec)nfsd4_decode_destroy_clientid,
>  	[OP_RECLAIM_COMPLETE]	= (nfsd4_dec)nfsd4_decode_reclaim_complete,
>  };
>  
> diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h
> index d2a8d044..d67d680 100644
> --- a/fs/nfsd/xdr4.h
> +++ b/fs/nfsd/xdr4.h
> @@ -405,6 +405,10 @@ struct nfsd4_destroy_session {
>  	struct nfs4_sessionid	sessionid;
>  };
>  
> +struct nfsd4_destroy_clientid {
> +	clientid_t clientid;
> +};
> +
>  struct nfsd4_reclaim_complete {
>  	u32 rca_one_fs;
>  };
> @@ -558,6 +562,7 @@ extern __be32 nfsd4_sequence(struct svc_rqst *,
>  extern __be32 nfsd4_destroy_session(struct svc_rqst *,
>  		struct nfsd4_compound_state *,
>  		struct nfsd4_destroy_session *);
> +extern __be32 nfsd4_destroy_clientid(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_destroy_clientid *);
>  __be32 nfsd4_reclaim_complete(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_reclaim_complete *);
>  extern __be32 nfsd4_process_open1(struct nfsd4_compound_state *,
>  		struct nfsd4_open *open);
> -- 
> 1.7.6
> 
> 

      reply	other threads:[~2011-10-20 12:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-20  8:51 [PATCH] nfs41: implement DESTROY_CLIENTID operation Mi Jinlong
2011-10-20  9:34 ` J. Bruce Fields
2011-10-20  9:45   ` Mi Jinlong
2011-10-20  9:51     ` [PATCH v2] " Mi Jinlong
2011-10-20 12:33       ` J. Bruce Fields [this message]

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=20111020123332.GO5444@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=mijinlong@cn.fujitsu.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).