nvme - Fix BUF_KERNPROC() SMP race
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 21 Jul 2016 02:29:06 +0000 (19:29 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 22 Jul 2016 03:08:58 +0000 (20:08 -0700)
commita391a14a3472200021bf4616938068c5e9ee2b58
treee4e94139882169822479b8c8bb52bac24415705b
parent8d327fcc6e31be8c51b8f2f883cfe4ed32015b02
nvme - Fix BUF_KERNPROC() SMP race

* BUF_KERNPROC() must be issued before we submit the request.  The subq
  lock is not sufficient to interlock request completion (which only needs
  the comq lock).

* Only occurs under extreme loads, probably due to an IPI or Xinvltlb
  causing enough of a pause that the completion can run.  NVMe is so fast,
  probably no other controller would hit this particular race condition.

* Also fix a bio queueing race which can leave a bio hanging.  If no
  requests are available (which can only happen under very heavy I/O
  loads), the signaling to the admin thread on the next I/O completion
  can race the queueing of the bio.  Fix the race by making sure the
  admin thread is signalled *after* queueing the bio.
sys/dev/disk/nvme/nvme.c
sys/dev/disk/nvme/nvme_disk.c