Skip to content

Commit 142b942

Browse files
Phil Sutterdavem330
authored andcommitted
rhashtable: fix for resize events during table walk
If rhashtable_walk_next detects a resize operation in progress, it jumps to the new table and continues walking that one. But it misses to drop the reference to it's current item, leading it to continue traversing the new table's bucket in which the current item is sorted into, and after reaching that bucket's end continues traversing the new table's second bucket instead of the first one, thereby potentially missing items. This fixes the rhashtable runtime test for me. Bug probably introduced by Herbert Xu's patch eddee5b ("rhashtable: Fix walker behaviour during rehash") although not explicitly tested. Fixes: eddee5b ("rhashtable: Fix walker behaviour during rehash") Signed-off-by: Phil Sutter <[email protected]> Acked-by: Herbert Xu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f7e2965 commit 142b942

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/rhashtable.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,8 @@ void *rhashtable_walk_next(struct rhashtable_iter *iter)
610610
iter->skip = 0;
611611
}
612612

613+
iter->p = NULL;
614+
613615
/* Ensure we see any new tables. */
614616
smp_rmb();
615617

@@ -620,8 +622,6 @@ void *rhashtable_walk_next(struct rhashtable_iter *iter)
620622
return ERR_PTR(-EAGAIN);
621623
}
622624

623-
iter->p = NULL;
624-
625625
return NULL;
626626
}
627627
EXPORT_SYMBOL_GPL(rhashtable_walk_next);

0 commit comments

Comments
 (0)