All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH] gfs2: Add missing rcu locking for glock lookup
@ 2017-02-22 15:09 Andreas Gruenbacher
  2017-02-22 15:13 ` Steven Whitehouse
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Andreas Gruenbacher @ 2017-02-22 15:09 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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);
 	}
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-02-23 14:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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.