Linux NFS development
 help / color / mirror / Atom feed
From: Yang Hongyang <yanghy@cn.fujitsu.com>
To: "J. Bruce Fields" <bfields@fieldses.org>
Cc: linux-nfs@vger.kernel.org, "J. Bruce Fields" <bfields@citi.umich.edu>
Subject: Re: [PATCH 07/14] nfsd4: separate delegreturn case from preprocess_stateid_op
Date: Wed, 11 Mar 2009 09:47:26 +0800	[thread overview]
Message-ID: <49B7182E.6080103@cn.fujitsu.com> (raw)
In-Reply-To: <1236731222-3294-8-git-send-email-bfields@fieldses.org>

J. Bruce Fields wrote:
> From: J. Bruce Fields <bfields@citi.umich.edu>
> 
> Delegreturn is enough a special case for preprocess_stateid_op to
> warrant just open-coding it in delegreturn.
> 
> There should be no change in behavior here; we're just reshuffling code.
> 
> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
> ---
>  fs/nfsd/nfs4state.c        |   40 ++++++++++++++++++++++++++++------------
>  include/linux/nfsd/state.h |    1 -
>  2 files changed, 28 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index d555585..de1d68a 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -2000,10 +2000,7 @@ out:
>  static inline __be32
>  check_special_stateids(svc_fh *current_fh, stateid_t *stateid, int flags)
>  {
> -	/* Trying to call delegreturn with a special stateid? Yuch: */
> -	if (!(flags & (RD_STATE | WR_STATE)))
> -		return nfserr_bad_stateid;
> -	else if (ONE_STATEID(stateid) && (flags & RD_STATE))
> +	if (ONE_STATEID(stateid) && (flags & RD_STATE))
>  		return nfs_ok;
>  	else if (locks_in_grace()) {
>  		/* Answer in remaining cases depends on existance of
> @@ -2024,8 +2021,7 @@ check_special_stateids(svc_fh *current_fh, stateid_t *stateid, int flags)
>  static inline int
>  io_during_grace_disallowed(struct inode *inode, int flags)
>  {
> -	return locks_in_grace() && (flags & (RD_STATE | WR_STATE))
> -		&& mandatory_lock(inode);
> +	return locks_in_grace() && mandatory_lock(inode);
>  }
>  
>  static int check_stateid_generation(stateid_t *in, stateid_t *ref)
> @@ -2089,8 +2085,6 @@ nfs4_preprocess_stateid_op(struct svc_fh *current_fh, stateid_t *stateid, int fl
>  		if (status)
>  			goto out;
>  		renew_client(dp->dl_client);
> -		if (flags & DELEG_RET)
> -			unhash_delegation(dp);
>  		if (filpp)
>  			*filpp = dp->dl_vfs_file;
>  	} else { /* open or lock stateid */
> @@ -2408,16 +2402,38 @@ __be32
>  nfsd4_delegreturn(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
>  		  struct nfsd4_delegreturn *dr)
>  {
> +	struct nfs4_delegation *dp;
> +	stateid_t *stateid = &dr->dr_stateid;
> +	struct inode *inode;
>  	__be32 status;
>  
>  	if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0)))

adjust style:
          status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0)
          if (status)

