From: "Myklebust, Trond" <Trond.Myklebust@netapp.com>
To: Stanislav Kinsbursky <skinsbursky@parallels.com>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
"xemul@parallels.com" <xemul@parallels.com>,
"neilb@suse.de" <neilb@suse.de>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"jbottomley@parallels.com" <jbottomley@parallels.com>,
"bfields@fieldses.org" <bfields@fieldses.org>,
"davem@davemloft.net" <davem@davemloft.net>,
"devel@openvz.org" <devel@openvz.org>
Subject: Re: [PATCH v2 1/4] SUNRPC: release per-net clients lock before calling PipeFS dentries creation
Date: Mon, 27 Feb 2012 16:21:32 +0000 [thread overview]
Message-ID: <1330359695.5541.45.camel@lade.trondhjem.org> (raw)
In-Reply-To: <20120227155055.7941.18741.stgit@localhost6.localdomain6>
On Mon, 2012-02-27 at 19:50 +0400, Stanislav Kinsbursky wrote:
> Lockdep is sad otherwise, because inode mutex is taken on PipeFS dentry
> creation, which can be called on mount notification, where this per-net client
> lock is taken on clients list walk.
>
> Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
>
> ---
> net/sunrpc/clnt.c | 10 +++++++---
> 1 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
> index bb7ed2f3..ddb5741 100644
> --- a/net/sunrpc/clnt.c
> +++ b/net/sunrpc/clnt.c
> @@ -84,7 +84,7 @@ static void rpc_register_client(struct rpc_clnt *clnt)
> struct sunrpc_net *sn = net_generic(clnt->cl_xprt->xprt_net, sunrpc_net_id);
>
> spin_lock(&sn->rpc_client_lock);
> - list_add(&clnt->cl_clients, &sn->all_clients);
> + list_add_tail(&clnt->cl_clients, &sn->all_clients);
> spin_unlock(&sn->rpc_client_lock);
> }
>
> @@ -208,15 +208,19 @@ static int rpc_pipefs_event(struct notifier_block *nb, unsigned long event,
> void *ptr)
> {
> struct super_block *sb = ptr;
> - struct rpc_clnt *clnt;
> + struct rpc_clnt *clnt, *tmp;
> int error = 0;
> struct sunrpc_net *sn = net_generic(sb->s_fs_info, sunrpc_net_id);
>
> spin_lock(&sn->rpc_client_lock);
> - list_for_each_entry(clnt, &sn->all_clients, cl_clients) {
> + list_for_each_entry_safe(clnt, tmp, &sn->all_clients, cl_clients) {
> + atomic_inc(&clnt->cl_count);
> + spin_unlock(&sn->rpc_client_lock);
> error = __rpc_pipefs_event(clnt, event, sb);
> + rpc_release_client(clnt);
> if (error)
> break;
> + spin_lock(&sn->rpc_client_lock);
> }
> spin_unlock(&sn->rpc_client_lock);
> return error;
>
This won't be safe. Nothing guarantees that 'tmp' remains valid after
you drop the spin_lock.
I think you rather need to add a check for whether clnt->cl_dentry is in
the right state (NULL if RPC_PIPEFS_UMOUNT or non-NULL if
RPC_PIPEFS_MOUNT) before deciding whether or not to atomic_inc() and
drop the lock, so that you can restart the loop after calling
__rpc_pipefs_event().
--
Trond Myklebust
Linux NFS client maintainer
NetApp
Trond.Myklebust@netapp.com
www.netapp.com
next prev parent reply other threads:[~2012-02-27 16:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-27 15:50 [PATCH v2 0/4] SUNRPC: several fixes around PipeFS objects Stanislav Kinsbursky
2012-02-27 15:50 ` [PATCH v2 1/4] SUNRPC: release per-net clients lock before calling PipeFS dentries creation Stanislav Kinsbursky
2012-02-27 16:21 ` Myklebust, Trond [this message]
2012-02-27 16:55 ` Stanislav Kinsbursky
2012-02-27 17:11 ` David Laight
2012-02-27 17:37 ` Myklebust, Trond
2012-02-27 15:51 ` [PATCH v2 2/4] NFS: " Stanislav Kinsbursky
[not found] ` <20120227155103.7941.17006.stgit-bi+AKbBUZKagILUCTcTcHdKyNwTtLsGr@public.gmane.org>
2012-02-27 15:59 ` David Laight
2012-02-27 16:20 ` Stanislav Kinsbursky
2012-02-27 15:51 ` [PATCH v2 3/4] SUNRPC: check RPC inode's pipe reference before dereferencing Stanislav Kinsbursky
[not found] ` <20120227154713.7941.17963.stgit-bi+AKbBUZKagILUCTcTcHdKyNwTtLsGr@public.gmane.org>
2012-02-27 15:51 ` [PATCH v2 4/4] SUNRPC: move waitq from RPC pipe to RPC inode Stanislav Kinsbursky
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=1330359695.5541.45.camel@lade.trondhjem.org \
--to=trond.myklebust@netapp.com \
--cc=bfields@fieldses.org \
--cc=davem@davemloft.net \
--cc=devel@openvz.org \
--cc=jbottomley@parallels.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.de \
--cc=netdev@vger.kernel.org \
--cc=skinsbursky@parallels.com \
--cc=xemul@parallels.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).