]> git.baikalelectronics.ru Git - kernel.git/commit
bdi: avoid oops on device removal
authorJan Kara <jack@suse.cz>
Thu, 3 Apr 2014 21:46:23 +0000 (14:46 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 3 Apr 2014 23:20:49 +0000 (16:20 -0700)
commit6c22a1c647218d4fdbfd5b75f107be58ace11073
tree5103d2779fbf2f1f07edb1ed51083d1303073ef9
parentdd5a7f77c72c60b262075d03e9834e722a2bfbed
bdi: avoid oops on device removal

After commit abf30af34232 ("writeback: replace custom worker pool
implementation with unbound workqueue") when device is removed while we
are writing to it we crash in bdi_writeback_workfn() ->
set_worker_desc() because bdi->dev is NULL.

This can happen because even though bdi_unregister() cancels all pending
flushing work, nothing really prevents new ones from being queued from
balance_dirty_pages() or other places.

Fix the problem by clearing BDI_registered bit in bdi_unregister() and
checking it before scheduling of any flushing work.

Fixes: abf30af3423229238a1326d20ea67c1a3a07451d
Reviewed-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Cc: Derek Basehore <dbasehore@chromium.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/fs-writeback.c
include/linux/backing-dev.h
mm/backing-dev.c