From 83556863450367f6001774338d77cfca6bb70e8f Mon Sep 17 00:00:00 2001 From: Thomas Deutschmann Date: Tue, 14 Apr 2020 19:46:32 +0200 Subject: [PATCH] sys-fs/lvm2: runscript: rework stop() - Don't use LVM script anymore: If one command within script failed, any following command won't run anymore. - Be verbose when rc_verbose=yes is set. - Don't pass VGs to vgchange command. This way, LVM will determine VGs on its own and we don't risk to hit command limit when system has many VGs. Closes: https://bugs.gentoo.org/690404 Signed-off-by: Thomas Deutschmann --- sys-fs/lvm2/files/lvm.rc-2.02.187 | 47 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/sys-fs/lvm2/files/lvm.rc-2.02.187 b/sys-fs/lvm2/files/lvm.rc-2.02.187 index f9ad753ea82d..84e799c32f03 100644 --- a/sys-fs/lvm2/files/lvm.rc-2.02.187 +++ b/sys-fs/lvm2/files/lvm.rc-2.02.187 @@ -138,39 +138,36 @@ stop() { fi # Stop LVM2 - if [ -x /sbin/vgs ] \ - && [ -x /sbin/vgchange ] \ - && [ -x /sbin/lvchange ] \ - && [ -f /etc/lvmtab -o -d /etc/lvm ] \ + if [ -f /etc/lvmtab -o -d /etc/lvm ] \ && [ -d /proc/lvm -o "$(grep device-mapper /proc/misc 2>/dev/null)" ] then - einfo "Shutting down the Logical Volume Manager" + local VGS=$($lvm_path vgs --config "${config}" -o vg_name --noheadings --nosuffix --rows 2> /dev/null) + if [ -z "${VGS}" ] ; then + # nothing to do for us + return 0 + fi - VGS=$($lvm_path vgs --config "${config}" -o vg_name --noheadings --nosuffix --rows 2> /dev/null) + local has_errors=0 verbose_command eend_cmd="eend" - if [ -n "${VGS}" ] ; then - local _ending="eend" - [ "${RC_RUNLEVEL}" = shutdown ] && _ending="ewend" + yesno "${rc_verbose}" && verbose_command=" -v" - ebegin " Shutting Down LVs & VGs" - #still echo stderr for debugging - lvm_commands="#!${lvm_path}\n" - # Extra PV find pass because some devices might not have been available until very recently - lvm_commands="${lvm_commands}lvchange --config '${config}' --sysinit -a ln ${VGS}\n" - # Now make the nodes - lvm_commands="${lvm_commands}vgchange --config '${config}' --sysinit -a ln ${VGS}\n" - # Order of this is important, have to work around dash and LVM readline - printf "%b\n" "${lvm_commands}" | ${lvm_path} /proc/self/fd/0 --config "${config}" >/dev/null - - rc=${?} - msg="Failed (possibly some LVs still needed for /usr or root)" - [ "${RC_RUNLEVEL}" = shutdown ] && msg="${msg} [rc=${rc}]" && rc=0 - ${_ending} ${rc} "${msg}" + local msg="Failed to stop Logical Volume Manager" + if [ "${RC_RUNLEVEL}" = shutdown ] ; then + # failures on shutdown are non-fatal + eend_cmd="ewend" + msg="${msg} (possibly some LVs still needed for /usr or root)" fi - einfo "Finished shutting down the Logical Volume Manager" - return 0 + ebegin "Stopping the Logical Volume Manager" + + ${lvm_path} vgchange${verbose_command} --config "${config}" --sysinit --activate n + [ $? -ne 0 ] && has_errors=1 + + ${eend_cmd} ${has_errors} "${msg}" fi + + # at this point make sure we always exit without indicating an error + return 0 } # vim:ts=4 -- 2.26.2