4728c8
---
4728c8
 libmultipath/configure.c |   18 +++------------
4728c8
 libmultipath/devmapper.c |   55 +++++++++++++++++++++++++++++++++++++++++------
4728c8
 libmultipath/devmapper.h |    3 +-
4728c8
 3 files changed, 55 insertions(+), 21 deletions(-)
4728c8
4728c8
Index: multipath-tools-130222/libmultipath/configure.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/configure.c
4728c8
+++ multipath-tools-130222/libmultipath/configure.c
4728c8
@@ -616,7 +616,6 @@ extern int
4728c8
 domap (struct multipath * mpp, char * params)
4728c8
 {
4728c8
 	int r = 0;
4728c8
-	uint16_t udev_flags = ((mpp->force_udev_reload)? 0 : MPATH_UDEV_RELOAD_FLAG) | ((mpp->skip_kpartx == SKIP_KPARTX_ON)? MPATH_UDEV_NO_KPARTX_FLAG : 0) | ((mpp->nr_active)? 0 : MPATH_UDEV_NO_PATHS_FLAG);
4728c8
 
4728c8
 	/*
4728c8
 	 * last chance to quit before touching the devmaps
4728c8
@@ -660,17 +659,11 @@ domap (struct multipath * mpp, char * pa
4728c8
 		break;
4728c8
 
4728c8
 	case ACT_RELOAD:
4728c8
-		r = dm_addmap_reload(mpp, params);
4728c8
-		if (r)
4728c8
-			r = dm_simplecmd_noflush(DM_DEVICE_RESUME, mpp->alias,
4728c8
-						 udev_flags);
4728c8
+		r = dm_addmap_reload(mpp, params, 0);
4728c8
 		break;
4728c8
 
4728c8
 	case ACT_RESIZE:
4728c8
-		r = dm_addmap_reload(mpp, params);
4728c8
-		if (r)
4728c8
-			r = dm_simplecmd_flush(DM_DEVICE_RESUME, mpp->alias, 1,
4728c8
-					       udev_flags);
4728c8
+		r = dm_addmap_reload(mpp, params, 1);
4728c8
 		break;
4728c8
 
4728c8
 	case ACT_RENAME:
4728c8
@@ -679,11 +672,8 @@ domap (struct multipath * mpp, char * pa
4728c8
 
4728c8
 	case ACT_RENAME2:
4728c8
 		r = dm_rename(mpp->alias_old, mpp->alias, mpp->skip_kpartx);
4728c8
-		if (r) {
4728c8
-			r = dm_addmap_reload(mpp, params);
4728c8
-			if (r)
4728c8
-				r = dm_simplecmd_noflush(DM_DEVICE_RESUME, mpp->alias, udev_flags);
4728c8
-		}
4728c8
+		if (r)
4728c8
+			r = dm_addmap_reload(mpp, params, 0);
4728c8
 		break;
4728c8
 
4728c8
 	default:
4728c8
Index: multipath-tools-130222/libmultipath/devmapper.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/devmapper.c
4728c8
+++ multipath-tools-130222/libmultipath/devmapper.c
4728c8
@@ -356,15 +356,33 @@ dm_addmap_create (struct multipath *mpp,
4728c8
 #define ADDMAP_RO 1
4728c8
 
4728c8
 extern int
4728c8
-dm_addmap_reload (struct multipath *mpp, char *params) {
4728c8
+dm_addmap_reload (struct multipath *mpp, char *params, int flush) {
4728c8
+	int r = 0;
4728c8
+	uint16_t udev_flags = ((mpp->force_udev_reload)?
4728c8
+			       0 : MPATH_UDEV_RELOAD_FLAG) |
4728c8
+			      ((mpp->skip_kpartx == SKIP_KPARTX_ON)?
4728c8
+			       MPATH_UDEV_NO_KPARTX_FLAG : 0) |
4728c8
+			      ((mpp->nr_active)? 0 : MPATH_UDEV_NO_PATHS_FLAG);
4728c8
+
4728c8
 	sysfs_set_max_sectors_kb(mpp, 1);
4728c8
-	if (!mpp->force_readonly) {
4728c8
-		if (dm_addmap(DM_DEVICE_RELOAD, TGT_MPATH, mpp, params, 0, ADDMAP_RW, SKIP_KPARTX_OFF))
4728c8
-			return 1;
4728c8
-		if (errno != EROFS)
4728c8
+	if (!mpp->force_readonly)
4728c8
+		r = dm_addmap(DM_DEVICE_RELOAD, TGT_MPATH, mpp, params, 0,
4728c8
+			      ADDMAP_RW, SKIP_KPARTX_OFF);
4728c8
+	if (!r) {
4728c8
+		if (!mpp->force_readonly && errno != EROFS)
4728c8
 			return 0;
4728c8
+		r = dm_addmap(DM_DEVICE_RELOAD, TGT_MPATH, mpp, params, 0,
4728c8
+			      ADDMAP_RO, SKIP_KPARTX_OFF);
4728c8
 	}
4728c8
-	return dm_addmap(DM_DEVICE_RELOAD, TGT_MPATH, mpp, params, 0, ADDMAP_RO, SKIP_KPARTX_OFF);
4728c8
+	if (r)
4728c8
+		r = dm_simplecmd(DM_DEVICE_RESUME, mpp->alias, !flush,
4728c8
+				 1, udev_flags, 0);
4728c8
+	if (r)
4728c8
+		return r;
4728c8
+	if (dm_is_suspended(mpp->alias))
4728c8
+		dm_simplecmd(DM_DEVICE_RESUME, mpp->alias, !flush, 1,
4728c8
+			     udev_flags, 0);
4728c8
+	return 0;
4728c8
 }
4728c8
 
4728c8
 extern int
4728c8
@@ -613,6 +631,31 @@ dm_is_mpath(const char * name)
4728c8
 out:
4728c8
 	dm_task_destroy(dmt);
4728c8
 	return r;
4728c8
+}
4728c8
+
4728c8
+int
4728c8
+dm_is_suspended(const char *mapname)
4728c8
+{
4728c8
+	int r = -1;
4728c8
+	struct dm_task *dmt;
4728c8
+	struct dm_info info;
4728c8
+
4728c8
+	if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
4728c8
+		return r;
4728c8
+
4728c8
+	if (!dm_task_set_name(dmt, mapname))
4728c8
+		goto out;
4728c8
+
4728c8
+	if (!dm_task_run(dmt))
4728c8
+		goto out;
4728c8
+
4728c8
+	if (!dm_task_get_info(dmt, &info) || !info.exists)
4728c8
+		goto out;
4728c8
+
4728c8
+	r = info.suspended;
4728c8
+out:
4728c8
+	dm_task_destroy(dmt);
4728c8
+	return r;
4728c8
 }
4728c8
 
4728c8
 static int
4728c8
Index: multipath-tools-130222/libmultipath/devmapper.h
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/devmapper.h
4728c8
+++ multipath-tools-130222/libmultipath/devmapper.h
4728c8
@@ -30,7 +30,7 @@ int dm_drv_version (unsigned int * versi
4728c8
 int dm_simplecmd_flush (int, const char *, int, uint16_t);
4728c8
 int dm_simplecmd_noflush (int, const char *, uint16_t);
4728c8
 int dm_addmap_create (struct multipath *mpp, char *params);
4728c8
-int dm_addmap_reload (struct multipath *mpp, char *params);
4728c8
+int dm_addmap_reload (struct multipath *mpp, char *params, int flush);
4728c8
 int dm_map_present (const char *);
4728c8
 int dm_get_map(const char *, unsigned long long *, char *);
4728c8
 int dm_get_status(char *, char *);
4728c8
@@ -51,6 +51,7 @@ int dm_switchgroup(char * mapname, int i
4728c8
 int dm_enablegroup(char * mapname, int index);
4728c8
 int dm_disablegroup(char * mapname, int index);
4728c8
 int dm_get_maps (vector mp);
4728c8
+int dm_is_suspended(const char *mapname);
4728c8
 int dm_geteventnr (char *name);
4728c8
 int dm_get_major (char *name);
4728c8
 int dm_get_minor (char *name);