]>
Commit | Line | Data |
---|---|---|
b96c193b JU |
1 | # Copyright (C) 2017 by Jonathan G. Underwood |
2 | # This file is part of mdraid-safe-timeouts. | |
3 | # | |
4 | # mdraid-safe-timeouts is free software: you can redistribute it | |
5 | # and/or modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation, either version 3 of | |
7 | # the License, or (at your option) any later version. | |
8 | # | |
9 | # Foobar is distributed in the hope that it will be useful, but | |
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 | # General Public License for more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with mdraid-safe-timeouts. If not, see | |
16 | # <http://www.gnu.org/licenses/>. | |
17 | ||
18 | # This file causes block devices with Linux RAID (mdadm) signatures to | |
19 | # attempt to set safe timeouts for the drives involved | |
20 | # See udev(8) for syntax | |
21 | ||
22 | # Don't process any events if anaconda is running as anaconda brings up | |
23 | # raid devices manually | |
24 | ENV{ANACONDA}=="?*", GOTO="md_timeouts_end" | |
25 | ||
26 | SUBSYSTEM!="block|machinecheck", GOTO="md_timeouts_end" | |
27 | ||
28 | # "noiswmd" on kernel command line stops mdadm from handling | |
29 | # "isw" (aka IMSM - Intel RAID). | |
30 | # "nodmraid" on kernel command line stops mdadm from handling | |
31 | # "isw" or "ddf". | |
32 | IMPORT{cmdline}="nodmraid" | |
33 | ENV{nodmraid}=="?*", GOTO="md_timeouts_end" | |
34 | IMPORT{cmdline}="noiswmd" | |
35 | ENV{noiswmd}=="?*", GOTO="md_timeouts_end" | |
36 | ||
37 | # Set controller timeout for parent disk of each partition if the | |
38 | # partition is a mdraid partition of higher than raid 0, and the disk | |
39 | # doesn't have scterc turned on (i.e. if it's disabled or the disk | |
40 | # doesn't support it). We determine if the disk has SCTERC turned on | |
41 | # by examining the output of smartctl and seeing if it contains the | |
42 | # word "seconds". If the word "seconds" is found we take this to imply | |
43 | # STCERC is turned on, and take no action. Otherwise we set the drive | |
44 | # controller timeout to 180 seconds. It would be better to check the | |
45 | # exit status code of smartctl rather than grepping for "seconds", but | |
46 | # it's not clear what that will be in the three cases (supported and | |
47 | # turned on, supported but disabled, not supported). | |
48 | ||
49 | ENV{DEVTYPE}!="partition", GOTO="md_timeouts_end" | |
50 | ||
51 | IMPORT{program}="/sbin/mdadm --examine --export $devnode" | |
52 | ||
53 | ACTION=="add|change", \ | |
54 | ENV{ID_FS_TYPE}=="linux_raid_member", \ | |
55 | ENV{MD_LEVEL}=="raid[1-9]*", \ | |
56 | TEST=="/sys/block/$parent/device/timeout", \ | |
57 | TEST=="/usr/sbin/smartctl", \ | |
18552ef0 DJL |
58 | PROGRAM!="/bin/sh -c '/usr/sbin/smartctl -l scterc /dev/$parent | grep -q seconds && exit 0 || exit 1'", \ |
59 | RUN+="/bin/sh -c 'echo 180 > /sys/block/$parent/device/timeout && /usr/bin/logger timeout for /dev/$parent set to 180 secs'" | |
b96c193b JU |
60 | |
61 | LABEL="md_timeouts_end" |