diff mbox series

[14/28] lnet: libcfs: reset hs_rehash_bits

Message ID 1655560330-30743-15-git-send-email-jsimmons@infradead.org (mailing list archive)
State Not Applicable
Headers show
Series lustre: sync to OpenSFS June 15, 2022 | expand

Commit Message

James Simmons June 18, 2022, 1:51 p.m. UTC
From: Alex Zhuravlev <bzzz@whamcloud.com>

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().

WC-bug-id: https://jira.whamcloud.com/browse/LU-15207
Lustre-commit: 9257f24dfdf9f0a68 ("LU-15207 libcfs: reset hs_rehash_bits")
Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/45533
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 net/lnet/libcfs/hash.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/net/lnet/libcfs/hash.c b/net/lnet/libcfs/hash.c
index d060eaa..c9ff92d 100644
--- a/net/lnet/libcfs/hash.c
+++ b/net/lnet/libcfs/hash.c
@@ -1765,8 +1765,15 @@  struct cfs_hash_cond_arg {
 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