Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | From 5ab50e0cb888e553a2635bbbf81eea3cdeffee60 Mon Sep 17 00:00:00 2001 |
| 2 | From: Benjamin Marzinski <bmarzins@redhat.com> |
| 3 | Date: Wed, 12 Apr 2017 09:07:51 -0500 |
| 4 | Subject: [PATCH 01/14] multipath: attempt at common multipath.rules |
| 5 | |
| 6 | This is a proposal to try and bring the Redhat and SuSE multipath.rules |
| 7 | closer. There are a couple of changes that I'd like some input on. |
| 8 | |
| 9 | The big change is moving the kpartx call into the multipath rules. Half |
| 10 | of the current kpartx.rules file is about creating symlinks for multiple |
| 11 | types of dm devices. The other half auto-creates kpartx devices on top |
| 12 | of multipath devices. Since it is only creating kpartx devices on top of |
| 13 | multipath devices, I've moved the these rules into multipath.rules, or |
| 14 | rather, I've replaced them with the redhat rules in multipath.rules. The |
| 15 | biggest difference is the kpartx isn't run on every reload. It works |
| 16 | with the 11-dm-mpath.rules code to not run kpartx on multipathd |
| 17 | generated reloads or when there aren't any working paths. It does |
| 18 | remember if it didn't get to run kpartx when it was supposed to (because |
| 19 | there were no valid paths or the device was suspended) and will make |
| 20 | sure to run it on the next possible uevent. |
| 21 | |
| 22 | The other change is the redhat multipath rules remove the partition |
| 23 | device nodes for devices claimed by multipath. The udev rule will only |
| 24 | do this one time (both to keep from running partx on every event, and so |
| 25 | that if users manually reread the partition table, we don't keep |
| 26 | removing them when clearly they are wanted). Redhat does this because we |
| 27 | had multiple customer issues where they were using the scsi partitions |
| 28 | instead of the kpartx devices. Obviously, with setting the partition |
| 29 | devices to not ready and clearing their fs_type, this isn't essential, |
| 30 | but it has helped make customers do the right thing. |
| 31 | |
| 32 | Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> |
| 33 | --- |
| 34 | kpartx/kpartx.rules | 8 -------- |
| 35 | multipath/multipath.rules | 27 ++++++++++++++++++++++++--- |
| 36 | 2 files changed, 24 insertions(+), 11 deletions(-) |
| 37 | |
| 38 | diff --git a/kpartx/kpartx.rules b/kpartx/kpartx.rules |
| 39 | index a958791..906e320 100644 |
| 40 | --- a/kpartx/kpartx.rules |
| 41 | +++ b/kpartx/kpartx.rules |
| 42 | @@ -34,12 +34,4 @@ ENV{ID_FS_LABEL_ENC}=="?*", IMPORT{db}="ID_FS_LABEL_ENC" |
| 43 | ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", \ |
| 44 | SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" |
| 45 | |
| 46 | -# Create dm tables for partitions |
| 47 | -ENV{DM_ACTION}=="PATH_FAILED|PATH_REINSTATED", GOTO="kpartx_end" |
| 48 | -ENV{DM_NR_VALID_PATHS}=="0", GOTO="kpartx_end" |
| 49 | -ENV{ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG1" |
| 50 | -ENV{DM_SUBSYSTEM_UDEV_FLAG1}=="1", GOTO="kpartx_end" |
| 51 | -ENV{DM_STATE}!="SUSPENDED", ENV{DM_UUID}=="mpath-*", \ |
| 52 | - RUN+="/sbin/kpartx -un -p -part /dev/$name" |
| 53 | - |
| 54 | LABEL="kpartx_end" |
| 55 | diff --git a/multipath/multipath.rules b/multipath/multipath.rules |
| 56 | index 86defc0..616a04c 100644 |
| 57 | --- a/multipath/multipath.rules |
| 58 | +++ b/multipath/multipath.rules |
| 59 | @@ -1,13 +1,13 @@ |
| 60 | # Set DM_MULTIPATH_DEVICE_PATH if the device should be handled by multipath |
| 61 | SUBSYSTEM!="block", GOTO="end_mpath" |
| 62 | ACTION!="add|change", GOTO="end_mpath" |
| 63 | -KERNEL!="sd*|dasd*", GOTO="end_mpath" |
| 64 | - |
| 65 | +KERNEL!="sd*|dasd*|rbd*|dm-*", GOTO="end_mpath" |
| 66 | IMPORT{cmdline}="nompath" |
| 67 | ENV{nompath}=="?*", GOTO="end_mpath" |
| 68 | IMPORT{cmdline}="multipath" |
| 69 | ENV{multipath}=="off", GOTO="end_mpath" |
| 70 | |
| 71 | +KERNEL=="dm-*", GOTO="check_kpartx" |
| 72 | ENV{DEVTYPE}!="partition", GOTO="test_dev" |
| 73 | IMPORT{parent}="DM_MULTIPATH_DEVICE_PATH" |
| 74 | ENV{DM_MULTIPATH_DEVICE_PATH}=="1", ENV{ID_FS_TYPE}="none", \ |
| 75 | @@ -21,7 +21,28 @@ TEST!="$env{MPATH_SBIN_PATH}/multipath", ENV{MPATH_SBIN_PATH}="/usr/sbin" |
| 76 | |
| 77 | ENV{DM_MULTIPATH_DEVICE_PATH}!="1", \ |
| 78 | PROGRAM=="$env{MPATH_SBIN_PATH}/multipath -u %k", \ |
| 79 | - ENV{DM_MULTIPATH_DEVICE_PATH}="1", ENV{ID_FS_TYPE}="none", \ |
| 80 | + ENV{DM_MULTIPATH_DEVICE_PATH}="1", ENV{ID_FS_TYPE}="mpath_member", \ |
| 81 | ENV{SYSTEMD_READY}="0" |
| 82 | |
| 83 | +ENV{DM_MULTIPATH_DEVICE_PATH}!="1", GOTO="end_mpath" |
| 84 | + |
| 85 | +IMPORT{db}="DM_MULTIPATH_WIPE_PARTS" |
| 86 | +ENV{DM_MULTIPATH_WIPE_PARTS}!="1", ENV{DM_MULTIPATH_WIPE_PARTS}="1", \ |
| 87 | + RUN+="/sbin/partx -d --nr 1-1024 $env{DEVNAME}" |
| 88 | +GOTO="end_mpath" |
| 89 | + |
| 90 | +LABEL="check_kpartx" |
| 91 | + |
| 92 | +IMPORT{db}="DM_MULTIPATH_NEED_KPARTX" |
| 93 | +ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG1" |
| 94 | +ENV{DM_SUBSYSTEM_UDEV_FLAG1}=="1", GOTO="end_mpath" |
| 95 | +ACTION!="change", GOTO="end_mpath" |
| 96 | +ENV{DM_UUID}!="mpath-?*", GOTO="end_mpath" |
| 97 | +ENV{DM_ACTIVATION}=="1", ENV{DM_MULTIPATH_NEED_KPARTX}="1" |
| 98 | +ENV{DM_SUSPENDED}=="1", GOTO="end_mpath" |
| 99 | +ENV{DM_ACTION}=="PATH_FAILED", GOTO="end_mpath" |
| 100 | +ENV{DM_ACTIVATION}!="1", ENV{DM_MULTIPATH_NEED_KPARTX}!="1", GOTO="end_mpath" |
| 101 | +RUN+="/sbin/kpartx -un -p -part /dev/$name" |
| 102 | +ENV{DM_MULTIPATH_NEED_KPARTX}="" |
| 103 | + |
| 104 | LABEL="end_mpath" |
| 105 | -- |
| 106 | 2.8.1 |
| 107 | |