Whamcloud - gitweb
LU-15207 libcfs: reset hs_rehash_bits 33/45533/8
authorAlex Zhuravlev <bzzz@whamcloud.com>
Thu, 11 Nov 2021 08:19:46 +0000 (11:19 +0300)
committerOleg Drokin <green@whamcloud.com>
Sat, 11 Jun 2022 05:32:01 +0000 (05:32 +0000)
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().

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I1a567f6be77ca6c45e5d4f256722206b12588554
Reviewed-on: https://review.whamcloud.com/45533
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/libcfs/hash.c

index ca234ef..6fb32ad 100644 (file)
@@ -1828,8 +1828,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