From: Trond Myklebust <Trond.Myklebust@netapp.com>
To: Bian Naimeng <biannm@cn.fujitsu.com>
Cc: linux-nfs@vger.kernel.org, "J. Bruce Fields" <bfields@redhat.com>
Subject: Re: [PATCH 2/2] We should clear NFS_DELEGATED_STATE after return delegation
Date: Wed, 08 Sep 2010 16:37:25 -0400 [thread overview]
Message-ID: <1283978245.2905.23.camel@heimdal.trondhjem.org> (raw)
In-Reply-To: <4C86FECF.2050103@cn.fujitsu.com>
On Wed, 2010-09-08 at 11:11 +0800, Bian Naimeng wrote:
> If there are not any delegation at this inode, we should clear stateid's
> NFS_DELEGATED_STATE when update it.
>
> Signed-off-by: Bian Naimeng <biannm@cn.fujitsu.com>
>
> ---
> fs/nfs/delegation.c | 1 +
> fs/nfs/nfs4proc.c | 12 +++++++++++-
> 2 files changed, 12 insertions(+), 1 deletions(-)
>
> diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
> index b9c3c43..62f296e 100644
> --- a/fs/nfs/delegation.c
> +++ b/fs/nfs/delegation.c
> @@ -106,6 +106,7 @@ again:
> continue;
> if (memcmp(state->stateid.data, stateid->data, sizeof(state->stateid.data)) != 0)
> continue;
> + clear_bit(NFS_DELEGATED_STATE, &state->flags);
> get_nfs_open_context(ctx);
> spin_unlock(&inode->i_lock);
> err = nfs4_open_delegation_recall(ctx, state, stateid);
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index 089da5b..f7e45b4 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -919,8 +919,18 @@ static int update_open_stateid(struct nfs4_state *state, nfs4_stateid *open_stat
>
> rcu_read_lock();
> deleg_cur = rcu_dereference(nfsi->delegation);
> - if (deleg_cur == NULL)
> + if (deleg_cur == NULL) {
> + if (delegation == NULL && open_stateid != NULL) {
Well... What I really meant was that we should make sure that we don't
get into this situation.
I think the clear_bit() should be unconditional if delegation == NULL,
but if the (delegation == NULL && open_stateid == NULL) _can_ occur,
then we should probably mark the nfs4_state for recovery using
nfs4_state_mark_reclaim_nograce(), and then fire of a recovery thread.
> + /*
> + * FIXME: If the state has NFS_DELEGATED_STATE bit
> + * we catch a race. Maybe should recover its open
> + * stateid, now we just clear the NFS_DELEGATED_STATE
> + * bit.
> + */
> + clear_bit(NFS_DELEGATED_STATE, &state->flags);
> + }
> goto no_delegation;
> + }
>
> spin_lock(&deleg_cur->lock);
> if (nfsi->delegation != deleg_cur ||
> --
> 1.7.0
>
>
> >>>> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> >>>> index 36400d3..c0c0320 100644
> >>>> --- a/fs/nfs/nfs4proc.c
> >>>> +++ b/fs/nfs/nfs4proc.c
> >>>> @@ -900,8 +900,18 @@ static int update_open_stateid(struct nfs4_state *state, nfs4_stateid *open_stat
> >>>>
> >>>> rcu_read_lock();
> >>>> deleg_cur = rcu_dereference(nfsi->delegation);
> >>>> - if (deleg_cur == NULL)
> >>>> + if (deleg_cur == NULL) {
> >>>> + if (delegation == NULL &&
> >>>> + test_bit(NFS_DELEGATED_STATE, &state->flags)) {
> >>> Any reason why we can't ditch the 'test_bit'?
> >>>
> >> Because i am not sure it's ok that we just clear_bit at here.
> >> If you think it's ok, i'd be fine with removing this test_bit.
> >
> > How is it different from just clearing the bit?
> >
> >>>> + /*FIXME: If the state has NFS_DELEGATED_STATE bit,
> >>>> + * we catch a race. Maybe should recover its open
> >>>> + * stateid, here we just clear the NFS_DELEGATED_STATE
> >>>> + * bit.
> >>> Can this ever be called with both deleg_cur==NULL and
> >>> open_stateid==NULL? If so, then we still have a bug.
> >>>
> >> Yes, i will add a checking. Thanks very much.
> >>
> >>>> + */
> >>>> + clear_bit(NFS_DELEGATED_STATE, &state->flags);
> >>>> + }
> >>>> goto no_delegation;
> >>>> + }
> >>>>
> >>>> spin_lock(&deleg_cur->lock);
> >>>> if (nfsi->delegation != deleg_cur ||
> >
> > Cheers
> > Trond
> >
> >
> >
>
next prev parent reply other threads:[~2010-09-08 20:38 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
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 [this message]
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=1283978245.2905.23.camel@heimdal.trondhjem.org \
--to=trond.myklebust@netapp.com \
--cc=bfields@redhat.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).