Bug 211390

Summary: emulators/virtualbox-ose panic with aio(4)
Product: Base System Reporter: Randy Westlund <rwestlun>
Component: kernAssignee: John Baldwin <jhb>
Status: Closed FIXED    
Severity: Affects Only Me CC: jhb, pi, rwestlun
Priority: --- Flags: bugzilla: maintainer-feedback? (vbox)
Version: 11.0-STABLE   
Hardware: Any   
OS: Any   

Description Randy Westlund 2016-07-26 18:14:59 UTC
Running 12-CURRENT r303286 with virtualbox-ose-5.0.26

VirtualBox panics when launching a VM.


> vboxdrv: ffffffff82973020 VMMR0.r0
> vboxdrv: ffffffff82a92020 VBoxDDR0.r0
> vboxdrv: ffffffff82aaf020 VBoxDD2R0.r0
> panic: _mtx_lock_sleep: recursed on non-recursive mutex aiomtx @ /usr/src/sys/kern/vfs_aio.c:996
>
> cpuid = 1
> KBD: stack backtrace:
> db_trace_wrapper() at db_trace_wrapper+0x2b
> vpanic() at vpanic+0x182
> kassert_panic() at kassert_panic+0x126
> __mtx_lock_sleep() at __mtx_lock_sleep+0x228
> __mtx_lock_flags() at __mtx_lock_flags+0x10d
> aio_queue() at aio_queue+0x9d6
> amd64_syscall() at amd64_syscall+0x2db
> Xfast_syscall() at Xfast_syscall+0xfb
> --- syscall (465, FreeBSD ELF64, sys_aio_fsync), rip = 0x80119fa0a, rsp = 0x7fffdf2abc98, rbp = 0x7fffdf2abcd0 ---
> KDB: enter: panic
> [ thread pid 14588 tid 101813 ]
> Stopped at      kdb_enter+0x3b: movq    $0,kdb_why
Comment 1 John Baldwin freebsd_committer freebsd_triage 2016-07-27 20:57:02 UTC
Patch posted to https://reviews.freebsd.org/D7339
Comment 2 commit-hook freebsd_committer freebsd_triage 2016-07-29 18:26:46 UTC
A commit references this bug:

Author: jhb
Date: Fri Jul 29 18:26:16 UTC 2016
New revision: 303501
URL: https://svnweb.freebsd.org/changeset/base/303501

Log:
  Fix locking issues with aio_fsync().

  - Use correct lock in aio_cancel_sync when dequeueing job.
  - Add _locked variants of aio_set/clear_cancel_function and use those
    to avoid lock recursion when adding and removing fsync jobs to the
    per-process sync queue.
  - While here, add a basic test for aio_fsync().

  PR:		211390
  Reported by:	Randy Westlund <rwestlun@gmail.com>
  MFC after:	1 week
  Sponsored by:	Chelsio Communications
  Differential Revision:	https://reviews.freebsd.org/D7339

Changes:
  head/sys/kern/vfs_aio.c
  head/tests/sys/aio/aio_test.c
Comment 3 commit-hook freebsd_committer freebsd_triage 2016-08-05 22:23:26 UTC
A commit references this bug:

Author: jhb
Date: Fri Aug  5 22:23:04 UTC 2016
New revision: 303787
URL: https://svnweb.freebsd.org/changeset/base/303787

Log:
  MFC 303406,303501: Fix panic when using aio_fsync().

  303406:
  Adjust tests in fsync job scheduling loop to reduce indentation.

  303501:
  Fix locking issues with aio_fsync().

  - Use correct lock in aio_cancel_sync when dequeueing job.
  - Add _locked variants of aio_set/clear_cancel_function and use those
    to avoid lock recursion when adding and removing fsync jobs to the
    per-process sync queue.
  - While here, add a basic test for aio_fsync().

  PR:		211390
  Approved by:	re (kib)

Changes:
_U  stable/11/
  stable/11/sys/kern/vfs_aio.c
  stable/11/tests/sys/aio/aio_test.c