linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Trond Myklebust <Trond.Myklebust@netapp.com>
To: Bian Naimeng <biannm@cn.fujitsu.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH 2/2] We should clear NFS_DELEGATED_STATE after return delegation
Date: Fri, 06 Aug 2010 09:30:47 -0400	[thread overview]
Message-ID: <1281101448.3586.11.camel@heimdal.trondhjem.org> (raw)
In-Reply-To: <4C5B8B48.4050008@cn.fujitsu.com>

On Fri, 2010-08-06 at 12:10 +0800, Bian Naimeng wrote:
> 
> Trond Myklebust 写道:
> > On Thu, 2010-08-05 at 10:26 +0800, Bian Naimeng wrote:
> >>> On Wed, 2010-08-04 at 17:18 +0800, Bian Naimeng wrote:
> >>>> We should clear NFS_DELEGATED_STATE bit for inode->open_states after return delegation.
> >>>>
> 
>     ... snip ...
> 
> >>  Thanks Trond.
> >>  But why we must remove test_and_clear_bit behind memcmp?
> >>
> >>  Always test_bit and memcmp have same result, and I think test_and_clear_bit is fast 
> >>  than memcmp, so i suggest we should call test_and_clear_bit first. right?
> > 
> > We can't clear the bit before the memcmp() test. What we could do is
> > keep the current test_bit() and then do a clear_bit after the memcmp().
> > 
> 
>   When i apply the patch, my test still fail. 
> 
>    The ctx->state will set set after open success, but this ctx add to the
>   the nfsi->open_files when we call nfs_open that is so early. So maybe
>   there are some states can be found at nfsi->open_states, but not at
>   ctx->state of nfsi->open_files, so we will miss clear NFS_DELEGATED_STATE
>   for these state.
> 
> Regards
>  Bian Naimeng
> 
> --------------------------------------------------
> 
> NFSv4: Remember to clear NFS_DELEGATED_STATE in nfs_delegation_claim_opens
> 
> Signed-off-by: Bian Naimeng <biannm@cn.fujitsu.com>
> 
> ---
>  fs/nfs/delegation.c |   15 +++++++++++----
>  1 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
> index 3016345..94a63e3 100644
> --- a/fs/nfs/delegation.c
> +++ b/fs/nfs/delegation.c
> @@ -94,7 +94,7 @@ static int nfs_delegation_claim_opens(struct inode *inode, const nfs4_stateid *s
>  	struct nfs_inode *nfsi = NFS_I(inode);
>  	struct nfs_open_context *ctx;
>  	struct nfs4_state *state;
> -	int err;
> +	int err = 0;
>  
>  again:
>  	spin_lock(&inode->i_lock);
> @@ -112,12 +112,19 @@ again:
>  		if (err >= 0)
>  			err = nfs_delegation_claim_locks(ctx, state);
>  		put_nfs_open_context(ctx);
> -		if (err != 0)
> -			return err;
> +		if (err != 0) {
> +			spin_lock(&inode->i_lock);
> +			break;
> +		}
>  		goto again;
>  	}
> +
> +	list_for_each_entry(state, &nfsi->open_states, inode_states) {
> +		clear_bit(NFS_DELEGATED_STATE, &state->flags);
> +	}
> +
>  	spin_unlock(&inode->i_lock);
> -	return 0;
> +	return err;
>  }
>  

I still don't see why this should be necessary. In the case of a server
reboot or network partition, the state recovery thread ought to be
taking care of this for us.

Cheers
  Trond

  reply	other threads:[~2010-08-06 13:31 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-04  9:14 [PATCH 0/2] Fix bug that client use a invaild delegation Bian Naimeng
2010-08-04  9:15 ` [PATCH 1/2] Make lock inode before lock nfs4_state_owner Bian Naimeng
2010-08-04  9:18 ` [PATCH 2/2] We should clear NFS_DELEGATED_STATE after return delegation Bian Naimeng
2010-08-04 12:45   ` Trond Myklebust
2010-08-05  2:26     ` Bian Naimeng
2010-08-05 13:03       ` Trond Myklebust
2010-08-06  4:10         ` Bian Naimeng
2010-08-06 13:30           ` Trond Myklebust [this message]
2010-08-16  7:50             ` Bian Naimeng
2010-08-17 23:16               ` Trond Myklebust
2010-08-18  3:17                 ` Bian Naimeng
2010-08-23  7:43                   ` Bian Naimeng
2010-09-01  6:40                 ` Bian Naimeng
2010-09-07 22:04                   ` Trond Myklebust
2010-09-08  1:33                     ` Bian Naimeng
2010-09-08  1:57                       ` Trond Myklebust
2010-09-08  2:37                         ` Bian Naimeng
2010-09-08  3:11                         ` Bian Naimeng
2010-09-08 20:37                           ` Trond Myklebust
2010-09-09  1:29                             ` Bian Naimeng
2010-11-24  6:27                               ` Bian Naimeng
     [not found]                             ` <1283978245.2905.23.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2010-12-02  8:32                               ` Li Yewang

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=1281101448.3586.11.camel@heimdal.trondhjem.org \
    --to=trond.myklebust@netapp.com \
    --cc=biannm@cn.fujitsu.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;
as well as URLs for NNTP newsgroup(s).