From 2ea20094d059840659a765911a3798faacafb6a0 Mon Sep 17 00:00:00 2001 From: Benjamin Block Date: Fri, 17 Sep 2021 12:10:28 +0200 Subject: [PATCH] chreipl-fcp-mpath: toolset skeleton with initial set of udev rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new tool to s390-tools: chreipl-fcp-mpath. A toolset based on udev to change the active re-IPL target if the current target goes into an error-state, due to for example a pulled cable. Add the base infrastructure consisting of a Makefile and a base set of udev rules. Integrate the Makefile into s390-tools Make machinery. The rules filter events base on the event subject type (dm-multipath, scsi disk), udev action (change, or add), and device mapper action (path failure, or path reinstated). No further processing is done right now in case of a match; if neither of these criteria matches, the rules exit, and the toolset won't be invoked. Reviewed-by: Steffen Maier Signed-off-by: Benjamin Block Signed-off-by: Jan Höppner --- Makefile | 2 +- chreipl-fcp-mpath/Makefile | 71 +++++++++++++++++++ chreipl-fcp-mpath/chreipl-fcp-mpath.mak | 19 +++++ .../udev/rules.d/70-chreipl-fcp-mpath.rules | 18 +++++ common.mak | 5 +- 5 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 chreipl-fcp-mpath/Makefile create mode 100644 chreipl-fcp-mpath/chreipl-fcp-mpath.mak create mode 100644 chreipl-fcp-mpath/udev/rules.d/70-chreipl-fcp-mpath.rules diff --git a/Makefile b/Makefile index d34c0eb8..73acb3c3 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ TOOL_DIRS = zipl zdump fdasd dasdfmt dasdview tunedasd \ vmconvert vmcp man mon_tools dasdinfo vmur cpuplugd ipl_tools \ ziomon iucvterm hyptop cmsfs-fuse qethqoat zfcpdump zdsfs cpumf \ systemd hmcdrvfs cpacfstats zdev dump2tar zkey netboot etc zpcictl \ - genprotimg lsstp hsci hsavmcore + genprotimg lsstp hsci hsavmcore chreipl-fcp-mpath SUB_DIRS = $(BASELIB_DIRS) $(LIB_DIRS) $(TOOL_DIRS) diff --git a/chreipl-fcp-mpath/Makefile b/chreipl-fcp-mpath/Makefile new file mode 100644 index 00000000..0294ecba --- /dev/null +++ b/chreipl-fcp-mpath/Makefile @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: MIT +# +# chreipl-fcp-mpath: use multipath information to change FCP IPL target +# (C) Copyright IBM Corp. 2021 +# +# Uses the following system-utilities (and shell-builtins): +# Utilities list in GNU Make Conventions: +# https://www.gnu.org/software/make/manual/make.html#Utilities-in-Makefiles +# Those necessary for sourced Makefiles: +# - ../common.mak +# - chreipl-fcp-mpath.mak +# bash: +# - bash + +override SHELL := /bin/bash +override .SHELLFLAGS := -O globstar -O nullglob -O extglob -c + +# Include common s390-tools definitions +include ../common.mak + +# Include common chreipl-fcp-mpath definitions +include chreipl-fcp-mpath.mak + +# Local setting: .make.config +# You may create a file named like this in the same directory as this +# Makefile, and customize the build this way (e.g. re-define variables +# set in `chreipl-fcp-mpath.mak`, or define a `CHREIPLZFCPMP_POST_INSTALL` +# that is automatically called after each installation) +ifneq ($(wildcard .make.config),) +include $(wildcard .make.config) +endif + +# +## Build +# + +.PHONY: chreipl-fcp-mpath chreipl-fcp-mpath-clean +chreipl-fcp-mpath: +chreipl-fcp-mpath-clean: +all: chreipl-fcp-mpath +clean: chreipl-fcp-mpath-clean + +udev/rules.d/70-chreipl-fcp-mpath.rules: + +chreipl-fcp-mpath: udev/rules.d/70-chreipl-fcp-mpath.rules + +# +## Install +# + +.PHONY: chreipl-fcp-mpath-install +# The content of `CHREIPLZFCPMP_POST_INSTALL` (bash script) is automatically +# called *after* installing chreipl-fcp-mpath during `make install`. If not +# defined (the default), nothing happens. You may define this on the make +# command line, or by creating a `.make.config` and defining the variable in +# there. +chreipl-fcp-mpath-install: + $(CHREIPLZFCPMP_POST_INSTALL) + +install: chreipl-fcp-mpath-install + +# install udev rules +INSTDIRS += $(UDEVRULESDIR) + +.PHONY: chreipl-fcp-mpath-install-udev-rules +chreipl-fcp-mpath-install-udev-rules: | $(DESTDIR)$(UDEVRULESDIR) +chreipl-fcp-mpath-install-udev-rules: udev/rules.d/70-chreipl-fcp-mpath.rules + $(INSTALL_DATA) -t $(DESTDIR)$(UDEVRULESDIR) \ + udev/rules.d/70-chreipl-fcp-mpath.rules + +chreipl-fcp-mpath-install: chreipl-fcp-mpath-install-udev-rules diff --git a/chreipl-fcp-mpath/chreipl-fcp-mpath.mak b/chreipl-fcp-mpath/chreipl-fcp-mpath.mak new file mode 100644 index 00000000..ac022d43 --- /dev/null +++ b/chreipl-fcp-mpath/chreipl-fcp-mpath.mak @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: MIT +# +# chreipl-fcp-mpath: use multipath information to change FCP IPL target +# (C) Copyright IBM Corp. 2021 +# +# Uses the following system-utilities (and shell-builtins): +# Utilities list in GNU Make Conventions: +# https://www.gnu.org/software/make/manual/make.html#Utilities-in-Makefiles + +# +## Paths and Build Variables +# + +# https://www.gnu.org/software/make/manual/make.html#Directory-Variables +UDEVDIR = $(USRLIBDIR)/udev +UDEVRULESDIR = $(UDEVDIR)/rules.d + +INSTALL_EXEC = $(INSTALL) -g $(GROUP) -o $(OWNER) --preserve-timestamps +INSTALL_DATA = $(INSTALL_EXEC) --mode=0644 diff --git a/chreipl-fcp-mpath/udev/rules.d/70-chreipl-fcp-mpath.rules b/chreipl-fcp-mpath/udev/rules.d/70-chreipl-fcp-mpath.rules new file mode 100644 index 00000000..f8e490e7 --- /dev/null +++ b/chreipl-fcp-mpath/udev/rules.d/70-chreipl-fcp-mpath.rules @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: MIT +# +# chreipl-fcp-mpath: use multipath information to change FCP IPL target +# (C) Copyright IBM Corp. 2021 + +# Did the event affect a multipath or scsi disk device? +ACTION=="change", KERNEL=="dm-[0-9]*", SUBSYSTEM=="block", \ + ENV{DM_UUID}=="mpath-*", ENV{DM_ACTION}=="PATH_FAILED", \ + GOTO="chreipl_fcp_mpath_path_change" +ACTION=="change", KERNEL=="dm-[0-9]*", SUBSYSTEM=="block", \ + ENV{DM_UUID}=="mpath-*", ENV{DM_ACTION}=="PATH_REINSTATED", \ + GOTO="chreipl_fcp_mpath_path_change" +ACTION=="add", KERNEL=="sd[a-z]*", SUBSYSTEM=="block", \ + GOTO="chreipl_fcp_mpath_path_change" +GOTO="chreipl_fcp_mpath_end" +LABEL="chreipl_fcp_mpath_path_change" + +LABEL="chreipl_fcp_mpath_end" diff --git a/common.mak b/common.mak index 6ede3def..525be7fc 100644 --- a/common.mak +++ b/common.mak @@ -182,6 +182,7 @@ USRSBINDIR = $(INSTALLDIR)/usr/sbin USRBINDIR = $(INSTALLDIR)/usr/bin BINDIR = $(INSTALLDIR)/sbin LIBDIR = $(INSTALLDIR)/lib +USRLIBDIR = $(INSTALLDIR)/usr/lib USRLIB64DIR = $(INSTALLDIR)/usr/lib64 SYSCONFDIR = $(INSTALLDIR)/etc MANDIR = $(INSTALLDIR)/usr/share/man @@ -206,10 +207,10 @@ INSTDIRS = $(USRSBINDIR) $(USRBINDIR) $(BINDIR) $(LIBDIR) $(MANDIR) \ $(TOOLS_LIBDIR) $(TOOLS_DATADIR) \ $(ZFCPDUMP_DIR) $(SYSTEMDSYSTEMUNITDIR) \ $(USRLIB64DIR) $(USRINCLUDEDIR) $(ZKEYKMSPLUGINDIR) \ - $(SOINSTALLDIR) + $(SOINSTALLDIR) $(USRLIBDIR) OWNER = $(shell id -un) GROUP = $(shell id -gn) -export INSTALLDIR BINDIR LIBDIR USRLIB64DIR MANDIR OWNER GROUP +export INSTALLDIR BINDIR LIBDIR USRLIBDIR USRLIB64DIR MANDIR OWNER GROUP # Special defines for zfcpdump ZFCPDUMP_IMAGE = zfcpdump-image