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
dracut-module-setup.sh | 20 +++----------------- kdump-lib.sh | 14 ++++++++++++++ kdumpctl | 2 +- mkdumprd | 6 +++--- 4 files changed, 21 insertions(+), 21 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 | 20 +++----------------- kdump-lib.sh | 14 ++++++++++++++ kdumpctl | 2 +- mkdumprd | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 90f3772..c7eeff8 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 ] } @@ -466,7 +452,7 @@ default_dump_target_install_conf() kdump_install_net "$_target" _fstype="nfs" else - _target=$(kdump_get_persistent_dev $_target) + _target=$(get_kdump_persistent_dev $_target) fi
echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf @@ -491,11 +477,11 @@ kdump_install_conf() { # remove inline comments after the end of a directive. case "$_opt" in raw) - _pdev=$(persistent_policy="by-id" kdump_get_persistent_dev $_val) + _pdev=$(persistent_policy="by-id" get_kdump_persistent_dev $_val) sed -i -e "s#^$_opt[[:space:]]+$_val#$_opt $_pdev#" ${initdir}/tmp/$$-kdump.conf ;; ext[234]|xfs|btrfs|minix) - _pdev=$(kdump_get_persistent_dev $_val) + _pdev=$(get_kdump_persistent_dev $_val) sed -i -e "s#^$_opt[[:space:]]+$_val#$_opt $_pdev#" ${initdir}/tmp/$$-kdump.conf ;; ssh|nfs) diff --git a/kdump-lib.sh b/kdump-lib.sh index 74dac4c..0040483 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -301,6 +301,20 @@ get_kdump_mntpoint_from_target() echo $_mntpoint | tr -s "/" }
+get_kdump_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") +} + # get_option_value <option_name> # retrieves value of option defined in kdump.conf get_option_value() { diff --git a/kdumpctl b/kdumpctl index 408b88a..8004783 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=$(get_kdump_persistent_dev $_target) if [ -z "$_new_dev" ]; then echo "Get persistent device name failed" return 2 diff --git a/mkdumprd b/mkdumprd index 7bc1bd1..c7b8f17 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="$(get_kdump_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" get_kdump_persistent_dev $config_val) if [ -z "$_praw" ]; then exit 1 fi
On 06/16/20 at 01:53pm, Kairui Song wrote:
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,
Any special reason to rename it to get_kdump_persistent_dev?
The kdump_get_persistent_dev was meant to add a "kdump" prefix so it is like a "kdump" version of "get_persistent_dev"
Signed-off-by: Kairui Song kasong@redhat.com
dracut-module-setup.sh | 20 +++----------------- kdump-lib.sh | 14 ++++++++++++++ kdumpctl | 2 +- mkdumprd | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 90f3772..c7eeff8 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 ] } @@ -466,7 +452,7 @@ default_dump_target_install_conf() kdump_install_net "$_target" _fstype="nfs" else
_target=$(kdump_get_persistent_dev $_target)
_target=$(get_kdump_persistent_dev $_target)
fi
echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf
@@ -491,11 +477,11 @@ kdump_install_conf() { # remove inline comments after the end of a directive. case "$_opt" in raw)
_pdev=$(persistent_policy="by-id" kdump_get_persistent_dev $_val)
_pdev=$(persistent_policy="by-id" get_kdump_persistent_dev $_val) sed -i -e "s#^$_opt[[:space:]]\+$_val#$_opt $_pdev#" ${initdir}/tmp/$$-kdump.conf ;; ext[234]|xfs|btrfs|minix)
_pdev=$(kdump_get_persistent_dev $_val)
_pdev=$(get_kdump_persistent_dev $_val) sed -i -e "s#^$_opt[[:space:]]\+$_val#$_opt $_pdev#" ${initdir}/tmp/$$-kdump.conf ;; ssh|nfs)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 74dac4c..0040483 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -301,6 +301,20 @@ get_kdump_mntpoint_from_target() echo $_mntpoint | tr -s "/" }
+get_kdump_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")
+}
# get_option_value <option_name> # retrieves value of option defined in kdump.conf get_option_value() { diff --git a/kdumpctl b/kdumpctl index 408b88a..8004783 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)
if [ -z "$_new_dev" ]; then echo "Get persistent device name failed" return 2_new_dev=$(get_kdump_persistent_dev $_target)
diff --git a/mkdumprd b/mkdumprd index 7bc1bd1..c7b8f17 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="$(get_kdump_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" get_kdump_persistent_dev $config_val) if [ -z "$_praw" ]; then exit 1 fi
-- 2.26.2 _______________________________________________ kexec mailing list -- kexec@lists.fedoraproject.org To unsubscribe send an email to kexec-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org
Thanks Dave
On Tue, Jun 16, 2020 at 3:30 PM Dave Young dyoung@redhat.com wrote:
On 06/16/20 at 01:53pm, Kairui Song wrote:
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,
Any special reason to rename it to get_kdump_persistent_dev?
The kdump_get_persistent_dev was meant to add a "kdump" prefix so it is like a "kdump" version of "get_persistent_dev"
I can keep the name, just want to align the naming style in kdump-lib.sh I'm fine either way.
Signed-off-by: Kairui Song kasong@redhat.com
dracut-module-setup.sh | 20 +++----------------- kdump-lib.sh | 14 ++++++++++++++ kdumpctl | 2 +- mkdumprd | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 90f3772..c7eeff8 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 ] } @@ -466,7 +452,7 @@ default_dump_target_install_conf() kdump_install_net "$_target" _fstype="nfs" else
_target=$(kdump_get_persistent_dev $_target)
_target=$(get_kdump_persistent_dev $_target)
fi
echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf
@@ -491,11 +477,11 @@ kdump_install_conf() { # remove inline comments after the end of a directive. case "$_opt" in raw)
_pdev=$(persistent_policy="by-id" kdump_get_persistent_dev $_val)
_pdev=$(persistent_policy="by-id" get_kdump_persistent_dev $_val) sed -i -e "s#^$_opt[[:space:]]\+$_val#$_opt $_pdev#" ${initdir}/tmp/$$-kdump.conf ;; ext[234]|xfs|btrfs|minix)
_pdev=$(kdump_get_persistent_dev $_val)
_pdev=$(get_kdump_persistent_dev $_val) sed -i -e "s#^$_opt[[:space:]]\+$_val#$_opt $_pdev#" ${initdir}/tmp/$$-kdump.conf ;; ssh|nfs)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 74dac4c..0040483 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -301,6 +301,20 @@ get_kdump_mntpoint_from_target() echo $_mntpoint | tr -s "/" }
+get_kdump_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")
+}
# get_option_value <option_name> # retrieves value of option defined in kdump.conf get_option_value() { diff --git a/kdumpctl b/kdumpctl index 408b88a..8004783 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=$(get_kdump_persistent_dev $_target) if [ -z "$_new_dev" ]; then echo "Get persistent device name failed" return 2
diff --git a/mkdumprd b/mkdumprd index 7bc1bd1..c7b8f17 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="$(get_kdump_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" get_kdump_persistent_dev $config_val) if [ -z "$_praw" ]; then exit 1 fi
-- 2.26.2 _______________________________________________ kexec mailing list -- kexec@lists.fedoraproject.org To unsubscribe send an email to kexec-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org
Thanks Dave
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.
Signed-off-by: Kairui Song kasong@redhat.com --- mkdumprd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mkdumprd b/mkdumprd index c7b8f17..3378952 100644 --- a/mkdumprd +++ b/mkdumprd @@ -92,7 +92,7 @@ to_mount() {
_mntopts="$_new_mntpoint $_fstype $_options" # for non-nfs _target converting to use udev persistent name - if [ -b "$_target" ]; then + if [[ "$_fstype" != *nfs ]]; then _pdev="$(get_kdump_persistent_dev $_target)" if [ -z "$_pdev" ]; then return 1
Hi Kairui On 06/16/20 at 01:53pm, Kairui Song wrote:
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.
Signed-off-by: Kairui Song kasong@redhat.com
mkdumprd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mkdumprd b/mkdumprd index c7b8f17..3378952 100644 --- a/mkdumprd +++ b/mkdumprd @@ -92,7 +92,7 @@ to_mount() {
_mntopts="$_new_mntpoint $_fstype $_options" # for non-nfs _target converting to use udev persistent name
- if [ -b "$_target" ]; then
- if [[ "$_fstype" != *nfs ]]; then
In the same function we have "$_fstype" == "nfs"* check before this, "nfs"* is better than *nfs since no fstype will end with nfs but with some prefixes..
_pdev="$(get_kdump_persistent_dev $_target)" if [ -z "$_pdev" ]; then return 1
-- 2.26.2 _______________________________________________ kexec mailing list -- kexec@lists.fedoraproject.org To unsubscribe send an email to kexec-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org
Thanks Dave
On Tue, Jun 16, 2020 at 3:28 PM Dave Young dyoung@redhat.com wrote:
Hi Kairui On 06/16/20 at 01:53pm, Kairui Song wrote:
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.
Signed-off-by: Kairui Song kasong@redhat.com
mkdumprd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mkdumprd b/mkdumprd index c7b8f17..3378952 100644 --- a/mkdumprd +++ b/mkdumprd @@ -92,7 +92,7 @@ to_mount() {
_mntopts="$_new_mntpoint $_fstype $_options" # for non-nfs _target converting to use udev persistent name
- if [ -b "$_target" ]; then
- if [[ "$_fstype" != *nfs ]]; then
In the same function we have "$_fstype" == "nfs"* check before this, "nfs"* is better than *nfs since no fstype will end with nfs but with some prefixes..
Yes, you are right, I wanted to cover nfs3/nfs4 case but used wrong wildcard, will fix it.
_pdev="$(get_kdump_persistent_dev $_target)" if [ -z "$_pdev" ]; then return 1
-- 2.26.2 _______________________________________________ kexec mailing list -- kexec@lists.fedoraproject.org To unsubscribe send an email to kexec-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org
Thanks Dave