Skip to content

Commit 98687f4

Browse files
herbertxdavem330
authored andcommitted
gfs2: Use rhashtable walk interface in glock_hash_walk
The function glock_hash_walk walks the rhashtable by hand. This is broken because if it catches the hash table in the middle of a rehash, then it will miss entries. This patch replaces the manual walk by using the rhashtable walk interface. Fixes: 88ffbf3 ("GFS2: Use resizable hash table for glocks") Signed-off-by: Herbert Xu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4581be4 commit 98687f4

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

fs/gfs2/glock.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,26 +1420,32 @@ static struct shrinker glock_shrinker = {
14201420
* @sdp: the filesystem
14211421
* @bucket: the bucket
14221422
*
1423+
* Note that the function can be called multiple times on the same
1424+
* object. So the user must ensure that the function can cope with
1425+
* that.
14231426
*/
14241427

14251428
static void glock_hash_walk(glock_examiner examiner, const struct gfs2_sbd *sdp)
14261429
{
14271430
struct gfs2_glock *gl;
1428-
struct rhash_head *pos;
1429-
const struct bucket_table *tbl;
1430-
int i;
1431+
struct rhashtable_iter iter;
14311432

1432-
rcu_read_lock();
1433-
tbl = rht_dereference_rcu(gl_hash_table.tbl, &gl_hash_table);
1434-
for (i = 0; i < tbl->size; i++) {
1435-
rht_for_each_entry_rcu(gl, pos, tbl, i, gl_node) {
1433+
rhashtable_walk_enter(&gl_hash_table, &iter);
1434+
1435+
do {
1436+
gl = ERR_PTR(rhashtable_walk_start(&iter));
1437+
if (gl)
1438+
continue;
1439+
1440+
while ((gl = rhashtable_walk_next(&iter)) && !IS_ERR(gl))
14361441
if ((gl->gl_name.ln_sbd == sdp) &&
14371442
lockref_get_not_dead(&gl->gl_lockref))
14381443
examiner(gl);
1439-
}
1440-
}
1441-
rcu_read_unlock();
1442-
cond_resched();
1444+
1445+
rhashtable_walk_stop(&iter);
1446+
} while (cond_resched(), gl == ERR_PTR(-EAGAIN));
1447+
1448+
rhashtable_walk_exit(&iter);
14431449
}
14441450

14451451
/**

0 commit comments

Comments
 (0)