Blame SOURCES/0219-RHBZ-1448970-fix-resize.patch

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