linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stanislav Kinsbursky <skinsbursky@parallels.com>
To: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH 3/3] NFS: Add memory barriers to the nfs_client->cl_cons_state initialisation
Date: Thu, 24 May 2012 08:36:36 +0400	[thread overview]
Message-ID: <4FBDBAD4.7040500@parallels.com> (raw)
In-Reply-To: <1337794363-11905-3-git-send-email-Trond.Myklebust@netapp.com>

23.05.2012 21:32, Trond Myklebust написал:
> Ensure that a process that uses the nfs_client->cl_cons_state test
> for whether the initialisation process is finished does not read
> stale data.
>
> Signed-off-by: Trond Myklebust<Trond.Myklebust@netapp.com>
> ---
>   fs/nfs/client.c |    5 +++++
>   fs/nfs/idmap.c  |    1 +
>   2 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/fs/nfs/client.c b/fs/nfs/client.c
> index e6070ea..4be85f9 100644
> --- a/fs/nfs/client.c
> +++ b/fs/nfs/client.c
> @@ -456,6 +456,8 @@ static bool nfs4_cb_match_client(const struct sockaddr *addr,
>   	    clp->cl_cons_state == NFS_CS_SESSION_INITING))
>   		return false;
>
> +	smp_rmb();
> +
>   	/* Match the version and minorversion */
>   	if (clp->rpc_ops->version != 4 ||
>   	    clp->cl_minorversion != minorversion)
> @@ -587,6 +589,8 @@ found_client:
>   		return ERR_PTR(error);
>   	}
>
> +	smp_rmb();
> +
>   	BUG_ON(clp->cl_cons_state != NFS_CS_READY);
>
>   	dprintk("-->  nfs_get_client() = %p [share]\n", clp);
> @@ -598,6 +602,7 @@ found_client:
>    */
>   void nfs_mark_client_ready(struct nfs_client *clp, int state)
>   {
> +	smp_wmb();

BTW, why barrier is before assignment?

>   	clp->cl_cons_state = state;
>   	wake_up_all(&nfs_client_active_wq);
>   }
> diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
> index 6ca949b..7d4e8dd 100644
> --- a/fs/nfs/idmap.c
> +++ b/fs/nfs/idmap.c
> @@ -548,6 +548,7 @@ restart:
>   		/* Skip nfs_clients that failed to initialise */
>   		if (clp->cl_cons_state<  0)
>   			continue;
> +		smp_rmb();
>   		if (clp->rpc_ops !=&nfs_v4_clientops)
>   			continue;
>   		cl_dentry = clp->cl_idmap->idmap_pipe->dentry;


  reply	other threads:[~2012-05-24  4:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-23 17:32 [PATCH 1/3] NFSv4.1: Fix session initialisation races Trond Myklebust
2012-05-23 17:32 ` [PATCH 2/3] NFSv4: Fix a race in the net namespace mount notification Trond Myklebust
2012-05-23 17:32   ` [PATCH 3/3] NFS: Add memory barriers to the nfs_client->cl_cons_state initialisation Trond Myklebust
2012-05-24  4:36     ` Stanislav Kinsbursky [this message]
2012-05-24 11:59       ` Myklebust, Trond
2012-05-23 18:58   ` [PATCH 2/3] NFSv4: Fix a race in the net namespace mount notification Stanislav Kinsbursky
2012-05-23 18:37 ` [PATCH 1/3] NFSv4.1: Fix session initialisation races Adamson, Andy
2012-05-23 19:14   ` Myklebust, Trond
2012-05-23 19:20     ` Myklebust, Trond
2012-05-23 19:25       ` Adamson, Andy

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=4FBDBAD4.7040500@parallels.com \
    --to=skinsbursky@parallels.com \
    --cc=Trond.Myklebust@netapp.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).