Blame SOURCES/0230-UP-allow-invalid-creates.patch

4728c8
---
4728c8
 libmultipath/devmapper.c |   31 +++++++++++++++++++++----------
4728c8
 1 file changed, 21 insertions(+), 10 deletions(-)
4728c8
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
@@ -264,12 +264,15 @@ dm_device_remove (const char *name, int
4728c8
 
4728c8
 static int
4728c8
 dm_addmap (int task, const char *target, struct multipath *mpp, char * params,
4728c8
-	   int use_uuid, int ro, int skip_kpartx) {
4728c8
+	   int use_uuid, int ro, uint16_t udev_flags) {
4728c8
 	int r = 0;
4728c8
 	struct dm_task *dmt;
4728c8
 	char *prefixed_uuid = NULL;
4728c8
 	uint32_t cookie = 0;
4728c8
-	uint16_t udev_flags = ((conf->daemon)? DM_UDEV_DISABLE_LIBRARY_FALLBACK : 0) | ((skip_kpartx == SKIP_KPARTX_ON)? MPATH_UDEV_NO_KPARTX_FLAG : 0);
4728c8
+
4728c8
+	/* Need to add this here to allow 0 to be passed in udev_flags */
4728c8
+	if (conf->daemon)
4728c8
+		udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK;
4728c8
 
4728c8
 	if (!(dmt = dm_task_create (task)))
4728c8
 		return 0;
4728c8
@@ -326,16 +329,28 @@ dm_addmap (int task, const char *target,
4728c8
 	return r;
4728c8
 }
4728c8
 
4728c8
+static uint16_t build_udev_flags(const struct multipath *mpp, int reload)
4728c8
+{
4728c8
+	/* DM_UDEV_DISABLE_LIBRARY_FALLBACK is added in dm_addmap */
4728c8
+	return  (mpp->skip_kpartx == SKIP_KPARTX_ON ?
4728c8
+		 MPATH_UDEV_NO_KPARTX_FLAG : 0) |
4728c8
+		(mpp->nr_active == 0 ?
4728c8
+		 MPATH_UDEV_NO_PATHS_FLAG : 0) |
4728c8
+		(reload && !mpp->force_udev_reload ?
4728c8
+		 MPATH_UDEV_RELOAD_FLAG : 0);
4728c8
+}
4728c8
+
4728c8
 extern int
4728c8
 dm_addmap_create (struct multipath *mpp, char * params) {
4728c8
 	int ro;
4728c8
+	uint16_t udev_flags = build_udev_flags(mpp, 0);
4728c8
 
4728c8
 	sysfs_set_max_sectors_kb(mpp, 0);
4728c8
 	for (ro = 0; ro <= 1; ro++) {
4728c8
 		int err;
4728c8
 
4728c8
 		if (dm_addmap(DM_DEVICE_CREATE, TGT_MPATH,
4728c8
-			      mpp, params, 1, ro, mpp->skip_kpartx))
4728c8
+			      mpp, params, 1, ro, udev_flags))
4728c8
 			return 1;
4728c8
 		/*
4728c8
 		 * DM_DEVICE_CREATE is actually DM_DEV_CREATE + DM_TABLE_LOAD.
4728c8
@@ -358,21 +373,17 @@ dm_addmap_create (struct multipath *mpp,
4728c8
 extern int
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
+	uint16_t udev_flags = build_udev_flags(mpp, 1);
4728c8
 
4728c8
 	sysfs_set_max_sectors_kb(mpp, 1);
4728c8
 	if (!mpp->force_readonly)
4728c8
 		r = dm_addmap(DM_DEVICE_RELOAD, TGT_MPATH, mpp, params, 0,
4728c8
-			      ADDMAP_RW, SKIP_KPARTX_OFF);
4728c8
+			      ADDMAP_RW, 0);
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
+			      ADDMAP_RO, 0);
4728c8
 	}
4728c8
 	if (r)
4728c8
 		r = dm_simplecmd(DM_DEVICE_RESUME, mpp->alias, !flush,