> -		goto out;
> +		return status;
> +	inode = cstate->current_fh.fh_dentry->d_inode;
>  
>  	nfs4_lock_state();
> -	status = nfs4_preprocess_stateid_op(&cstate->current_fh,
> -					    &dr->dr_stateid, DELEG_RET, NULL);
> -	nfs4_unlock_state();
> +	status = nfserr_bad_stateid;
> +	if (ZERO_STATEID(stateid) || ONE_STATEID(stateid))
> +		goto out;
> +	status = nfserr_stale_stateid;
> +	if (STALE_STATEID(stateid)) 
> +		goto out;
> +	status = nfs_ok;
> +	if (is_delegation_stateid(stateid))
> +		goto out;
> +	status = nfserr_bad_stateid;
> +	dp = find_delegation_stateid(inode, stateid);
> +	if (!dp)
> +		goto out;
> +	status = check_stateid_generation(stateid, &dp->dl_stateid);
> +	if (status)
> +		goto out;
> +	renew_client(dp->dl_client);
> +
> +	unhash_delegation(dp);
>  out:
> +	nfs4_unlock_state();
> +
>  	return status;
>  }
>  
> diff --git a/include/linux/nfsd/state.h b/include/linux/nfsd/state.h
> index 1130d53..c9311a1 100644
> --- a/include/linux/nfsd/state.h
> +++ b/include/linux/nfsd/state.h
> @@ -263,7 +263,6 @@ struct nfs4_stateid {
>  #define RD_STATE	        0x00000010
>  #define WR_STATE	        0x00000020
>  #define CLOSE_STATE             0x00000040
> -#define DELEG_RET               0x00000080
>  
>  #define seqid_mutating_err(err)                       \
>  	(((err) != nfserr_stale_clientid) &&    \


-- 
Regards
Yang Hongyang

  parent reply	other threads:[~2009-03-11  1:48 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-11  0:26 miscellaneous nfsd4 state changes J. Bruce Fields
2009-03-11  0:26 ` [PATCH 01/14] nfsd4: trivial preprocess_stateid_op cleanup J. Bruce Fields
2009-03-11  0:26   ` [PATCH 02/14] nfsd4: move check_stateid_generation check J. Bruce Fields
2009-03-11  0:26     ` [PATCH 03/14] nfsd4: remove redundant "if" in nfs4_preprocess_stateid_op J. Bruce Fields
2009-03-11  0:26       ` [PATCH 04/14] nfsd4: remove unneeded local variable J. Bruce Fields
2009-03-11  0:26         ` [PATCH 05/14] nfsd4: remove some dprintk's J. Bruce Fields
2009-03-11  0:26           ` [PATCH 06/14] nfsd4: add a helper function to decide if stateid is delegation J. Bruce Fields
2009-03-11  0:26             ` [PATCH 07/14] nfsd4: separate delegreturn case from preprocess_stateid_op J. Bruce Fields
2009-03-11  0:26               ` [PATCH 08/14] nfsd4: fail when delegreturn gets a non-delegation stateid J. Bruce Fields
2009-03-11  0:26                 ` [PATCH 09/14] nfsd4: remove unused CHECK_FH flag J. Bruce Fields
2009-03-11  0:26                   ` [PATCH 10/14] nfsd4: rename io_during_grace_disallowed J. Bruce Fields
2009-03-11  0:26                     ` [PATCH 11/14] nfsd4: put_nfs4_client does not require state lock J. Bruce Fields
2009-03-11  0:27                       ` [PATCH 12/14] nfsd4: remove use of mutex for file_hashtable J. Bruce Fields
2009-03-11  0:27                         ` [PATCH 13/14] nfsd4: fix do_probe_callback errors J. Bruce Fields
2009-03-11  0:27                           ` [PATCH 14/14] nfsd4: move rpc_client setup to a separate function J. Bruce Fields
2009-03-12 10:59                             ` Benny Halevy
2009-03-12 10:55                           ` [PATCH 13/14] nfsd4: fix do_probe_callback errors Benny Halevy
2009-03-12 21:41                             ` J. Bruce Fields
2009-03-11 18:52                         ` [PATCH 12/14] nfsd4: remove use of mutex for file_hashtable Benny Halevy
2009-03-12  0:05                           ` J. Bruce Fields
2009-03-12 10:49                             ` Benny Halevy
2009-03-13 17:18                               ` J. Bruce Fields
2009-03-18 20:28                                 ` J. Bruce Fields
2009-03-18 20:40                                   ` Benny Halevy
2009-03-18 21:03                                     ` J. Bruce Fields
2009-03-18 21:07                                       ` Benny Halevy
2009-03-11  1:52                 ` [PATCH 08/14] nfsd4: fail when delegreturn gets a non-delegation stateid Yang Hongyang
2009-03-11 20:07                   ` J. Bruce Fields
2009-03-11 18:29                 ` Benny Halevy
2009-03-12  0:03                   ` J. Bruce Fields
2009-03-11  1:47               ` Yang Hongyang [this message]
2009-03-11 19:51                 ` [PATCH 07/14] nfsd4: separate delegreturn case from preprocess_stateid_op J. Bruce Fields
2009-03-11  1:12       ` [PATCH 03/14] nfsd4: remove redundant "if" in nfs4_preprocess_stateid_op Yang Hongyang
2009-03-11  1:23         ` J. Bruce Fields
2009-03-11  1:26           ` Yang Hongyang
2009-03-11 18:05             ` Benny Halevy
2009-03-11 19:49               ` J. Bruce Fields
2009-03-11  2:09   ` [PATCH 01/14] nfsd4: trivial preprocess_stateid_op cleanup Yang Hongyang

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=49B7182E.6080103@cn.fujitsu.com \
    --to=yanghy@cn.fujitsu.com \
    --cc=bfields@citi.umich.edu \
    --cc=bfields@fieldses.org \
    --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