freebsd-dev/cmd
Richard Yao 7809eb8b65 ztest: Switch to LWP rwlock interface
ztest is intended to subject the ZFS code in userland to stress that it
should be able to withstand. Any failures that occur when running it are
failures that likely would occur inside the kernel. However, being in
userland, it is much easier to debug them. In practice, this prevents
a large number of problems from reaching production code.

A design decision was made by the original authors of ztest to make a
distinction between userland locking primitives and kernel locking
primitives. The ztest code itself calls userland locking primitives
while the kernel code being run in userland will call emulated kernel
locking primitives that wrap the userland locking primitives.

When ztest was first ported to Linux, a decision was made to use the
emulated kernel interfaces everywhere. In effect, the userland
rw_rdlock()/rw_wrlock() became the kernel rw_enter() and and the userland
rw_unlock() became the kernel rw_exit(). This caused a regression
because of an assertion in rw_enter() to catch recursive locking. That
is permitted in userland, but not in the kernel. Consequently, the ztest
code itself does recursive read locking. The use of the emulated kernel
interfaces consequently caused the following failure:

ztest: ../../lib/libzpool/kernel.c:384: Assertion `rwlp->rw_owner !=
zk_thread_current() (0x1c87150 != 0x1c87150)' failed.

That occurs because ztest_dmu_objset_create_destroy() will take a read
lock and call ztest_dmu_object_alloc_free(). That will call ztest_io(),
which will take a readlock only when asked to do ZTEST_IO_REWRITE. This
triggered the assertion.

The pthreads rwlock interface was based on the LWP rwlock interface
implemented in Illumos libc. Luckily enough, the subset used by ztest is
almost identical, so we can solve this problem by switching to the LWP
thread rwlock interface in ztest. This eliminates a point of divergence
with Illumos and should make code sharing slightly easier.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1970
2014-05-01 15:53:58 -07:00
..
arcstat sighandler() should take 2 arguments 2014-03-20 11:03:46 -07:00
dbufstat Python 3 fixes 2013-11-08 14:30:29 -08:00
fsck_zfs Add /sbin/fsck.zfs helper 2013-01-09 16:54:58 -08:00
mount_zfs Add full SELinux support 2013-12-19 10:37:31 -08:00
vdev_id vdev_id: support per-channel slot mappings 2014-01-17 11:17:54 -08:00
zdb cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
zed Replace zed_file_create_dirs() with mkdirp() 2014-04-09 13:32:54 -07:00
zfs Fix for re-reading /etc/mtab. 2014-04-04 09:46:20 -07:00
zhack Add missing libzfs_core to Makefiles 2013-11-20 15:44:15 -08:00
zinject Make command line guid parsing more tolerant 2014-04-02 13:10:08 -07:00
zpios Fix error message in zpios 2014-01-29 15:11:56 -08:00
zpool Fix libblkid ZFS detection when making new pools 2014-05-01 13:26:33 -07:00
zstreamdump Add missing libzfs_core to Makefiles 2013-11-20 15:44:15 -08:00
ztest ztest: Switch to LWP rwlock interface 2014-05-01 15:53:58 -07:00
zvol_id cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
Makefile.am Initial implementation of zed (ZFS Event Daemon) 2014-04-02 13:10:03 -07:00