mirror_zfs/module/splat
Chunwei Chen e843553d03 Don't hold mutex until release cv in cv_wait
If a thread is holding mutex when doing cv_destroy, it might end up waiting a
thread in cv_wait. The waiter would wake up trying to aquire the same mutex
and cause deadlock.

We solve this by move the mutex_enter to the bottom of cv_wait, so that
the waiter will release the cv first, allowing cv_destroy to succeed and have
a chance to free the mutex.

This would create race condition on the cv_mutex. We use xchg to set and check
it to ensure we won't be harmed by the race. This would result in the cv_mutex
debugging becomes best-effort.

Also, the change reveals a race, which was unlikely before, where we call
mutex_destroy while test threads are still holding the mutex. We use
kthread_stop to make sure the threads are exit before mutex_destroy.

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tim Chase <tim@chase2k.com>
Issue zfsonlinux/zfs#4166
Issue zfsonlinux/zfs#4106
2016-01-12 15:18:44 -08:00
..
Makefile.in Support parallel build trees (VPATH builds) 2015-07-17 12:53:11 -07:00
splat-atomic.c Add defclsyspri macro 2015-07-23 13:25:49 -07:00
splat-condvar.c Don't hold mutex until release cv in cv_wait 2016-01-12 15:18:44 -08:00
splat-cred.c splat cred:groupmember: Fix false positives 2014-04-08 12:44:41 -07:00
splat-ctl.c Linux 4.2 compat: misc_deregister() 2015-09-01 09:20:45 -07:00
splat-generic.c Remove compat includes from sys/types.h 2014-11-19 10:35:12 -08:00
splat-internal.h Linux 4.2 compat: vfs_rename() 2015-08-19 16:03:29 -07:00
splat-kmem.c Limit maximum object size in kmem tests 2015-11-16 15:02:24 -08:00
splat-kobj.c Refresh links to web site 2013-03-04 19:09:34 -08:00
splat-linux.c Remove compat includes from sys/types.h 2014-11-19 10:35:12 -08:00
splat-list.c Refresh links to web site 2013-03-04 19:09:34 -08:00
splat-mutex.c Add defclsyspri macro 2015-07-23 13:25:49 -07:00
splat-random.c Refresh links to web site 2013-03-04 19:09:34 -08:00
splat-rwlock.c Add defclsyspri macro 2015-07-23 13:25:49 -07:00
splat-taskq.c Add defclsyspri macro 2015-07-23 13:25:49 -07:00
splat-thread.c Add defclsyspri macro 2015-07-23 13:25:49 -07:00
splat-time.c Remove compat includes from sys/types.h 2014-11-19 10:35:12 -08:00
splat-vnode.c Linux 4.2 compat: vfs_rename() 2015-08-19 16:03:29 -07:00
splat-zlib.c Refactor existing code 2015-01-16 13:55:08 -08:00