Blame SOURCES/0159-UPBZ-1255885-udev-waits.patch

c896fb
---
c896fb
 kpartx/devmapper.c       |   41 ++++++++++++++++++++++++++++-------------
c896fb
 kpartx/devmapper.h       |    4 ++--
c896fb
 kpartx/kpartx.c          |   16 ++++++++--------
c896fb
 libmultipath/config.h    |    1 -
c896fb
 libmultipath/devmapper.c |   19 +++++++++++++------
c896fb
 multipath/main.c         |    2 --
c896fb
 6 files changed, 51 insertions(+), 32 deletions(-)
c896fb
c896fb
Index: multipath-tools-130222/kpartx/devmapper.c
c896fb
===================================================================
c896fb
--- multipath-tools-130222.orig/kpartx/devmapper.c
c896fb
+++ multipath-tools-130222/kpartx/devmapper.c
c896fb
@@ -14,13 +14,6 @@
c896fb
 #define MAX_PREFIX_LEN 8
c896fb
 #define PARAMS_SIZE 1024
c896fb
 
c896fb
-#ifndef LIBDM_API_COOKIE
c896fb
-static inline int dm_task_set_cookie(struct dm_task *dmt, uint32_t *c, int a)
c896fb
-{
c896fb
-	return 1;
c896fb
-}
c896fb
-#endif
c896fb
-
c896fb
 extern int
c896fb
 dm_prereq (char * str, int x, int y, int z)
