summaryrefslogtreecommitdiffstats
path: root/0086-RHBZ-681144-sysfs-device-cleanup.patch
blob: 315889267b14ea201a48803cf0a6114e07a8b958 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
---
 multipathd/cli_handlers.c |    2 +-
 multipathd/main.c         |   20 +++++++++++++-------
 multipathd/main.h         |    2 +-
 3 files changed, 15 insertions(+), 9 deletions(-)

Index: multipath-tools/multipathd/cli_handlers.c
===================================================================
--- multipath-tools.orig/multipathd/cli_handlers.c
+++ multipath-tools/multipathd/cli_handlers.c
@@ -416,7 +416,7 @@ cli_del_path (void * v, char ** reply, i
 
 	condlog(2, "%s: remove path (operator)", param);
 
-	return ev_remove_path(param, vecs);
+	return ev_remove_path(param, vecs, NULL);
 }
 
 int
Index: multipath-tools/multipathd/main.c
===================================================================
--- multipath-tools.orig/multipathd/main.c
+++ multipath-tools/multipathd/main.c
@@ -496,23 +496,25 @@ fail:
 static int
 uev_remove_path (struct sysfs_device * dev, struct vectors * vecs)
 {
-	int retval;
+	int retval, del_sysdev;
 
 	condlog(2, "%s: remove path (uevent)", dev->kernel);
-	retval = ev_remove_path(dev->kernel, vecs);
-	if (!retval)
+	retval = ev_remove_path(dev->kernel, vecs, &del_sysdev);
+	if (del_sysdev)
 		sysfs_device_put(dev);
 
 	return retval;
 }
 
 int
-ev_remove_path (char * devname, struct vectors * vecs)
+ev_remove_path (char * devname, struct vectors * vecs, int *del_sysdev)
 {
 	struct multipath * mpp;
 	struct path * pp;
 	int i, retval = 0;
 
+	if (del_sysdev)
+		*del_sysdev = 0;
 	pp = find_path_by_dev(vecs->pathvec, devname);
 
 	if (!pp) {
@@ -599,6 +601,10 @@ out:
 	if ((i = find_slot(vecs->pathvec, (void *)pp)) != -1)
 		vector_del_slot(vecs->pathvec, i);
 
+	if (pp->sysdev)
+		sysfs_device_put(pp->sysdev);
+	else if (del_sysdev)
+		*del_sysdev = 1;
 	free_path(pp);
 
 	return retval;
@@ -689,11 +695,11 @@ uev_trigger (struct uevent * uev, void *
 	if (uev_discard(uev->devpath))
 		return 0;
 
+	lock(vecs->lock);
+
 	sysdev = sysfs_device_get(uev->devpath);
 	if(!sysdev)
-		return 0;
-
-	lock(vecs->lock);
+		goto out;
 
 	/*
 	 * device map event
Index: multipath-tools/multipathd/main.h
===================================================================
--- multipath-tools.orig/multipathd/main.h
+++ multipath-tools/multipathd/main.h
@@ -5,7 +5,7 @@
 
 int reconfigure (struct vectors *);
 int ev_add_path (char *, struct vectors *);
-int ev_remove_path (char *, struct vectors *);
+int ev_remove_path (char *, struct vectors *, int *);
 int ev_add_map (struct sysfs_device *, struct vectors *);
 int ev_remove_map (char *, struct vectors *);
 void sync_map_state (struct multipath *);