Skip to content

Commit e952c29

Browse files
Andreas Gruenbachergregkh
authored andcommitted
gfs2: Fix glock rhashtable rcu bug
commit 961ae1d83d055a4b9ebbfb4cc8ca62ec1a7a3b74 upstream. Before commit 88ffbf3 "GFS2: Use resizable hash table for glocks", glocks were freed via call_rcu to allow reading the glock hashtable locklessly using rcu. This was then changed to free glocks immediately, which made reading the glock hashtable unsafe. Bring back the original code for freeing glocks via call_rcu. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ac12d6a commit e952c29

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

fs/gfs2/glock.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,23 @@ static struct rhashtable_params ht_parms = {
8080

8181
static struct rhashtable gl_hash_table;
8282

83-
void gfs2_glock_free(struct gfs2_glock *gl)
83+
static void gfs2_glock_dealloc(struct rcu_head *rcu)
8484
{
85-
struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
85+
struct gfs2_glock *gl = container_of(rcu, struct gfs2_glock, gl_rcu);
8686

8787
if (gl->gl_ops->go_flags & GLOF_ASPACE) {
8888
kmem_cache_free(gfs2_glock_aspace_cachep, gl);
8989
} else {
9090
kfree(gl->gl_lksb.sb_lvbptr);
9191
kmem_cache_free(gfs2_glock_cachep, gl);
9292
}
93+
}
94+
95+
void gfs2_glock_free(struct gfs2_glock *gl)
96+
{
97+
struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
98+
99+
call_rcu(&gl->gl_rcu, gfs2_glock_dealloc);
93100
if (atomic_dec_and_test(&sdp->sd_glock_disposal))
94101
wake_up(&sdp->sd_glock_wait);
95102
}

fs/gfs2/incore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ struct gfs2_glock {
367367
loff_t end;
368368
} gl_vm;
369369
};
370+
struct rcu_head gl_rcu;
370371
struct rhash_head gl_node;
371372
};
372373

0 commit comments

Comments
 (0)