dm: allocate a special workqueue for deferred device removal
authorMikulas Patocka <mpatocka@redhat.com>
Sat, 14 Jun 2014 17:44:31 +0000 (13:44 -0400)
committerMike Snitzer <snitzer@redhat.com>
Thu, 10 Jul 2014 20:44:13 +0000 (16:44 -0400)
commitacfe0ad74d2e1bfc81d1d7bf5e15b043985d3650
tree06543d0970d34acff9e4c52bab1691e73f0f132a
parent4c834452aad01531db949414f94f817a86348d59
dm: allocate a special workqueue for deferred device removal

The commit 2c140a246dc ("dm: allow remove to be deferred") introduced a
deferred removal feature for the device mapper.  When this feature is
used (by passing a flag DM_DEFERRED_REMOVE to DM_DEV_REMOVE_CMD ioctl)
and the user tries to remove a device that is currently in use, the
device will be removed automatically in the future when the last user
closes it.

Device mapper used the system workqueue to perform deferred removals.
However, some targets (dm-raid1, dm-mpath, dm-stripe) flush work items
scheduled for the system workqueue from their destructor.  If the
destructor itself is called from the system workqueue during deferred
removal, it introduces a possible deadlock - the workqueue tries to flush
itself.

Fix this possible deadlock by introducing a new workqueue for deferred
removals.  We allocate just one workqueue for all dm targets.  The
ability of dm targets to process IOs isn't dependent on deferred removal
of unused targets, so a deadlock due to shared workqueue isn't possible.

Also, cleanup local_init() to eliminate potential for returning success
on failure.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org # 3.13+
drivers/md/dm.c