summaryrefslogtreecommitdiffstats
path: root/0005-RH-add-mpathconf.patch
blob: 89ab3a30e6c501fc065b2f27e2de6a66bdb0b789 (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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
---
 libmultipath/config.c |    3 
 multipath/Makefile    |    5 
 multipath/main.c      |    4 
 multipath/mpathconf   |  312 ++++++++++++++++++++++++++++++++++++++++++++++++++
 multipath/mpathconf.8 |  103 ++++++++++++++++
 5 files changed, 423 insertions(+), 4 deletions(-)

Index: multipath-tools-130222/libmultipath/config.c
===================================================================
--- multipath-tools-130222.orig/libmultipath/config.c
+++ multipath-tools-130222/libmultipath/config.c
@@ -587,8 +587,7 @@ load_config (char * file)
 	} else {
 		init_keywords();
 		condlog(0, "/etc/multipath.conf does not exist, blacklisting all devices.");
-		condlog(0, "A default multipath.conf file is located at");
-		condlog(0, "/usr/share/doc/device-mapper-multipath-%d.%d.%d/multipath.conf", MULTIPATH_VERSION(VERSION_CODE));
+		condlog(0, "run \"/sbin/mpathconf --enable\" to create a default /etc/multipath.conf");
 		if (conf->blist_devnode == NULL) {
 			conf->blist_devnode = vector_alloc();
 			if (!conf->blist_devnode) {
Index: multipath-tools-130222/multipath/Makefile
===================================================================
--- multipath-tools-130222.orig/multipath/Makefile
+++ multipath-tools-130222/multipath/Makefile
@@ -17,22 +17,27 @@ $(EXEC): $(OBJS)
 	$(CC) $(CFLAGS) $(OBJS) -o $(EXEC) $(LDFLAGS)
 	$(GZIP) $(EXEC).8 > $(EXEC).8.gz
 	$(GZIP) $(EXEC).conf.5 > $(EXEC).conf.5.gz
+	$(GZIP) mpathconf.8 > mpathconf.8.gz
 
 install:
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir)
 	$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/
+	$(INSTALL_PROGRAM) -m 755 mpathconf $(DESTDIR)$(bindir)/
 	$(INSTALL_PROGRAM) -d $(DESTDIR)/lib/udev/rules.d
 	$(INSTALL_PROGRAM) -m 644 multipath.rules $(DESTDIR)/lib/udev/rules.d/62-multipath.rules
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).8.gz $(DESTDIR)$(mandir)
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(man5dir)
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).conf.5.gz $(DESTDIR)$(man5dir)
+	$(INSTALL_PROGRAM) -m 644 mpathconf.8.gz $(DESTDIR)$(mandir)
 
 uninstall:
 	rm $(DESTDIR)/lib/udev/rules.d/62-multipath.rules
 	rm $(DESTDIR)$(bindir)/$(EXEC)
+	rm $(DESTDIR)$(bindir)/mpathconf
 	rm $(DESTDIR)$(mandir)/$(EXEC).8.gz
 	rm $(DESTDIR)$(man5dir)/$(EXEC).conf.5.gz
+	rm $(DESTDIR)$(mandir)/mpathconf.8.gz
 
 clean:
 	rm -f core *.o $(EXEC) *.gz
Index: multipath-tools-130222/multipath/main.c
===================================================================
--- multipath-tools-130222.orig/multipath/main.c
+++ multipath-tools-130222/multipath/main.c
@@ -433,10 +433,10 @@ main (int argc, char *argv[])
 		exit(1);
 	}
 
-	if (dm_prereq())
+	if (load_config(DEFAULT_CONFIGFILE))
 		exit(1);
 
