summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Deutschmann <whissi@gentoo.org>2020-04-14 19:46:32 +0200
committerThomas Deutschmann <whissi@gentoo.org>2020-04-14 20:34:21 +0200
commit83556863450367f6001774338d77cfca6bb70e8f (patch)
tree3b684d4e061f5e824ed46a77ca300c7f923d865b
parentsys-fs/lvm2: runscript: rework start() (diff)
downloadgentoo-83556863450367f6001774338d77cfca6bb70e8f.tar.gz
gentoo-83556863450367f6001774338d77cfca6bb70e8f.tar.bz2
gentoo-83556863450367f6001774338d77cfca6bb70e8f.zip
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 <whissi@gentoo.org>
-rw-r--r--sys-fs/lvm2/files/lvm.rc-2.02.18747
1 files 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