libmultipath: move suspend logic to _dm_flush_map
authorMartin Wilck <mwilck@suse.de>
Tue, 28 Feb 2017 16:23:11 +0000 (17:23 +0100)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Thu, 16 Mar 2017 07:04:52 +0000 (08:04 +0100)
commit79a05a4e86065a2395944eeb8e12691fc7e0e952
tree2c21a7aaf09d9fd72e79c720c650fe9ce5eadb69
parentd5308228aef9b5b7c8b1da5af490c3d9a2b13bdc
libmultipath: move suspend logic to _dm_flush_map

The function dm_suspend_and_flush() introduced in 9a4ff93
tries to remove child maps (partitions) after suspending
the mpath device. This may lock up if removing the partitions
requires I/O. It's better to use the following sequence
of actions: 1) clear queue_if_no_path; 2) remove partitions;
3) suspend; 4) remove (or resume and restore queue_if_no_path
in case of failure).

This patch modifies the implementation by moving the
queue_if_no_path/suspend logic into _dm_flush_map().
A call to _dm_flush_map() with need_suspend=1 replaces
the previous call to dm_suspend_and_flush().

With this change, the mpath device is only suspended after
removing partmaps, avoiding the deadlock.

Fixes: 9a4ff93 "Switch off 'queue_if_no_path' before removing maps"
Signed-off-by: Martin Wilck <mwilck@suse.com>
libmultipath/devmapper.c
libmultipath/devmapper.h