Previous patch series: [PATCH v2 0/7] Add support for unmounted dump target assumed get_persistent_dev accepts any block target config format. But it doesn't recognize the UUID= or LABEL= format. So always use the wrapper version for kdump which supports it well.
Also fix a nfs detection issue introduced the that patch series.
Kairui Song (2): Always wrap up call to dracut get_persistent_dev function mkdumprd: Fix nfs detection in to_mount
Update from v1: - Keep kdump_get_persistent_dev function name unchanged - Simplify and fix nfs dump target detection in to_mount again
dracut-module-setup.sh | 14 -------------- kdump-lib.sh | 14 ++++++++++++++ kdumpctl | 2 +- mkdumprd | 24 ++++++++++-------------- 4 files changed, 25 insertions(+), 29 deletions(-)
Dracut get_persistent_dev function don't recognize UUID= or LABEL= format, so caller should conver it to the path to the block device before calling it. There is already such a helper "kdump_get_persistent_dev", just move it to kdump-lib.sh and rename it to reuse it,
Signed-off-by: Kairui Song kasong@redhat.com --- dracut-module-setup.sh | 14 -------------- kdump-lib.sh | 14 ++++++++++++++ kdumpctl | 2 +- mkdumprd | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 90f3772..2454463 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -48,20 +48,6 @@ depends() { return 0 }
-kdump_get_persistent_dev() { - local dev="${1//"/}" - - case "$dev" in - UUID=*) - dev=`blkid -U "${dev#UUID=}"` - ;; - LABEL=*) - dev=`blkid -L "${dev#LABEL=}"` - ;; - esac - echo $(get_persistent_dev "$dev") -} - kdump_is_bridge() { [ -d /sys/class/net/"$1"/bridge ] } diff --git a/kdump-lib.sh b/kdump-lib.sh index 74dac4c..6f250d4 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -307,6 +307,20 @@ get_option_value() { strip_comments `grep "^$1[[:space:]]+" /etc/kdump.conf | tail -1 | cut -d\ -f2-` }
+kdump_get_persistent_dev() { + local dev="${1//"/}" + + case "$dev" in + UUID=*) + dev=`blkid -U "${dev#UUID=}"` + ;; + LABEL=*) + dev=`blkid -L "${dev#LABEL=}"` + ;; + esac + echo $(get_persistent_dev "$dev") +} + is_atomic() { grep -q "ostree" /proc/cmdline diff --git a/kdumpctl b/kdumpctl index 408b88a..70fb551 100755 --- a/kdumpctl +++ b/kdumpctl @@ -482,7 +482,7 @@ check_dump_fs_modified() if [[ $(expr substr $_new_fstype 1 3) = "nfs" ]];then _new_dev=$_target else - _new_dev=$(get_persistent_dev $_target) + _new_dev=$(kdump_get_persistent_dev $_target) if [ -z "$_new_dev" ]; then echo "Get persistent device name failed" return 2 diff --git a/mkdumprd b/mkdumprd index 7bc1bd1..4b1e11c 100644 --- a/mkdumprd +++ b/mkdumprd @@ -93,7 +93,7 @@ to_mount() { _mntopts="$_new_mntpoint $_fstype $_options" # for non-nfs _target converting to use udev persistent name if [ -b "$_target" ]; then - _pdev="$(get_persistent_dev $_target)" + _pdev="$(kdump_get_persistent_dev $_target)" if [ -z "$_pdev" ]; then return 1 fi @@ -438,7 +438,7 @@ do dd if=$config_val count=1 of=/dev/null > /dev/null 2>&1 || { perror_exit "Bad raw disk $config_val" } - _praw=$(persistent_policy="by-id" get_persistent_dev $config_val) + _praw=$(persistent_policy="by-id" kdump_get_persistent_dev $config_val) if [ -z "$_praw" ]; then exit 1 fi
If target is in format of UUID= or LABEL=, current code will fail as it expects target to be the absoluta path to the block device. Check for the fstype instead.
Also simplity the code logic.
Signed-off-by: Kairui Song kasong@redhat.com --- mkdumprd | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/mkdumprd b/mkdumprd index 4b1e11c..3dbf839 100644 --- a/mkdumprd +++ b/mkdumprd @@ -65,7 +65,7 @@ add_dracut_sshkey() {
# caller should ensure $1 is valid and mounted in 1st kernel to_mount() { - local _target=$1 _fstype=$2 _options=$3 _new_mntpoint _mntopts _pdev + local _target=$1 _fstype=$2 _options=$3 _new_mntpoint _pdev
_new_mntpoint=$(get_kdump_mntpoint_from_target $_target) _fstype="${_fstype:-$(get_fs_type_from_target $_target)}" @@ -73,9 +73,16 @@ to_mount() { _options="${_options:-defaults}"
if [[ "$_fstype" == "nfs"* ]]; then + _pdev=$_target _options=$(echo $_options | sed 's/,addr=[^,]*//') _options=$(echo $_options | sed 's/,proto=[^,]*//') _options=$(echo $_options | sed 's/,clientaddr=[^,]*//') + else + # for non-nfs _target converting to use udev persistent name + _pdev="$(get_kdump_persistent_dev $_target)" + if [ -z "$_pdev" ]; then + return 1 + fi fi
# mount fs target as rw in 2nd kernel @@ -90,18 +97,7 @@ to_mount() { # mount it before kdump starts, this is an attempt to improve robustness _options="$_options,nofail,x-systemd.before=initrd-fs.target"
- _mntopts="$_new_mntpoint $_fstype $_options" - # for non-nfs _target converting to use udev persistent name - if [ -b "$_target" ]; then - _pdev="$(kdump_get_persistent_dev $_target)" - if [ -z "$_pdev" ]; then - return 1 - fi - else - _pdev=$_target - fi - - echo "$_pdev $_mntopts" + echo "$_pdev $_new_mntpoint $_fstype $_options" }
#Function: get_ssh_size
On 06/17/20 at 02:28pm, Kairui Song wrote:
Previous patch series: [PATCH v2 0/7] Add support for unmounted dump target assumed get_persistent_dev accepts any block target config format. But it doesn't recognize the UUID= or LABEL= format. So always use the wrapper version for kdump which supports it well.
Also fix a nfs detection issue introduced the that patch series.
Kairui Song (2): Always wrap up call to dracut get_persistent_dev function mkdumprd: Fix nfs detection in to_mount
Update from v1:
- Keep kdump_get_persistent_dev function name unchanged
- Simplify and fix nfs dump target detection in to_mount again
dracut-module-setup.sh | 14 -------------- kdump-lib.sh | 14 ++++++++++++++ kdumpctl | 2 +- mkdumprd | 24 ++++++++++-------------- 4 files changed, 25 insertions(+), 29 deletions(-)
Hi Kairui,
Thanks, looks good
Acked-by: Dave Young dyoung@redhat.com