We met an filesystem issue when do stable kernel upgrade from 3.10.31 to
3.10.53. And we found it's caused by the following commit bf0972039 which
introduced in 3.10.53.
After applying this patch, after system suspend/resume, plug out a SD card
will cause the following WARNING if SD card has a filesystem mounted.
If revert it, no such WARNING shows.

I also tried the latest linux-next tree, it also has such issue.

Looks the patch is used to fixing a potential system crashing.
We're not sure whether this WARNING is as expected and reasonable
or a BUG because there's no such WARNING before this patch.

After commit 839a8e8660b6 ("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.