-	if (load_config(DEFAULT_CONFIGFILE))
+	if (dm_prereq())
 		exit(1);
 
 	while ((arg = getopt(argc, argv, ":dchl::FfM:v:p:b:Brtq")) != EOF ) {
Index: multipath-tools-130222/multipath/mpathconf
===================================================================
--- /dev/null
+++ multipath-tools-130222/multipath/mpathconf
@@ -0,0 +1,312 @@
+#!/bin/sh
+#
+# Copyright (C) 2010 Red Hat, Inc. All rights reserved.
+#
+# This file is part of the device-mapper-multipath package.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+#
+# Simple editting of /etc/multipath.conf
+# This program was largely ripped off from lvmconf
+#
+
+unset ENABLE FIND FRIENDLY MODULE MULTIPATHD HAVE_DISABLE HAVE_FIND HAVE_BLACKLIST HAVE_DEFAULTS HAVE_FRIENDLY HAVE_MULTIPATHD HAVE_MODULE SHOW_STATUS CHANGED_CONFIG
+
+DEFAULT_CONFIGFILE="/usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf"
+CONFIGFILE="/etc/multipath.conf"
+MULTIPATHDIR="/etc/multipath"
+TMPFILE=/etc/multipath/.multipath.conf.tmp
+
+function usage
+{
+	echo "usage: $0 <command>"
+	echo ""
+	echo "Commands:"
+	echo "Enable: --enable "
+	echo "Disable: --disable"
+	echo "Set user_friendly_names (Default n): --user_friendly_names <y|n>"
+	echo "Set find_multipaths (Default n): --find_multipaths <y|n>"
+	echo "Load the dm-multipath modules on enable (Default y): --with_module <y|n>"
+	echo "start/stop/reload multipathd (Default n): --with_multipathd <y|n>"
+	echo ""
+}
+
+function parse_args
+{
+	while [ -n "$1" ]; do
+		case $1 in
+			--enable)
+				ENABLE=1
+				shift
+				;;
+			--disable)
+				ENABLE=0
+				shift
+				;;
+			--user_friendly_names)
+				if [ -n "$2" ]; then
+					FRIENDLY=$2
+					shift 2
+				else
+					usage
+					exit 1
+				fi
+				;;
+			--find_multipaths)
+				if [ -n "$2" ]; then
+					FIND=$2
+					shift 2
+				else
+					usage
+					exit 1
+				fi
+				;;
+			--with_module)
+				if [ -n "$2" ]; then
+					MODULE=$2
+					shift 2
+				else
+					usage
+					exit 1
+				fi
+				;;
+			--with_multipathd)
+				if [ -n "$2" ]; then
+					MULTIPATHD=$2
+					shift 2
+				else
+					usage
+					exit 1
+				fi
+				;;
+			*)
+				usage
+				exit
+		esac
+	done
+}
+
+function validate_args
+{
+	if [ "$ENABLE" = "0" ] && [ -n "$FRIENDLY" -o -n "$FIND" -o -n "$MODULE" ]; then
+		echo "ignoring extra parameters on disable"
+		FRIENDLY=""
+		FIND=""
+		MODULE=""
+	fi
+	if [ -n "$FRIENDLY" ] && [ "$FRIENDLY" != "y" -a "$FRIENDLY" != "n" ]; then
+		echo "--user_friendly_names must be either 'y' or 'n'"
+		exit 1
+	fi
+	if [ -n "$FIND" ] && [ "$FIND" != "y" -a "$FIND" != "n" ]; then
+		echo "--find_multipaths must be either 'y' or 'n'"
+		exit 1
+	fi
+	if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" ]; then
+		SHOW_STATUS=1
+	fi
+	if [ -n "$MODULE" ] && [ "$MODULE" != "y" -a "$MODULE" != "n" ]; then
+		echo "--with_module must be either 'y' or 'n'"
+		exit 1
+	fi
+	if [ -n "$MULTIPATHD" ] && [ "$MULTIPATHD" != "y" -a "$MULTIPATHD" != "n" ]; then
+		echo "--with_multipathd must be either 'y' or 'n'"
+		exit 1
+	fi
+}
+
+umask 0077
+
+parse_args "$@"
+
+validate_args
+
+if [ ! -d "$MULTIPATHDIR" ]; then
+	echo "/etc/multipath/ does not exist. failing"
+	exit 1
+fi
+
+rm $TMPFILE 2> /dev/null
+if [ -f "$CONFIGFILE" ]; then
+	cp $CONFIGFILE $TMPFILE
+elif [ -f "$DEFAULT_CONFIGFILE" ]; then
+	cp $DEFAULT_CONFIGFILE $TMPFILE
+else
+	touch $TMPFILE
+fi
+
+if grep -q "^blacklist[[:space:]]*{" $TMPFILE ; then
+	HAVE_BLACKLIST=1
+fi
+
+if grep -q "^defaults[[:space:]]*{" $TMPFILE ; then
+	HAVE_DEFAULTS=1
+fi
+
+if [ -z "$MODULE" -o "$MODULE" = "y" ]; then
+	if lsmod | grep -q "dm_multipath" ; then
+		HAVE_MODULE=1
+	else
+		HAVE_MODULE=0
+	fi
+fi
+
+if [ "$MULTIPATHD" = "y" ]; then
+	if service multipathd status > /dev/null ; then
+		HAVE_MULTIPATHD=1
+	else
+		HAVE_MULTIPATHD=0
+	fi
+fi
+
+if [ "$HAVE_BLACKLIST" = "1" ]; then
+	if sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*devnode \"\.\?\*\"" ; then
+		HAVE_DISABLE=1
+	elif sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[#[:space:]]*devnode \"\.\?\*\"" ; then
+		HAVE_DISABLE=0
+	fi
+fi
+
+if [ "$HAVE_DEFAULTS" = "1" ]; then
+	if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*find_multipaths[[:space:]]*\(yes\|1\)" ; then
+		HAVE_FIND=1
+	elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*find_multipaths[[:space:]]*\(no\|0\)" ; then
+		HAVE_FIND=0
+	fi
+	if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]]*\(yes\|1\)" ; then
+		HAVE_FRIENDLY=1
+	elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]]*\(no\|0\)" ; then
+		HAVE_FRIENDLY=0
+	fi
+fi
+
+if [ -n "$SHOW_STATUS" ]; then
+	if [ -z "$HAVE_DISABLE" -o "$HAVE_DISABLE" = 0 ]; then
+		echo "multipath is enabled"
+	else
+		echo "multipath is disabled"
+	fi
+	if [ -z "$HAVE_FIND"  -o "$HAVE_FIND" = 0 ]; then
+		echo "find_multipaths is disabled"
+	else
+		echo "find_multipaths is enabled"
+	fi
+	if [ -z "$HAVE_FRIENDLY" -o "$HAVE_FRIENDLY" = 0 ]; then
+		echo "user_friendly_names is disabled"
+	else
+		echo "user_friendly_names is enabled"
+	fi
+	if [ -n "$HAVE_MODULE" ]; then
+		if [ "$HAVE_MODULE" = 1 ]; then
+			echo "dm_multipath module is loaded"
+		else
+			echo "dm_multipath module is not loaded"
+		fi
+	fi
+	if [ -n "$HAVE_MULTIPATHD" ]; then
+		service multipathd status
+	fi
+	exit 0
+fi
+
+if [ -z "$HAVE_BLACKLIST" ]; then
+	cat >> $TMPFILE <<- _EOF_
+
+blacklist {
+}
+_EOF_
+fi
+
+if [ -z "$HAVE_DEFAULTS" ]; then
+	cat >> $TMPFILE <<- _EOF_
+
+defaults {
+}
+_EOF_
+fi
+
+if [ "$ENABLE" = 1 ]; then
+	if [ "$HAVE_DISABLE" = 1 ]; then
+		sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*devnode \"\.\?\*\"/#	devnode ".*"/' $TMPFILE
+	fi
+elif [ "$ENABLE" = 0 ]; then
+	if [ -z "$HAVE_DISABLE" ]; then
+		sed -i '/^blacklist[[:space:]]*{/ a\
+	devnode "*"
+' $TMPFILE
+	elif [ "$HAVE_DISABLE" = 0 ]; then
+		sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*#[#[:space:]]*devnode \"\.\?\*\"/	devnode ".*"/' $TMPFILE
+	fi
+fi
+
+if [ "$FIND" = "n" ]; then
+	if [ "$HAVE_FIND" = 1 ]; then
+		sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*find_multipaths[[:space:]]*\(yes\|1\)/	find_multipaths no/' $TMPFILE
+		CHANGED_CONFIG=1
+	fi
+elif [ "$FIND" = "y" ]; then
+	if [ -z "$HAVE_FIND" ]; then
+		sed -i '/^defaults[[:space:]]*{/ a\
+	find_multipaths yes
+' $TMPFILE
+		CHANGED_CONFIG=1
+	elif [ "$HAVE_FIND" = 0 ]; then
+		sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*find_multipaths[[:space:]]*\(no\|0\)/	find_multipaths yes/' $TMPFILE
+		CHANGED_CONFIG=1
+	fi
+fi
+
+if [ "$FRIENDLY" = "n" ]; then
+	if [ "$HAVE_FRIENDLY" = 1 ]; then
+		sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*user_friendly_names[[:space:]]*\(yes\|1\)/	user_friendly_names no/' $TMPFILE
+		CHANGED_CONFIG=1
+	fi
+elif [ "$FRIENDLY" = "y" ]; then
+	if [ -z "$HAVE_FRIENDLY" ]; then
+		sed -i '/^defaults[[:space:]]*{/ a\
+	user_friendly_names yes
+' $TMPFILE
+		CHANGED_CONFIG=1
+	elif [ "$HAVE_FRIENDLY" = 0 ]; then
+		sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*user_friendly_names[[:space:]]*\(no\|0\)/	user_friendly_names yes/' $TMPFILE
+		CHANGED_CONFIG=1
+	fi
+fi
+
+if [ -f "$CONFIGFILE" ]; then
+	cp $CONFIGFILE $CONFIGFILE.old
+	if [ $? != 0 ]; then
+		echo "failed to backup old config file, $CONFIGFILE not updated"
+		exit 1
+	fi
+fi
+
+cp $TMPFILE $CONFIGFILE
+if [ $? != 0 ]; then
+	echo "failed to copy new config file into place, check $CONFIGFILE is still OK"
+	exit 1
+fi
+
+rm -f $TMPFILE
+
+if [ "$ENABLE" = 1 ]; then
+	if [ "$HAVE_MODULE" = 0 ]; then
+		modprobe dm_multipath
+	fi
+	if [ "$HAVE_MULTIPATHD" = 0 ]; then
+		service multipathd start
+	fi
+elif [ "$ENABLE" = 0 ]; then
+	if [ "$HAVE_MULTIPATHD" = 1 ]; then
+		service multipathd stop
+	fi
+elif [ -n "$CHANGED_CONFIG" -a "$HAVE_MULTIPATHD" = 1 ]; then
+	service multipathd reload
+fi
Index: multipath-tools-130222/multipath/mpathconf.8
===================================================================
--- /dev/null
+++ multipath-tools-130222/multipath/mpathconf.8
@@ -0,0 +1,103 @@
+.TH MPATHCONF 8 "June 2010" "" "Linux Administrator's Manual"
+.SH NAME
+mpathconf - A tool for configuring device-mapper-multipath
+.SH SYNOPSIS
+.B mpathconf
+.RB [\| commands \|]
+.RB [\| options \|]
+.SH DESCRIPTION
+.B mpathconf
+is a utility that creates or modifies
+.B /etc/multipath.conf.
+It can enable or disable multipathing and configure some common options.
+.B mpathconf
+can also load the
+.B dm_multipath
+module, start and stop the
+.B multipathd
+daemon, and configure the
+.B multipathd
+service to start automatically or not. If
+.B mpathconf
+is called with no commands, it will display the current configuration.
+
+The default options for mpathconf are
+.B --with_module
+The
+.B --with_multipathd
+option is not set by default.  Enabling multipathing will load the
+.B dm_multipath
+module but it will not immediately start it. This is so
+that users can manually edit their config file if necessary, before starting
+.B multipathd.
+
+If
+.B /etc/multipath.conf
+already exists, mpathconf will edit it. If it does not exist, mpathconf will
+use
+.B /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf
+as the starting file. This file has
+.B user_friendly_names
+set. If this file does not exist, mpathconf will create
+.B /etc/multipath.conf
+from scratch.  For most users, this means that
+.B user_friendly_names
+will be set by default, unless they use the
+.B --user_friendly_names n
+command.
+.SH COMMANDS
+.TP
+.B --enable
+Removes any line that blacklists all device nodes from the
+.B /etc/multipath.conf
+blacklist section.
+.TP
+.B --disable
+Adds a line that blacklists all device nodes to the
+.B /etc/multipath.conf
+blacklist section. If no blacklist section exists, it will create one.
+.TP
+.B --user_friendly_name \fP { \fBy\fP | \fBn\fP }
+If set to \fBy\fP, this adds the line
+.B user_friendly_names yes
+to the
+.B /etc/multipath.conf
+defaults section. If set to \fBn\fP, this removes the line, if present. This
+command can be used along with any other command.
+.TP
+.B --find_multipaths\fP { \fBy\fP | \fBn\fP }
+If set to \fBy\fP, this adds the line
+.B find_multipaths yes
+to the
+.B /etc/multipath.conf
+defaults section. If set to \fBn\fP, this removes the line, if present. This
+command can be used aldong with any other command.
+.SH OPTIONS
+.TP
+.B --with_module\fP { \fBy\fP | \fBn\fP }
+If set to \fBy\fP, this runs
+.B modprobe dm_multipath
+to install the multipath modules. This option only works with the
+.B --enable
+command. This option is set to \fBy\fP by default.
+.TP
+.B --with_multipathd { \fBy\fP | \fBn\fP }
+If set to \fBy\fP, this runs
+.B service multipathd start
+to start the multipathd daemon on \fB--enable\fP,
+.B service multipathd stop
+to start the multipathd daemon on \fB--disable\fP, and
+.B service multipathd reload
+to reconfigure multipathd on \fB--user_frindly_names\fP and
+\fB--find_multipaths\fP.
+This option is set to \fBn\fP by default.
+.SH FILES
+.BR /etc/multipath.conf
+.SH "SEE ALSO"
+.BR multipath.conf (5),
+.BR modprobe (8),
+.BR multipath (8),
+.BR multipathd (8),
+.BR service (8),
+.SH AUTHOR
+Benjamin Marzinski <bmarzins@redhat.com>