mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-28 20:09:35 +03:00
07ce5d7390
PROBLEM ======= It's possible for a parent zio to complete even though it has children which have not completed. This can result in the following panic: > $C ffffff01809128c0 vpanic() ffffff01809128e0 mutex_panic+0x58(fffffffffb94c904, ffffff597dde7f80) ffffff0180912950 mutex_vector_enter+0x347(ffffff597dde7f80) ffffff01809129b0 zio_remove_child+0x50(ffffff597dde7c58, ffffff32bd901ac0, ffffff3373370908) ffffff0180912a40 zio_done+0x390(ffffff32bd901ac0) ffffff0180912a70 zio_execute+0x78(ffffff32bd901ac0) ffffff0180912b30 taskq_thread+0x2d0(ffffff33bae44140) ffffff0180912b40 thread_start+8() > ::status debugging crash dump vmcore.2 (64-bit) from batfs0390 operating system: 5.11 joyent_20170911T171900Z (i86pc) image uuid: (not set) panic message: mutex_enter: bad mutex, lp=ffffff597dde7f80 owner=ffffff3c59b39480 thread=ffffff0180912c40 dump content: kernel pages only The problem is that dbuf_prefetch along with l2arc can create a zio tree which confuses the parent zio and allows it to complete with while children still exist. Here's the scenario: zio tree: pio |--- lio The parent zio, pio, has entered the zio_done stage and begins to check its children to see there are still some that have not completed. In zio_done(), the children are checked in the following order: zio_wait_for_children(zio, ZIO_CHILD_VDEV, ZIO_WAIT_DONE) zio_wait_for_children(zio, ZIO_CHILD_GANG, ZIO_WAIT_DONE) zio_wait_for_children(zio, ZIO_CHILD_DDT, ZIO_WAIT_DONE) zio_wait_for_children(zio, ZIO_CHILD_LOGICAL, ZIO_WAIT_DONE) If pio, finds any child which has not completed then it stops executing and goes to sleep. Each call to zio_wait_for_children() will grab the io_lock while checking the particular child. In this scenario, the pio has completed the first call to zio_wait_for_children() to check for any ZIO_CHILD_VDEV children. Since the only zio in the zio tree right now is the logical zio, lio, then it completes that call and prepares to check the next child type. In the meantime, the lio completes and in its callback creates a child vdev zio, cio. The zio tree looks like this: zio tree: pio |--- lio |--- cio The lio then grabs the parent's io_lock and removes itself. zio tree: pio |--- cio The pio continues to run but has already completed its check for ZIO_CHILD_VDEV and will erroneously complete. When the child zio, cio, completes it will panic the system trying to reference the parent zio which has been destroyed. SOLUTION ======== The fix is to rework the zio_wait_for_children() logic to accept a bitfield for all the children types that it's interested in checking. The io_lock will is held the entire time we check all the children types. Since the function now accepts a bitfield, a simple ZIO_CHILD_BIT() macro is provided to allow for the conversion between a ZIO_CHILD type and the bitfield used by the zio_wiat_for_children logic. Authored by: George Wilson <george.wilson@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Andriy Gapon <avg@FreeBSD.org> Reviewed by: Youzhong Yang <youzhong@gmail.com> Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov> Approved by: Dan McDonald <danmcd@omniti.com> Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov> OpenZFS-issue: https://www.illumos.org/issues/8857 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/862ff6d99c Issue #5918 Closes #7168 |
||
---|---|---|
.. | ||
crypto | ||
fm | ||
fs | ||
sysevent | ||
abd.h | ||
arc_impl.h | ||
arc.h | ||
avl_impl.h | ||
avl.h | ||
blkptr.h | ||
bplist.h | ||
bpobj.h | ||
bptree.h | ||
bqueue.h | ||
dbuf.h | ||
ddt.h | ||
dmu_impl.h | ||
dmu_objset.h | ||
dmu_send.h | ||
dmu_traverse.h | ||
dmu_tx.h | ||
dmu_zfetch.h | ||
dmu.h | ||
dnode.h | ||
dsl_bookmark.h | ||
dsl_dataset.h | ||
dsl_deadlist.h | ||
dsl_deleg.h | ||
dsl_destroy.h | ||
dsl_dir.h | ||
dsl_pool.h | ||
dsl_prop.h | ||
dsl_scan.h | ||
dsl_synctask.h | ||
dsl_userhold.h | ||
edonr.h | ||
efi_partition.h | ||
Makefile.am | ||
metaslab_impl.h | ||
metaslab.h | ||
mmp.h | ||
mntent.h | ||
multilist.h | ||
nvpair_impl.h | ||
nvpair.h | ||
pathname.h | ||
policy.h | ||
range_tree.h | ||
refcount.h | ||
rrwlock.h | ||
sa_impl.h | ||
sa.h | ||
sdt.h | ||
sha2.h | ||
skein.h | ||
spa_boot.h | ||
spa_checksum.h | ||
spa_impl.h | ||
spa.h | ||
space_map.h | ||
space_reftree.h | ||
sysevent.h | ||
trace_acl.h | ||
trace_arc.h | ||
trace_common.h | ||
trace_dbgmsg.h | ||
trace_dbuf.h | ||
trace_dmu.h | ||
trace_dnode.h | ||
trace_multilist.h | ||
trace_txg.h | ||
trace_zil.h | ||
trace_zio.h | ||
trace_zrlock.h | ||
trace.h | ||
txg_impl.h | ||
txg.h | ||
u8_textprep_data.h | ||
u8_textprep.h | ||
uberblock_impl.h | ||
uberblock.h | ||
uio_impl.h | ||
unique.h | ||
uuid.h | ||
vdev_disk.h | ||
vdev_file.h | ||
vdev_impl.h | ||
vdev_raidz_impl.h | ||
vdev_raidz.h | ||
vdev.h | ||
xvattr.h | ||
zap_impl.h | ||
zap_leaf.h | ||
zap.h | ||
zfeature.h | ||
zfs_acl.h | ||
zfs_context.h | ||
zfs_ctldir.h | ||
zfs_debug.h | ||
zfs_delay.h | ||
zfs_dir.h | ||
zfs_fuid.h | ||
zfs_ioctl.h | ||
zfs_onexit.h | ||
zfs_ratelimit.h | ||
zfs_rlock.h | ||
zfs_sa.h | ||
zfs_stat.h | ||
zfs_vfsops.h | ||
zfs_vnops.h | ||
zfs_znode.h | ||
zil_impl.h | ||
zil.h | ||
zio_checksum.h | ||
zio_compress.h | ||
zio_impl.h | ||
zio_priority.h | ||
zio.h | ||
zpl.h | ||
zrlock.h | ||
zvol.h |