CHROMIUM: md: dm-verity: Fix to avoid a deadlock in dm-bufio
authorPaul Taysom <taysom@chromium.org>
Thu, 31 Jan 2013 21:44:23 +0000 (13:44 -0800)
committerChromeBot <chrome-bot@google.com>
Thu, 14 Mar 2013 18:50:25 +0000 (11:50 -0700)
commit867a05bd79267c344209fb46e56b0aca3b292520
treee6ca5dcd78fa18e5ca097694d204f9299c5a2003
parent112f879c41ce061a078c2ed3b1c825009733650d
CHROMIUM: md: dm-verity: Fix to avoid a deadlock in dm-bufio

Changed the dm-verity prefetching to use a worker thread to avoid
a deadlock in dm-bufio.

If generic_make_request is called recursively, it queues the I/O
request on the current->bio_list without making the I/O request
and returns. The routine making the recursive call cannot wait
for the I/O to complete.

The deadlock occurred when one thread grabbed the bufio_client
mutex and waited for an I/O to complete but the I/O was queued
on another thread's current->bio_list and it was waiting to get
the mutex held by the first thread.

The fix allows only one I/O request from dm-verity to dm-bufio
per thread. To do this, the prefetch requests were queued on worker
threads.

In addition to avoiding the deadlock, this fix made a slight
improvement in performance.

seconds_kernel_to_login:
  with prefetch:    8.43s
  without prefetch: 9.2s
  worker prefetch:  8.28s

BUG=chromium-os:39148
TEST=./run_remote_tests.sh --board=$B --remote=$IP suite:smoke
Signed-off-by: Paul Taysom <taysom@chromium.org>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@kernel.org
Change-Id: I5f3cddfed507abfb8198fee71e713495f076b772
Reviewed-on: https://gerrit.chromium.org/gerrit/42422
Tested-by: Paul Taysom <taysom@chromium.org>
Reviewed-by: Mandeep Singh Baines <msb@chromium.org>
Reviewed-by: Olof Johansson <olofj@chromium.org>
Commit-Queue: Paul Taysom <taysom@chromium.org>
drivers/md/dm-bufio.c
drivers/md/dm-verity.c