From 2954e5125642f8b54c6c265290711adcb69e9a79 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Thu, 11 Nov 2021 11:19:46 +0300 Subject: [PATCH] LU-15207 libcfs: reset hs_rehash_bits if rehash work is cancelled, then nobody resets hs_rehash_bits and the first iterator asserts at LASSERT(!cfs_hash_is_rehashing(hs)) in cfs_hash_for_each_relax(). Lustre-change: https://review.whamcloud.com/45533 Lustre-commit: TBD (from 0c51e83b1345059c7f6847ea394e589ebffd0121) Signed-off-by: Alex Zhuravlev Change-Id: I1a567f6be77ca6c45e5d4f256722206b12588554 Reviewed-on: https://review.whamcloud.com/45557 Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Andreas Dilger --- libcfs/libcfs/hash.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libcfs/libcfs/hash.c b/libcfs/libcfs/hash.c index aa2c7b3..499d06d 100644 --- a/libcfs/libcfs/hash.c +++ b/libcfs/libcfs/hash.c @@ -1829,8 +1829,15 @@ EXPORT_SYMBOL(cfs_hash_for_each_key); void cfs_hash_rehash_cancel(struct cfs_hash *hs) { - LASSERT(cfs_hash_with_rehash(hs)); - cancel_work_sync(&hs->hs_rehash_work); + LASSERT(hs->hs_iterators > 0 || hs->hs_exiting); + while (cfs_hash_is_rehashing(hs)) { + if (cancel_work_sync(&hs->hs_rehash_work)) { + cfs_hash_lock(hs, 1); + hs->hs_rehash_bits = 0; + cfs_hash_unlock(hs, 1); + } + cond_resched(); + } } void -- 1.8.3.1