kernel - Fix races in disk iteration and diskctx handling
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 30 Nov 2012 19:17:50 +0000 (11:17 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 30 Nov 2012 20:57:42 +0000 (12:57 -0800)
commit5374d04ff57a66cc5c140a32249db93546195130
tree85edac55f172b5f3ac2b4210307813c07226da99
parente9593c8eee2f93a65210914fa1c91a2c5cad6b74
kernel - Fix races in disk iteration and diskctx handling

* Add disk->d_refs to prevent a disk structure from being destroyed out
  from under an iteration.

* Redo the disk_enumeration() API to use markers and d_refs.

* Make adjustments to the dsched API.  In particular, do not return
  unreferenced tdio pointers in situations where they aren't used by
  the caller.

* Properly implement the ref count on the tdio's, one for each of the two
  lists the tdio belongs to, and ensure that dsched_thread_io_alloc()
  keeps an extra ref on the tdio after releasing the diskctx lock to prevent
  it from being ripped out while the code is pondering whether to place
  the tdio on the tdctx list.

* When deleting the tdio's for a tdctx try to destroy the diskctx.  That is,
  simply dereferencing it from the thread is not sufficient.

* When deleting the tdio's for a diskctx try to destroy the tdctx.  That is,
  simply dereferencing it from the diskctx is not sufficient.

* Handle destroy/ref races.
sys/kern/dsched/bfq/bfq_helper_thread.c
sys/kern/dsched/fq/fq_core.c
sys/kern/kern_dsched.c
sys/kern/subr_disk.c
sys/sys/disk.h
sys/sys/dsched.h