]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commitf83c9614c33ba0e32319108d497f8160820889e0
tree06543d0970d34acff9e4c52bab1691e73f0f132a
parentec0a5ff0a2aa0111b438ab1c4b32d94c768c82d6
dm: allocate a special workqueue for deferred device removal

The commit 5a44612048f ("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