c896fb
 {
c896fb
@@ -60,10 +53,13 @@ dm_prereq (char * str, int x, int y, int
c896fb
 }
c896fb
 
c896fb
 extern int
c896fb
-dm_simplecmd (int task, const char *name, int no_flush, uint32_t *cookie, uint16_t udev_flags) {
c896fb
+dm_simplecmd (int task, const char *name, int no_flush, uint16_t udev_flags) {
c896fb
 	int r = 0;
c896fb
 	int udev_wait_flag = (task == DM_DEVICE_RESUME ||
c896fb
 			      task == DM_DEVICE_REMOVE);
c896fb
+#ifdef LIBDM_API_COOKIE
c896fb
+	uint32_t cookie = 0;
c896fb
+#endif
c896fb
 	struct dm_task *dmt;
c896fb
 
c896fb
 	if (!(dmt = dm_task_create(task)))
c896fb
@@ -78,10 +74,17 @@ dm_simplecmd (int task, const char *name
c896fb
 	if (no_flush)
c896fb
 		dm_task_no_flush(dmt);
c896fb
 
c896fb
-	if (udev_wait_flag && !dm_task_set_cookie(dmt, cookie, ((udev_sync)? 0 : DM_UDEV_DISABLE_LIBRARY_FALLBACK) | udev_flags))
c896fb
+#ifdef LIBDM_API_COOKIE
c896fb
+	if (!udev_sync)
c896fb
+		udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK;
c896fb
+	if (udev_wait_flag && !dm_task_set_cookie(dmt, &cookie, udev_flags))
c896fb
 		goto out;
c896fb
+#endif
c896fb
 	r = dm_task_run(dmt);
c896fb
-
c896fb
+#ifdef LIBDM_API_COOKIE
c896fb
+	if (udev_wait_flag)
c896fb
+		dm_udev_wait(cookie);
c896fb
+#endif
c896fb
 	out:
c896fb
 	dm_task_destroy(dmt);
c896fb
 	return r;
c896fb
@@ -90,10 +93,14 @@ dm_simplecmd (int task, const char *name
c896fb
 extern int
c896fb
 dm_addmap (int task, const char *name, const char *target,
c896fb
 	   const char *params, uint64_t size, int ro, const char *uuid, int part,
c896fb
-	   mode_t mode, uid_t uid, gid_t gid, uint32_t *cookie) {
c896fb
+	   mode_t mode, uid_t uid, gid_t gid) {
c896fb
 	int r = 0;
c896fb
 	struct dm_task *dmt;
c896fb
 	char *prefixed_uuid = NULL;
c896fb
+#ifdef LIBDM_API_COOKIE
c896fb
+	uint32_t cookie = 0;
c896fb
+	uint16_t udev_flags = 0;
c896fb
+#endif
c896fb
 
c896fb
 	if (!(dmt = dm_task_create (task)))
c896fb
 		return 0;
c896fb
@@ -128,10 +135,18 @@ dm_addmap (int task, const char *name, c
c896fb
 
c896fb
 	dm_task_no_open_count(dmt);
c896fb
 
c896fb
-	if (task == DM_DEVICE_CREATE && !dm_task_set_cookie(dmt, cookie, (udev_sync)? 0 : DM_UDEV_DISABLE_LIBRARY_FALLBACK))
c896fb
+#ifdef LIBDM_API_COOKIE
c896fb
+	if (!udev_sync)
c896fb
+		udev_flags = DM_UDEV_DISABLE_LIBRARY_FALLBACK;
c896fb
+	if (task == DM_DEVICE_CREATE &&
c896fb
+	    !dm_task_set_cookie(dmt, &cookie, udev_flags))
c896fb
 		goto addout;
c896fb
+#endif
c896fb
 	r = dm_task_run (dmt);
c896fb
-
c896fb
+#ifdef LIBDM_API_COOKIE
c896fb
+	if (task == DM_DEVICE_CREATE)
c896fb
+			dm_udev_wait(cookie);
c896fb
+#endif
c896fb
 addout:
c896fb
 	dm_task_destroy (dmt);
c896fb
 	free(prefixed_uuid);
c896fb
Index: multipath-tools-130222/kpartx/devmapper.h
c896fb
===================================================================
c896fb
--- multipath-tools-130222.orig/kpartx/devmapper.h
c896fb
+++ multipath-tools-130222/kpartx/devmapper.h
c896fb
@@ -11,9 +11,9 @@
c896fb
 extern int udev_sync;
c896fb
 
c896fb
 int dm_prereq (char *, int, int, int);
c896fb
-int dm_simplecmd (int, const char *, int, uint32_t *, uint16_t);
c896fb
+int dm_simplecmd (int, const char *, int, uint16_t);
c896fb
 int dm_addmap (int, const char *, const char *, const char *, uint64_t,
c896fb
-	       int, const char *, int, mode_t, uid_t, gid_t, uint32_t *);
c896fb
+	       int, const char *, int, mode_t, uid_t, gid_t);
c896fb
 int dm_map_present (char *, char **);
c896fb
 char * dm_mapname(int major, int minor);
c896fb
 dev_t dm_get_first_dep(char *devname);
c896fb
Index: multipath-tools-130222/kpartx/kpartx.c
c896fb
===================================================================
c896fb
--- multipath-tools-130222.orig/kpartx/kpartx.c
c896fb
+++ multipath-tools-130222/kpartx/kpartx.c
c896fb
@@ -224,7 +224,6 @@ main(int argc, char **argv){
c896fb
 	int hotplug = 0;
c896fb
 	int loopcreated = 0;
c896fb
 	struct stat buf;
c896fb
-	uint32_t cookie = 0;
c896fb
 
c896fb
 	initpts();
c896fb
 	init_crc32();
c896fb
@@ -300,6 +299,8 @@ main(int argc, char **argv){
c896fb
 #ifdef LIBDM_API_COOKIE
c896fb
 	if (!udev_sync)
c896fb
 		dm_udev_set_sync_support(0);
c896fb
+	else
c896fb
+		dm_udev_set_sync_support(1);
c896fb
 #endif
c896fb
 
c896fb
 	if (dm_prereq(DM_TARGET, 0, 0, 0) && (what == ADD || what == DELETE || what == UPDATE)) {
c896fb
@@ -451,7 +452,7 @@ main(int argc, char **argv){
c896fb
 				}
c896fb
 
c896fb
 				if (!dm_simplecmd(DM_DEVICE_REMOVE, partname,
c896fb
-						  0, &cookie, 0)) {
c896fb
+						  0, 0)) {
c896fb
 					r++;
c896fb
 					continue;
c896fb
 				}
c896fb
@@ -508,7 +509,7 @@ main(int argc, char **argv){
c896fb
 				if (!dm_addmap(op, partname, DM_TARGET, params,
c896fb
 					       slices[j].size, ro, uuid, j+1,
c896fb
 					       buf.st_mode & 0777, buf.st_uid,
c896fb
-					       buf.st_gid, &cookie)) {
c896fb
+					       buf.st_gid)) {
c896fb
 					fprintf(stderr, "create/reload failed on %s\n",
c896fb
 						partname);
c896fb
 					r++;
c896fb
@@ -516,12 +517,13 @@ main(int argc, char **argv){
c896fb
 				}
c896fb
 				if (op == DM_DEVICE_RELOAD &&
c896fb
 				    !dm_simplecmd(DM_DEVICE_RESUME, partname,
c896fb
-						  1, &cookie, MPATH_UDEV_RELOAD_FLAG)) {
c896fb
+						  1, MPATH_UDEV_RELOAD_FLAG)) {
c896fb
 					fprintf(stderr, "resume failed on %s\n",
c896fb
 						partname);
c896fb
 					r++;
c896fb
 					continue;
c896fb
 				}
c896fb
+
c896fb
 				dm_devn(partname, &slices[j].major,
c896fb
 					&slices[j].minor);
c896fb
 
c896fb
@@ -560,7 +562,7 @@ main(int argc, char **argv){
c896fb
 				}
c896fb
 
c896fb
 				if (!dm_simplecmd(DM_DEVICE_REMOVE,
c896fb
-						  partname, 1, &cookie, 0)) {
c896fb
+						  partname, 1, 0)) {
c896fb
 					r++;
c896fb
 					continue;
c896fb
 				}
c896fb
@@ -586,9 +588,7 @@ main(int argc, char **argv){
c896fb
 		}
c896fb
 		printf("loop deleted : %s\n", device);
c896fb
 	}
c896fb
-#ifdef LIBDM_API_COOKIE
c896fb
-	dm_udev_wait(cookie);
c896fb
-#endif
c896fb
+
c896fb
 	dm_lib_release();
c896fb
 	dm_lib_exit();
c896fb
 
c896fb
Index: multipath-tools-130222/libmultipath/config.h
c896fb
===================================================================
c896fb
--- multipath-tools-130222.orig/libmultipath/config.h
c896fb
+++ multipath-tools-130222/libmultipath/config.h
c896fb
@@ -129,7 +129,6 @@ struct config {
c896fb
 	uid_t uid;
c896fb
 	gid_t gid;
c896fb
 	mode_t mode;
c896fb
-	uint32_t cookie;
c896fb
 	int reassign_maps;
c896fb
 	int retain_hwhandler;
c896fb
 	int detect_prio;
c896fb
Index: multipath-tools-130222/libmultipath/devmapper.c
c896fb
===================================================================
c896fb
--- multipath-tools-130222.orig/libmultipath/devmapper.c
c896fb
+++ multipath-tools-130222/libmultipath/devmapper.c
c896fb
@@ -215,6 +215,7 @@ dm_simplecmd (int task, const char *name
c896fb
 	int r = 0;
c896fb
 	int udev_wait_flag = (need_sync && (task == DM_DEVICE_RESUME ||
c896fb
 					    task == DM_DEVICE_REMOVE));
c896fb
+	uint32_t cookie = 0;
c896fb
 	struct dm_task *dmt;
c896fb
 
c896fb
 	if (!(dmt = dm_task_create (task)))
c896fb
@@ -233,10 +234,12 @@ dm_simplecmd (int task, const char *name
c896fb
 	if (do_deferred(deferred_remove))
c896fb
 		dm_task_deferred_remove(dmt);
c896fb
 #endif
c896fb
-	if (udev_wait_flag && !dm_task_set_cookie(dmt, &conf->cookie, ((conf->daemon)? DM_UDEV_DISABLE_LIBRARY_FALLBACK : 0) | udev_flags))
c896fb
+	if (udev_wait_flag && !dm_task_set_cookie(dmt, &cookie, ((conf->daemon)? DM_UDEV_DISABLE_LIBRARY_FALLBACK : 0) | udev_flags))
c896fb
 		goto out;
c896fb
 	r = dm_task_run (dmt);
c896fb
 
c896fb
+	if (udev_wait_flag)
c896fb
+			udev_wait(cookie);
c896fb
 	out:
c896fb
 	dm_task_destroy (dmt);
c896fb
 	return r;
c896fb
@@ -264,6 +267,7 @@ dm_addmap (int task, const char *target,
c896fb
 	int r = 0;
c896fb
 	struct dm_task *dmt;
c896fb
 	char *prefixed_uuid = NULL;
c896fb
+	uint32_t cookie = 0;
c896fb
 
c896fb
 	if (!(dmt = dm_task_create (task)))
c896fb
 		return 0;
c896fb
@@ -304,10 +308,12 @@ dm_addmap (int task, const char *target,
c896fb
 	dm_task_no_open_count(dmt);
c896fb
 
c896fb
 	if (task == DM_DEVICE_CREATE &&
c896fb
-	    !dm_task_set_cookie(dmt, &conf->cookie, (conf->daemon)? DM_UDEV_DISABLE_LIBRARY_FALLBACK : 0))
c896fb
+	    !dm_task_set_cookie(dmt, &cookie, (conf->daemon)? DM_UDEV_DISABLE_LIBRARY_FALLBACK : 0))
c896fb
 		goto freeout;
c896fb
 	r = dm_task_run (dmt);
c896fb
 
c896fb
+	if (task == DM_DEVICE_CREATE)
c896fb
+			udev_wait(cookie);
c896fb
 	freeout:
c896fb
 	if (prefixed_uuid)
c896fb
 		FREE(prefixed_uuid);
c896fb
@@ -1366,6 +1372,7 @@ dm_rename (const char * old, char * new)
c896fb
 {
c896fb
 	int r = 0;
c896fb
 	struct dm_task *dmt;
c896fb
+	uint32_t cookie;
c896fb
 
c896fb
 	if (dm_rename_partmaps(old, new))
c896fb
 		return r;
c896fb
@@ -1381,12 +1388,12 @@ dm_rename (const char * old, char * new)
c896fb
 
c896fb
 	dm_task_no_open_count(dmt);
c896fb
 
c896fb
-	if (!dm_task_set_cookie(dmt, &conf->cookie, (conf->daemon)? DM_UDEV_DISABLE_LIBRARY_FALLBACK : 0))
c896fb
-		goto out;
c896fb
-	if (!dm_task_run(dmt))
c896fb
+	if (!dm_task_set_cookie(dmt, &cookie, (conf->daemon)? DM_UDEV_DISABLE_LIBRARY_FALLBACK : 0))
c896fb
 		goto out;
c896fb
+	r = dm_task_run(dmt);
c896fb
+
c896fb
+	udev_wait(cookie);
c896fb
 
c896fb
-	r = 1;
c896fb
 out:
c896fb
 	dm_task_destroy(dmt);
c896fb
 	return r;
c896fb
Index: multipath-tools-130222/multipath/main.c
c896fb
===================================================================
c896fb
--- multipath-tools-130222.orig/multipath/main.c
c896fb
+++ multipath-tools-130222/multipath/main.c
c896fb
@@ -681,8 +681,6 @@ main (int argc, char *argv[])
c896fb
 		condlog(3, "restart multipath configuration process");
c896fb
 
c896fb
 out:
c896fb
-	udev_wait(conf->cookie);
c896fb
-
c896fb
 	dm_lib_release();
c896fb
 	dm_lib_exit();
c896fb