diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2012-03-02 04:51:00 -0500 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2012-03-02 04:51:00 -0500 |
commit | 62d3c5439c534b0e6c653fc63e6d8c67be3a57b1 (patch) | |
tree | d335d0e449ef2d61d52921e3f210cdd403bb025a /kernel | |
parent | cecd353a02fb1405c8a72a324b26b5acf97e7411 (diff) |
Block: use a freezable workqueue for disk-event polling
This patch (as1519) fixes a bug in the block layer's disk-events
polling. The polling is done by a work routine queued on the
system_nrt_wq workqueue. Since that workqueue isn't freezable, the
polling continues even in the middle of a system sleep transition.
Obviously, polling a suspended drive for media changes and such isn't
a good thing to do; in the case of USB mass-storage devices it can
lead to real problems requiring device resets and even re-enumeration.
The patch fixes things by creating a new system-wide, non-reentrant,
freezable workqueue and using it for disk-events polling.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: <stable@kernel.org>
Acked-by: Tejun Heo <tj@kernel.org>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/workqueue.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index bec7b5b53e03..f2c5638bb5ab 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -253,11 +253,13 @@ struct workqueue_struct *system_long_wq __read_mostly; | |||
253 | struct workqueue_struct *system_nrt_wq __read_mostly; | 253 | struct workqueue_struct *system_nrt_wq __read_mostly; |
254 | struct workqueue_struct *system_unbound_wq __read_mostly; | 254 | struct workqueue_struct *system_unbound_wq __read_mostly; |
255 | struct workqueue_struct *system_freezable_wq __read_mostly; | 255 | struct workqueue_struct *system_freezable_wq __read_mostly; |
256 | struct workqueue_struct *system_nrt_freezable_wq __read_mostly; | ||
256 | EXPORT_SYMBOL_GPL(system_wq); | 257 | EXPORT_SYMBOL_GPL(system_wq); |
257 | EXPORT_SYMBOL_GPL(system_long_wq); | 258 | EXPORT_SYMBOL_GPL(system_long_wq); |
258 | EXPORT_SYMBOL_GPL(system_nrt_wq); | 259 | EXPORT_SYMBOL_GPL(system_nrt_wq); |
259 | EXPORT_SYMBOL_GPL(system_unbound_wq); | 260 | EXPORT_SYMBOL_GPL(system_unbound_wq); |
260 | EXPORT_SYMBOL_GPL(system_freezable_wq); | 261 | EXPORT_SYMBOL_GPL(system_freezable_wq); |
262 | EXPORT_SYMBOL_GPL(system_nrt_freezable_wq); | ||
261 | 263 | ||
262 | #define CREATE_TRACE_POINTS | 264 | #define CREATE_TRACE_POINTS |
263 | #include <trace/events/workqueue.h> | 265 | #include <trace/events/workqueue.h> |
@@ -3833,8 +3835,11 @@ static int __init init_workqueues(void) | |||
3833 | WQ_UNBOUND_MAX_ACTIVE); | 3835 | WQ_UNBOUND_MAX_ACTIVE); |
3834 | system_freezable_wq = alloc_workqueue("events_freezable", | 3836 | system_freezable_wq = alloc_workqueue("events_freezable", |
3835 | WQ_FREEZABLE, 0); | 3837 | WQ_FREEZABLE, 0); |
3838 | system_nrt_freezable_wq = alloc_workqueue("events_nrt_freezable", | ||
3839 | WQ_NON_REENTRANT | WQ_FREEZABLE, 0); | ||
3836 | BUG_ON(!system_wq || !system_long_wq || !system_nrt_wq || | 3840 | BUG_ON(!system_wq || !system_long_wq || !system_nrt_wq || |
3837 | !system_unbound_wq || !system_freezable_wq); | 3841 | !system_unbound_wq || !system_freezable_wq || |
3842 | !system_nrt_freezable_wq); | ||
3838 | return 0; | 3843 | return 0; |
3839 | } | 3844 | } |
3840 | early_initcall(init_workqueues); | 3845 | early_initcall(init_workqueues); |