summaryrefslogtreecommitdiffstats
path: root/0034-RHBZ-579575-add-q-multipath-option.patch
blob: 7d856784180fe924f21d207f1f1f1c48468eefd1 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
---
 libmultipath/config.h    |    1 +
 libmultipath/configure.c |    6 +++++-
 libmultipath/file.c      |   32 ++++++++++++++++++++++++++++++++
 libmultipath/file.h      |    1 +
 multipath/main.c         |    8 ++++++--
 5 files changed, 45 insertions(+), 3 deletions(-)

Index: multipath-tools/libmultipath/config.h
===================================================================
--- multipath-tools.orig/libmultipath/config.h
+++ multipath-tools/libmultipath/config.h
@@ -87,6 +87,7 @@ struct config {
 	int fast_io_fail;
 	unsigned int dev_loss;
 	int find_multipaths;
+	int allow_queueing;
 	uid_t uid;
 	gid_t gid;
 	mode_t mode;
Index: multipath-tools/libmultipath/configure.c
===================================================================
--- multipath-tools.orig/libmultipath/configure.c
+++ multipath-tools/libmultipath/configure.c
@@ -36,6 +36,7 @@
 #include "prio.h"
 #include "util.h"
 #include "finder.h"
+#include "file.h"
 
 extern int
 setup_map (struct multipath * mpp)
@@ -567,7 +568,10 @@ coalesce_paths (struct vectors * vecs, v
 		if (r == DOMAP_DRY)
 			continue;
 
-		if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF) {
+		if (!conf->daemon && !conf->allow_queueing &&
+		    !pidfile_check(DEFAULT_PIDFILE))
+			dm_queue_if_no_path(mpp->alias, 0);
+		else if (mpp->no_path_retry != NO_PATH_RETRY_UNDEF) {
 			if (mpp->no_path_retry == NO_PATH_RETRY_FAIL)
 				dm_queue_if_no_path(mpp->alias, 0);
 			else
Index: multipath-tools/multipath/main.c
===================================================================
--- multipath-tools.orig/multipath/main.c
+++ multipath-tools/multipath/main.c
@@ -80,7 +80,7 @@ usage (char * progname)
 {
 	fprintf (stderr, VERSION_STRING);
 	fprintf (stderr, "Usage:\n");
-	fprintf (stderr, "  %s [-c] [-d] [-r] [-v lvl] [-p pol] [-b fil] [dev]\n", progname);
+	fprintf (stderr, "  %s [-c] [-d] [-r] [-v lvl] [-p pol] [-b fil] [-q] [dev]\n", progname);
 	fprintf (stderr, "  %s -l|-ll|-f [-v lvl] [-b fil] [dev]\n", progname);
 	fprintf (stderr, "  %s -F [-v lvl]\n", progname);
 	fprintf (stderr, "  %s -h\n", progname);
@@ -93,6 +93,7 @@ usage (char * progname)
 		"  -f      flush a multipath device map\n" \
 		"  -F      flush all multipath device maps\n" \
 		"  -c      check if a device should be a path in a multipath device\n" \
+		"  -q      allow queue_if_no_path when multipathd is not running\n"\
 		"  -d      dry run, do not create or update devmaps\n" \
 		"  -r      force devmap reload\n" \
 		"  -p      policy failover|multibus|group_by_serial|group_by_prio\n" \
@@ -362,7 +363,7 @@ main (int argc, char *argv[])
 		condlog(0, "multipath tools need sysfs mounted");
 		exit(1);
 	}
-	while ((arg = getopt(argc, argv, ":dchl::FfM:v:p:b:r")) != EOF ) {
+	while ((arg = getopt(argc, argv, ":dchl::FfM:v:p:b:rq")) != EOF ) {
 		switch(arg) {
 		case 1: printf("optarg : %s\n",optarg);
 			break;
@@ -379,6 +380,9 @@ main (int argc, char *argv[])
 		case 'c':
 			conf->dry_run = 2;
 			break;
+		case 'q':
+			conf->allow_queueing = 1;
+			break;
 		case 'd':
 			if (!conf->dry_run)
 				conf->dry_run = 1;
Index: multipath-tools/libmultipath/file.c
===================================================================
--- multipath-tools.orig/libmultipath/file.c
+++ multipath-tools/libmultipath/file.c
@@ -176,3 +176,35 @@ fail:
 	close(fd);
 	return -1;
 }
+
+int pidfile_check(const char *file)
+{
+	int fd;
+	struct flock lock;
+
+	fd = open(file, O_RDONLY);
+	if (fd < 0) {
+		if (errno == ENOENT)
+			return 0;
+		condlog(0, "Cannot open pidfile, %s : %s", file,
+			strerror(errno));
+		return -1;
+	}
+	lock.l_type = F_WRLCK;
+	lock.l_start = 0;
+	lock.l_whence = SEEK_SET;
+	lock.l_len = 0;
+
+	if (fcntl(fd, F_GETLK, &lock) < 0) {
+		condlog(0, "Cannot check lock on pidfile, %s : %s", file,
+			strerror(errno));
+		return -1;
+	}
+	close(fd);
+	if (lock.l_type == F_UNLCK)
+		return 0;
+	return 1;
+}
+
+
+
Index: multipath-tools/libmultipath/file.h
===================================================================
--- multipath-tools.orig/libmultipath/file.h
+++ multipath-tools/libmultipath/file.h
@@ -7,5 +7,6 @@
 
 #define FILE_TIMEOUT 30
 int open_file(char *file, int *can_write, char *header);
+int pidfile_check(const char *file);
 
 #endif /* _FILE_H */