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

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