All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] gfs2: Add missing rcu locking for glock lookup
Date: Wed, 22 Feb 2017 15:13:32 +0000	[thread overview]
Message-ID: <fe975f2b-473c-f87e-efb4-0604d8360a14@redhat.com> (raw)
In-Reply-To: <1487776193-18506-1-git-send-email-agruenba@redhat.com>

Hi,

Looks good, but can we fix that "retry for 100 times" loop too at the 
same time? There does appear to be an rhashtable API function that does 
what we need there,

Steve.

On 22/02/17 15:09, Andreas Gruenbacher wrote:
> From: Andrew Price <anprice@redhat.com>
>
> We must hold the rcu read lock across looking up glocks and trying to
> bump their refcount to prevent the glocks from being freed in between.
>
> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
> ---
>   fs/gfs2/glock.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
> index 94f50ca..1d60f5f 100644
> --- a/fs/gfs2/glock.c
> +++ b/fs/gfs2/glock.c
> @@ -658,9 +658,11 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
>   	struct kmem_cache *cachep;
>   	int ret, tries = 0;
>   
> +	rcu_read_lock();
>   	gl = rhashtable_lookup_fast(&gl_hash_table, &name, ht_parms);
>   	if (gl && !lockref_get_not_dead(&gl->gl_lockref))
>   		gl = NULL;
> +	rcu_read_unlock();
>   
>   	*glp = gl;
>   	if (gl)
> @@ -728,15 +730,18 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
>   
>   	if (ret == -EEXIST) {
>   		ret = 0;
> +		rcu_read_lock();
>   		tmp = rhashtable_lookup_fast(&gl_hash_table, &name, ht_parms);
>   		if (tmp == NULL || !lockref_get_not_dead(&tmp->gl_lockref)) {
>   			if (++tries < 100) {
> +				rcu_read_unlock();
>   				cond_resched();
>   				goto again;
>   			}
>   			tmp = NULL;
>   			ret = -ENOMEM;
>   		}
> +		rcu_read_unlock();
>   	} else {
>   		WARN_ON_ONCE(ret);
>   	}



  reply	other threads:[~2017-02-22 15:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-22 15:09 [Cluster-devel] [PATCH] gfs2: Add missing rcu locking for glock lookup Andreas Gruenbacher
2017-02-22 15:13 ` Steven Whitehouse [this message]
2017-02-22 15:26   ` Andreas Gruenbacher
2017-02-22 15:28     ` Andreas Gruenbacher
2017-02-22 15:29     ` Steven Whitehouse
2017-02-22 15:34       ` Andreas Gruenbacher
2017-02-22 15:50         ` Steven Whitehouse
2017-02-22 15:18 ` Andrew Price
2017-02-22 19:19 ` Bob Peterson
2017-02-23 10:04   ` Andrew Price
2017-02-23 13:08     ` Bob Peterson
2017-02-23 14:32       ` Andrew Price

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=fe975f2b-473c-f87e-efb4-0604d8360a14@redhat.com \
    --to=swhiteho@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.