mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
In the final step of the udev rules toolset, we either know that the
current event subject is the re-IPL target, a dm-multipath device with
the re-IPL target, or represents the same volume based on its WWID. As
such it is a candidate to replace the current re-IPL target.
The new helper `chreipl-fcp-mpath-try-change-ipl-path` will use the
subject itself - in case it is a single scsi disk -, or the dm-multipath
device, to test whether there is a path in a good state.
"Good state" is based on the zfcp device driver state
(<SDEV>/zfcp_failed, <SDEV>/zfcp_in_recovery), the scsi_transport_fc
port state (<SDEV>/../../fc_remote_ports/rport-*/port_state), and the
scsi device state (<SDEV>/state). A path is only considered if they all
indicate a device in good conditions.
If such a path is found, the helper will try to set it as new re-IPL
target regardless of whether the current re-IPL is still in good shape
or not. This is by design, and done to reduce complexity in further
state checking, and prevention of races with overlapping events in udev
(when executing in parallel workers).
Whenever a new re-IPL target is selected and set in
/sys/firmware/reipl/fcp/{device,wwpn,lun}, the helper will also update
the records in the ID-file - otherwise they might appear as stale, when
they aren't.
This step in the udev rule processing might also result in log messages
written to the syslog (using the utility `logger` from util-linux;
writing to /dev/log).
In case the re-IPL target is changed, a message with level notice is
logged, informing about the new target.
In case no good path is found as part of a dm-multipath device, a
message with level critical is logged, as it might result in a failed
re-IPL if no path is available.
Lastly, when changing the information in /sys/firmware/reipl/fcp/ fails
for whatever reason, a message with level alert is logged, as the
written information might be inconsistent and must be audited/corrected
manually by an operator.
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
173 lines
6.0 KiB
Makefile
173 lines
6.0 KiB
Makefile
# 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
|
|
|
|
# common function used in the helper scripts
|
|
CHREIPL_FCP_MPATH_COMMON := \
|
|
chreipl-fcp-mpath-common.sh
|
|
CHREIPL_FCP_MPATH_UDEV_HELPER := \
|
|
chreipl-fcp-mpath-is-ipl-tgt \
|
|
chreipl-fcp-mpath-is-ipl-vol \
|
|
chreipl-fcp-mpath-is-reipl-zfcp \
|
|
chreipl-fcp-mpath-record-volume-identifier \
|
|
chreipl-fcp-mpath-try-change-ipl-path
|
|
|
|
$(CHREIPL_FCP_MPATH_UDEV_HELPER) $(CHREIPL_FCP_MPATH_COMMON): $(MAKEFILE_LIST)
|
|
$(CHREIPL_FCP_MPATH_UDEV_HELPER) $(CHREIPL_FCP_MPATH_COMMON): % : %.in
|
|
$(call chreiplzfcpmp-sed-buildvar-replace,$(<),$(@))
|
|
chmod a+x $(@)
|
|
|
|
$(CHREIPL_FCP_MPATH_UDEV_HELPER): $(CHREIPL_FCP_MPATH_COMMON)
|
|
|
|
.PHONY: chreipl-fcp-mpath-udev-helper-clean
|
|
chreipl-fcp-mpath-udev-helper-clean:
|
|
rm -f $(CHREIPL_FCP_MPATH_UDEV_HELPER) $(CHREIPL_FCP_MPATH_COMMON)
|
|
|
|
udev/rules.d/70-chreipl-fcp-mpath.rules: $(CHREIPL_FCP_MPATH_UDEV_HELPER)
|
|
|
|
chreipl-fcp-mpath: udev/rules.d/70-chreipl-fcp-mpath.rules
|
|
chreipl-fcp-mpath-clean: chreipl-fcp-mpath-udev-helper-clean
|
|
|
|
#
|
|
## 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
|
|
|
|
# install udev helper programs
|
|
INSTDIRS += $(UDEVDIR)
|
|
|
|
.PHONY: chreipl-fcp-mpath-install-udev-helper
|
|
chreipl-fcp-mpath-install-udev-helper: | $(DESTDIR)$(UDEVDIR)
|
|
chreipl-fcp-mpath-install-udev-helper: $(CHREIPL_FCP_MPATH_UDEV_HELPER)
|
|
$(INSTALL_EXEC) -t $(DESTDIR)$(UDEVDIR) $(CHREIPL_FCP_MPATH_UDEV_HELPER)
|
|
|
|
chreipl-fcp-mpath-install: chreipl-fcp-mpath-install-udev-helper
|
|
|
|
# install common library files
|
|
INSTDIRS += $(CHREIPLZFCPMPDIR)
|
|
|
|
.PHONY: chreipl-fcp-mpath-install-libfiles
|
|
chreipl-fcp-mpath-install-libfiles: | $(DESTDIR)$(CHREIPLZFCPMPDIR)
|
|
chreipl-fcp-mpath-install-libfiles: $(CHREIPL_FCP_MPATH_COMMON)
|
|
$(INSTALL_DATA) -t $(DESTDIR)$(CHREIPLZFCPMPDIR) \
|
|
$(CHREIPL_FCP_MPATH_COMMON)
|
|
|
|
chreipl-fcp-mpath-install: chreipl-fcp-mpath-install-libfiles
|
|
|
|
#
|
|
## Utility
|
|
#
|
|
|
|
# Utilities for the debug feature of chreipl-fcp-mpath-common.sh.
|
|
#
|
|
# When `chreipl-fcp-mpath` is built with D=1 (default is D=0), each run
|
|
# of one of the helper scripts will create a debug log in $(DEBUGOUTDIR)
|
|
# (default: /run/udev) which among other things contains the complete shell
|
|
# trace of that script run, with some added information that would not be
|
|
# inspectable otherwise with just the trace.
|
|
#
|
|
# There is currently no way of enabling/disabling this at runtime.
|
|
#
|
|
# chreipl-fcp-mpath-common.sh defines debug log file name as
|
|
# "chreiplzfcpmp-${debug_trace_tag}-${SEQNUM:-0}.XXXXXXXXXX" where SEQNUM is a
|
|
# udev rule environment variable and each X is replaced with some [[:alnum:]]
|
|
# by mktemp. For a definition of `debug_trace_tag`, please see the comments
|
|
# in the source.
|
|
#
|
|
# The following targets can be used for some simple access and filtering of the
|
|
# logs during development.
|
|
|
|
DEBUG_LOG_GLOB = $(DEBUGOUTDIR)/chreiplzfcpmp-[[:digit:]][[:digit:]][[:alpha:]][[:alpha:]][[:alpha:]][[:alpha:]]-+([[:digit:]]).[[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]]
|
|
|
|
# display all debug log files on the system
|
|
.PHONY: chreipl-fcp-mpath-debug-logs
|
|
chreipl-fcp-mpath-debug-logs:
|
|
@ls -1d $(DEBUG_LOG_GLOB)
|
|
|
|
# display only debug log files of script runs that exited with status 0 (= good)
|
|
#
|
|
# XXX: `sed -n -e '$p'` is used instead of `tail -n1` to prevent an other
|
|
# dependency just for that (both invocations do the same thing).
|
|
.PHONY: chreipl-fcp-mpath-debug-logs-filter-good
|
|
chreipl-fcp-mpath-debug-logs-filter-good:
|
|
@for lg in $(DEBUG_LOG_GLOB); do \
|
|
sed -e '/^+ trap_exit$$/,/^+ trap - EXIT$$/d' "$${lg}" \
|
|
| sed -n -e '$$p' \
|
|
| grep -q -e '^+ exit 0$$' || continue; \
|
|
ls -d "$${lg}"; \
|
|
done
|
|
|
|
# display only debug log files of script runs that didn't exit with status 0
|
|
# (= bad)
|
|
.PHONY: chreipl-fcp-mpath-debug-logs-filter-bad
|
|
chreipl-fcp-mpath-debug-logs-filter-bad:
|
|
@for lg in $(DEBUG_LOG_GLOB); do \
|
|
sed -e '/^+ trap_exit$$/,/^+ trap - EXIT$$/d' "$${lg}" \
|
|
| sed -n -e '$$p' \
|
|
| grep -q -e '^+ exit 0$$' && continue; \
|
|
ls -d "$${lg}"; \
|
|
done
|
|
|
|
.PHONY: chreipl-fcp-mpath-debug-logs-clean
|
|
chreipl-fcp-mpath-debug-logs-clean:
|
|
rm -f $(DEBUG_LOG_GLOB)
|