summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorDerek Basehore <dbasehore@chromium.org>2012-12-18 12:27:18 -0800
committerMandar Padmawar <mpadmawar@nvidia.com>2013-03-14 07:08:57 -0700
commit00a0fc719c0b7c9c0f26da22c16629558d86e7ed (patch)
treeb8c36dc29c870e2b968eda6a84c9bdccc2c6eff6 /block
parent605a982aecdb00165dcf19387fd854e83058c989 (diff)
block: remove deadlock in disk_clear_events
In disk_clear_events, do not put work on system_nrt_freezable_wq. Instead, put it on system_nrt_wq. There is a race between probing a usb and suspending the device. Since probing a usb calls disk_clear_events, which puts work on a frozen workqueue, probing cannot finish after the workqueue is frozen. However, suspending cannot finish until the usb probe is finished, so we get a deadlock, causing the system to reboot. The way to reproduce this bug is to wake up from suspend with a usb storage device plugged in, or plugging in a usb storage device right before suspend. The window of time is on the order of time it takes to probe the usb device. As long as the workqueues are frozen before the call to add_disk within sd_probe_async finishes, there will be a deadlock (which calls blkdev_get, sd_open, check_disk_change, then disk_clear_events). This is not difficult to reproduce after figuring out the timings. Bug 1234886 Change-Id: I326339a5ba7011b46a2e8b80a3dbd4fe383096a7 [akpm@linux-foundation.org: fix up comment] Signed-off-by: Derek Basehore <dbasehore@chromium.org> Reviewed-by: Mandeep Singh Baines <msb@chromium.org> Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Jens Axboe <axboe@kernel.dk> Reviewed-on: http://git-master/r/208468 Reviewed-by: Ajay Gupta <ajayg@nvidia.com> Tested-by: Ajay Gupta <ajayg@nvidia.com> Reviewed-by: Bo Yan <byan@nvidia.com> (cherry picked from commit 80daddb927db9f4b24276147a17eba220e85bdcc) Reviewed-on: http://git-master/r/208865 Reviewed-by: Ashutosh Jha <ajha@nvidia.com> GVS: Gerrit_Virtual_Submit
Diffstat (limited to 'block')
-rw-r--r--block/genhd.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 2ade7561436c..6d60c7bb8b05 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1581,7 +1581,14 @@ unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask)
/* uncondtionally schedule event check and wait for it to finish */
disk_block_events(disk);
- queue_delayed_work(system_nrt_freezable_wq, &ev->dwork, 0);
+ /*
+ * We need to put the work on system_nrt_wq here since there is a
+ * deadlock that happens while probing a usb device while suspending. If
+ * we put work on a freezable workqueue here, a usb probe will wait here
+ * until the workqueue is unfrozen during suspend. Since suspend waits
+ * on all probes to complete, we have a deadlock
+ */
+ queue_delayed_work(system_nrt_wq, &ev->dwork, 0);
flush_delayed_work(&ev->dwork);
__disk_unblock_events(disk, false);