Hi Coiby,
On Fri, Jan 14, 2022 at 12:25 PM Coiby Xu <coxu(a)redhat.com> wrote:
Hi Tao,
The patch looks good to me except for some nitpicking,
1. zstd is the default compression method so the message title is
misleading
2. If zstd compression fails, there should be some info printed
via debug
Thanks for the good suggestions! I have sent out the v2 patch with the
modifications.
Thanks,
Tao Liu
On Thu, Jan 13, 2022 at 03:39:56PM +0800, Tao Liu wrote:
>zstd is set as the default compression method. "--compress zstd"
>will make dracut to decide: a) if dracut module squash is added,
>libzstd will be used, b) otherwise cmd zstd will be used. However in
>kexec-tools we cannot guarantee dracut module squash is added, for
>example users can set omit_dracutmodules in dracut.conf and etc, so
>is_squash_available is not able to check is libzstd or cmd zstd
>been used at runtime.
>
>This patch will give "--compress zstd" a try first, if fails, it will
>just proceed the default compression method.
>
>Fixes: 7de4a0d ("Set zstd as recommented for kexec-tools")
>
>Signed-off-by: Tao Liu <ltao(a)redhat.com>
>---
> kdump-lib.sh | 5 -----
> mkdumprd | 21 ++++++++++++---------
> mkfadumprd | 7 ++++---
> 3 files changed, 16 insertions(+), 17 deletions(-)
>
>diff --git a/kdump-lib.sh b/kdump-lib.sh
>index 2ea51be..6415dda 100755
>--- a/kdump-lib.sh
>+++ b/kdump-lib.sh
>@@ -31,11 +31,6 @@ is_squash_available()
> done
> }
>
>-is_zstd_command_available()
>-{
>- [[ -x "$(command -v zstd)" ]]
>-}
>-
> perror_exit()
> {
> derror "$@"
>diff --git a/mkdumprd b/mkdumprd
>index 593ec77..10398ef 100644
>--- a/mkdumprd
>+++ b/mkdumprd
>@@ -431,15 +431,6 @@ done <<< "$(kdump_read_conf)"
>
> handle_default_dump_target
>
>-if ! have_compression_in_dracut_args; then
>- # Here zstd is set as the default compression method. If squash module
>- # is available for dracut, libzstd will be used by mksquashfs. If
>- # squash module is unavailable, command zstd will be used instead.
>- if is_squash_available || is_zstd_command_available; then
>- add_dracut_arg "--compress" "zstd"
>- fi
>-fi
>-
> if [[ -n $extra_modules ]]; then
> add_dracut_arg "--add-drivers" "$extra_modules"
> fi
>@@ -457,6 +448,18 @@ if ! is_fadump_capable; then
> add_dracut_arg "--no-hostonly-default-device"
> fi
>
>+if ! have_compression_in_dracut_args; then
>+ # Here we will first try to compress in zstd, if fails we will proceed
>+ # the default compress method.
>+ dracut "${dracut_args[@]}" "--compress" "zstd"
"$@" 2>/dev/null
>+ _rc=$?
>+
>+ if [[ $_rc -eq 0 ]]; then
>+ sync
>+ exit $_rc
>+ fi
>+fi
>+
> dracut "${dracut_args[@]}" "$@"
>
> _rc=$?
>diff --git a/mkfadumprd b/mkfadumprd
>index 86dfcee..f3cfe8a 100644
>--- a/mkfadumprd
>+++ b/mkfadumprd
>@@ -64,9 +64,10 @@ fi
>
> # Same as setting zstd in mkdumprd
> if ! have_compression_in_dracut_args; then
>- if is_squash_available || is_zstd_command_available; then
>- _dracut_isolate_args+=(--compress zstd)
>- fi
>+ dracut --force --quiet "${_dracut_isolate_args[@]}"
"--compress" "zstd" "$@" "$TARGET_INITRD"
2>/dev/null
>+ _rc=$?
>+
>+ [[ $_rc -eq 0 ]] && exit $_rc
> fi
>
> if ! dracut --force --quiet "${_dracut_isolate_args[@]}" "$@"
"$TARGET_INITRD"; then
>--
>2.33.1
>
--
Best regards,
Coiby