Module Name:    src
Committed By:   martin
Date:           Tue Dec 14 19:05:11 UTC 2021

Modified Files:
        src/sys/dev [netbsd-9]: cgd.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1393):

        sys/dev/cgd.c: revision 1.141

cgd(4): Wait for worker threads to complete before destroying mutex.

Fixes PR kern/56546 (probably!).


To generate a diff of this commit:
cvs rdiff -u -r1.116.10.3 -r1.116.10.4 src/sys/dev/cgd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/cgd.c
diff -u src/sys/dev/cgd.c:1.116.10.3 src/sys/dev/cgd.c:1.116.10.4
--- src/sys/dev/cgd.c:1.116.10.3	Mon Apr  6 14:57:42 2020
+++ src/sys/dev/cgd.c	Tue Dec 14 19:05:11 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.116.10.3 2020/04/06 14:57:42 martin Exp $ */
+/* $NetBSD: cgd.c,v 1.116.10.4 2021/12/14 19:05:11 martin Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.116.10.3 2020/04/06 14:57:42 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.116.10.4 2021/12/14 19:05:11 martin Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -516,14 +516,20 @@ cgd_create_worker(void)
 static void
 cgd_destroy_worker(struct cgd_worker *cw)
 {
+
+	/*
+	 * Wait for all worker threads to complete before destroying
+	 * the rest of the cgd_worker.
+	 */
+	if (cw->cw_wq)
+		workqueue_destroy(cw->cw_wq);
+
 	mutex_destroy(&cw->cw_lock);
 
 	if (cw->cw_cpool) {
 		pool_destroy(cw->cw_cpool);
 		kmem_free(cw->cw_cpool, sizeof(struct pool));
 	}
-	if (cw->cw_wq)
-		workqueue_destroy(cw->cw_wq);
 
 	kmem_free(cw, sizeof(struct cgd_worker));
 }

Reply via email to