Enhance kdump to support bind mounted target, since kdump cann't parse the bind mounted path.
Following is the testcases which kdump can generate the core sucessfully. 1) rootfs, default path / specified path 2) rootfs with bind mounted path which is in the rootfs device # cat /etc/kdump | grep ^path path /var/crash # mount -o bind /var/crash /mnt/crash 4) rootfs with bind mounted path which is not in the rootfs device # cat /etc/kdump | grep ^path path /var/crash # mount /dev/vdb /mnt # mount -o bind /var/crash /mnt/crash 5) no-rootfs 6) no-rootfs with bind mounted path which is in the same device 7) no-rootfs with bind mounted path which is not in the same device 8) nfs 9) nfs with bind mounted path which is under the nfs mount point path # cat /etc/kdump | grep ^nfs nfs 192.168.122.134:/opt/crash # cat /etc/kdump | grep ^path path /var/crash # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # mount -o bind /mnt/nfs/var/crash /mnt/nfs/dump 10) nfs with bind mounted path which is not under the nfs mount point path # cat /etc/kdump | grep ^nfs nfs 192.168.122.134:/opt/crash # cat /etc/kdump | grep ^path path /var/crash # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # mount -o bind /mnt/nfs/var/crash /mnt/dump 11) nfs which don't specify the nfs option in the /etc/kdump, with bind mounted path which is under the nfs mount point path # cat /etc/kdump | grep ^nfs # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # cat /etc/kdump | grep ^path path /mnt/nfs/var/crash # mount -o bind /mnt/nfs/var/crash /mnt/nfs/dump 12) nfs which don't specify the nfs option in the /etc/kdump, with bind mounted path which is not under the nfs mount point path # cat /etc/kdump | grep ^nfs # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # cat /etc/kdump | grep ^path path /mnt/nfs/var/crash # mount -o bind /mnt/nfs/var/crash /mnt/dump 13) ext4 14) ext4 with bind mounted path which is under the ext4 mount point path 15) ext4 with bind mounted path which is not under the ext4 mount point path 16) btrfs 17) btrfs with subvolume which mounts under mount point path 18) btrfs with subvolume which does not mount under mount point path
--- changelog: v3: - modify the commit log and annotation properly - use function is_atomic as the judgement in check_boot_dir v2: - bisect the patch to make it clear to be reviewed - add the necessary function decription v1: - add the judgment to make it work only in Atomic ---
Minfei Huang (5): kdump-lib: Add the new function to enhance bind mounted judgement kdump-lib: Add new function to judge the system is Atomic or not Get the mount point correctly, if the device has several mount point Fix the warning if the target path is bind mount in Atomic dracut-module-setup: Enhance kdump to support the bind mounted feature in Atomic
dracut-module-setup.sh | 43 +++++++++++++++++++++++++++++-- kdump-lib.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++++-- kdumpctl | 4 +-- mkdumprd | 30 ++++++++++++++++------ 4 files changed, 131 insertions(+), 14 deletions(-)
findmnt uses the option "-v, --nofsroot" to exclude the [/dir] in the SOURCE column for bind-mounts, then if $_mntpoint equals to $_mntpoint_nofsroot, the mountpoint is not bind mounted directory.
the value of $_mntpoint may be like /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the directory is bind mounted. The former part represents the device path, the rest part is the bind mounted directory which quotes by bracket "[]".
Signed-off-by: Minfei Huang mhuang@redhat.com Acked-by: Dave Young dyoung@redhat.com --- kdump-lib.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/kdump-lib.sh b/kdump-lib.sh index f24f08d..ca7563a 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -86,6 +86,38 @@ get_root_fs_device() return }
+# findmnt uses the option "-v, --nofsroot" to exclusive the [/dir] +# in the SOURCE column for bind-mounts, then if $_mntpoint equals to +# $_mntpoint_nofsroot, the mountpoint is not bind mounted directory. +is_bind_mount() +{ + local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}') + local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print $2}') + + if [[ $_mntpoint = $_mntpoint_nofsroot ]]; then + return 1 + else + return 0 + fi +} + +# Below is just an example for mount info +# /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the +# directory is bind mounted. The former part represents the device path, rest +# part is the bind mounted directory which quotes by bracket "[]". +get_bind_mount_directory() +{ + local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}') + local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print $2}') + + _mntpoint=${_mntpoint#*$_mntpoint_nofsroot} + + _mntpoint=${_mntpoint#[} + _mntpoint=${_mntpoint%]} + + echo $_mntpoint +} + get_mntpoint_from_path() { echo $(df $1 | tail -1 | awk '{print $NF}')
For Atomic system, the cmdline will contain the specific string "ostree". So we can filter out the "ostree" to judge the system is Atomic or not.
Signed-off-by: Minfei Huang mhuang@redhat.com --- kdump-lib.sh | 5 +++++ kdumpctl | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index ca7563a..8b0516f 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -220,3 +220,8 @@ is_ipv6_target() _server=${_server:-$_server_tmp} echo $_server | grep -q ":" } + +is_atomic() +{ + grep -q "ostree" /proc/cmdline +} diff --git a/kdumpctl b/kdumpctl index 31ceb47..ca053a1 100755 --- a/kdumpctl +++ b/kdumpctl @@ -294,14 +294,12 @@ get_pcs_cluster_modified_files()
check_boot_dir() { - local _is_atomic #If user specify a boot dir for kdump kernel, let's use it. Otherwise #check whether it's a atomic host. If yes parse the subdirectory under #/boot; If not just find it under /boot. [ -n "$KDUMP_BOOTDIR" ] && return
- _is_atomic=$(cat /proc/cmdline | grep "ostree") - if [ -z "$_is_atomic" ] || [ "$(uname -m)" = "s390x" ]; then + if ! is_atomic || [ "$(uname -m)" = "s390x" ]; then KDUMP_BOOTDIR="/boot" else eval $(cat /proc/cmdline| grep "BOOT_IMAGE" | cut -d' ' -f1)
Any block device can be mounted multiply on the different mount point. Once a mount point is mounted in bind mode, the general mount point can be unmounted. Thus kdump would not find the general mount point[1] to handle the path.
The mount point, which is as general mount point, will be got by "fintmnt" previously. But the mntpoint may be incorrect, if the mntpoint is bind mount.
In order to fix it to support bind mounted in atomic, we will add a judgement to comfirm the mntpoint is bind mounted, or not.
For general mount, returning path is like following, if we use "findmnt". The returning is same as "findmnt -v".
-bash-4.2# findmnt /var | tail -n 1 | awk '{print $2}' /dev/mapper/atomicos-root
But for bind mount, returning path is like following, if we use "fintmnt". -bash-4.2# findmnt /var | tail -n 1 | awk '{print $2}' /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var]
Use "findmnt -v" is like this: -bash-4.2# findmnt -v /var | tail -n 1 | awk '{print $2}' /dev/mapper/atomicos-root
So we can determine the bind mount, if the returning is different between "findmnt" and "findmnt -v".
[1] general mount point is a directory without being in bind mounted mode, just a normal directory.
Signed-off-by: Minfei Huang mhuang@redhat.com Acked-by: Dave Young dyoung@redhat.com --- kdump-lib.sh | 26 +++++++++++++++++++++++++- mkdumprd | 8 ++------ 2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 8b0516f..5333fe4 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -133,9 +133,33 @@ get_fs_type_from_target() echo $(findmnt -k -f -n -r -o FSTYPE $1) }
+# input: device path +# output: the general mount point +# find the general mount point, not the bind mounted point in atomic +# As general system, Use the previous code +# +# ERROR and EXIT: +# the device can be umounted the general mount point, if one of the mount point is bind mounted +# For example: +# mount /dev/sda /mnt/ +# mount -o bind /mnt/var /var +# umount /mnt get_mntpoint_from_target() { - echo $(findmnt -k -f -n -r -o TARGET $1) + if is_atomic; then + for _mnt in $(findmnt -k -n -r -o TARGET $1) + do + if ! is_bind_mount $_mnt; then + echo $_mnt + return + fi + done + + echo "Mount $1 firstly, without the bind mode" >&2 + exit 1 + else + echo $(findmnt -k -f -n -r -o TARGET $1) + fi }
# get_option_value <option_name> diff --git a/mkdumprd b/mkdumprd index 7c572a7..14ec70f 100644 --- a/mkdumprd +++ b/mkdumprd @@ -103,7 +103,7 @@ to_mount() { local _dev=$1 _source _target _fstype _options _mntopts _pdev
_source=$(findmnt -k -f -n -r -o SOURCE $_dev) - _target=$(findmnt -k -f -n -r -o TARGET $_dev) + _target=$(get_mntpoint_from_target $_dev) # mount under /sysroot if dump to root disk or mount under #/kdumproot/$_target in other cases in 2nd kernel. systemd #will be in charge to umount it. @@ -147,10 +147,6 @@ to_mount() { echo "$_pdev $_mntopts" }
-to_mount_point() { - echo $(findmnt -k -f -n -r -o TARGET $1) -} - is_readonly_mount() { local _mnt _mnt=$(findmnt -k -f -n -r -o OPTIONS $1) @@ -204,7 +200,7 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() { - local _mnt=$(to_mount_point $1) + local _mnt=$(get_mntpoint_from_target $1) echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}') }
kdump will raise the warning in Atomic, if the path is bind mounted directory. The reason why causes this issue is kdump cannt parse the bind mounted directory.
To correct dumping target, we can construct the real dumping path in Atomic, which contains two part, one bind mounted path, the other specified dump target.
Following is an example: -bash-4.2# cat /etc/kdump.conf | grep ^path path /var/crash
-bash-4.2# findmnt /var | tail -n 1 | awk '{print $2}' /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var]
-bash-4.2# findmnt -v /var | tail -n 1 | awk '{print $2}' /dev/mapper/atomicos-root
Then we can found it that the real path of dumping vmcore is /ostree/deploy/rhel-atomic-host/var/crash.
To fix this issue, we can replace the target path as the real path which is from above parsing.
Signed-off-by: Minfei Huang mhuang@redhat.com --- kdump-lib.sh | 5 ++++- mkdumprd | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 5333fe4..2abb513 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -182,7 +182,10 @@ make_absolute_save_path() local _mnt
[ -n $_target ] && _mnt=$(get_mntpoint_from_target $1) - echo "${_mnt}/$SAVE_PATH" + _mnt="${_mnt}/$SAVE_PATH" + + # strip the duplicated "/" + echo "$_mnt" | tr -s / }
check_save_path_fs() diff --git a/mkdumprd b/mkdumprd index 14ec70f..8cf3c7b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -362,6 +362,17 @@ handle_default_dump_target()
_mntpoint=$(get_mntpoint_from_path $SAVE_PATH) _target=$(get_target_from_path $SAVE_PATH) + + if is_atomic && is_bind_mount $_mntpoint; then + SAVE_PATH=${SAVE_PATH##"$_mntpoint"} + # the real dump path in the 2nd kernel, if the mount point is bind mounted. + SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH + _mntpoint=$(get_mntpoint_from_target $_target) + + # the absolute path in the 1st kernel + SAVE_PATH=$_mntpoint/$SAVE_PATH + fi + if [ "$_mntpoint" != "/" ]; then SAVE_PATH=${SAVE_PATH##"$_mntpoint"} _fstype=$(get_fs_type_from_target $_target) @@ -533,8 +544,17 @@ do if [ "$config_opt" = "nfs" ]; then add_dracut_module "nfs" fi + + _absolute_save_path=$(make_absolute_save_path $config_val) + _mntpoint=$(get_mntpoint_from_path $_absolute_save_path) + if is_atomic && is_bind_mount $_mntpoint; then + SAVE_PATH=${_absolute_save_path##"$_mntpoint"} + # the real dump path in the 2nd kernel, if the mount point is bind mounted. + SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH + fi + add_mount "$config_val" - check_save_path_fs $(make_absolute_save_path $config_val) + check_save_path_fs $_absolute_save_path check_size fs $config_val ;; raw)
On 04/17/15 at 04:26pm, Minfei Huang wrote:
kdump will raise the warning in Atomic, if the path is bind mounted directory. The reason why causes this issue is kdump cannt parse the bind mounted directory.
To correct dumping target, we can construct the real dumping path in Atomic, which contains two part, one bind mounted path, the other specified dump target.
Following is an example: -bash-4.2# cat /etc/kdump.conf | grep ^path path /var/crash
-bash-4.2# findmnt /var | tail -n 1 | awk '{print $2}' /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var] -bash-4.2# findmnt -v /var | tail -n 1 | awk '{print $2}' /dev/mapper/atomicos-root
Then we can found it that the real path of dumping vmcore is /ostree/deploy/rhel-atomic-host/var/crash.
To fix this issue, we can replace the target path as the real path which is from above parsing.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 5 ++++- mkdumprd | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 5333fe4..2abb513 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -182,7 +182,10 @@ make_absolute_save_path() local _mnt
[ -n $_target ] && _mnt=$(get_mntpoint_from_target $1)
- echo "${_mnt}/$SAVE_PATH"
- _mnt="${_mnt}/$SAVE_PATH"
- # strip the duplicated "/"
- echo "$_mnt" | tr -s /
}
check_save_path_fs() diff --git a/mkdumprd b/mkdumprd index 14ec70f..8cf3c7b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -362,6 +362,17 @@ handle_default_dump_target()
_mntpoint=$(get_mntpoint_from_path $SAVE_PATH) _target=$(get_target_from_path $SAVE_PATH)
- if is_atomic && is_bind_mount $_mntpoint; then
SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
# the real dump path in the 2nd kernel, if the mount point is bind mounted.
SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH
_mntpoint=$(get_mntpoint_from_target $_target)
# the absolute path in the 1st kernel
SAVE_PATH=$_mntpoint/$SAVE_PATH
- fi
- if [ "$_mntpoint" != "/" ]; then SAVE_PATH=${SAVE_PATH##"$_mntpoint"} _fstype=$(get_fs_type_from_target $_target)
@@ -533,8 +544,17 @@ do if [ "$config_opt" = "nfs" ]; then add_dracut_module "nfs" fi
_absolute_save_path=$(make_absolute_save_path $config_val)
What the use of below section? They are redundant?
_mntpoint=$(get_mntpoint_from_path $_absolute_save_path)
if is_atomic && is_bind_mount $_mntpoint; then
SAVE_PATH=${_absolute_save_path##"$_mntpoint"}
# the real dump path in the 2nd kernel, if the mount point is bind mounted.
SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH
fi
add_mount "$config_val"
check_save_path_fs $(make_absolute_save_path $config_val)
raw)check_save_path_fs $_absolute_save_path check_size fs $config_val ;;
-- 1.9.3
On 04/20/15 at 09:43am, Dave Young wrote:
On 04/17/15 at 04:26pm, Minfei Huang wrote:
kdump will raise the warning in Atomic, if the path is bind mounted directory. The reason why causes this issue is kdump cannt parse the bind mounted directory.
To correct dumping target, we can construct the real dumping path in Atomic, which contains two part, one bind mounted path, the other specified dump target.
Following is an example: -bash-4.2# cat /etc/kdump.conf | grep ^path path /var/crash
-bash-4.2# findmnt /var | tail -n 1 | awk '{print $2}' /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var] -bash-4.2# findmnt -v /var | tail -n 1 | awk '{print $2}' /dev/mapper/atomicos-root
Then we can found it that the real path of dumping vmcore is /ostree/deploy/rhel-atomic-host/var/crash.
To fix this issue, we can replace the target path as the real path which is from above parsing.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 5 ++++- mkdumprd | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 5333fe4..2abb513 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -182,7 +182,10 @@ make_absolute_save_path() local _mnt
[ -n $_target ] && _mnt=$(get_mntpoint_from_target $1)
- echo "${_mnt}/$SAVE_PATH"
- _mnt="${_mnt}/$SAVE_PATH"
- # strip the duplicated "/"
- echo "$_mnt" | tr -s /
}
check_save_path_fs() diff --git a/mkdumprd b/mkdumprd index 14ec70f..8cf3c7b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -362,6 +362,17 @@ handle_default_dump_target()
_mntpoint=$(get_mntpoint_from_path $SAVE_PATH) _target=$(get_target_from_path $SAVE_PATH)
- if is_atomic && is_bind_mount $_mntpoint; then
SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
# the real dump path in the 2nd kernel, if the mount point is bind mounted.
SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH
_mntpoint=$(get_mntpoint_from_target $_target)
# the absolute path in the 1st kernel
SAVE_PATH=$_mntpoint/$SAVE_PATH
- fi
- if [ "$_mntpoint" != "/" ]; then SAVE_PATH=${SAVE_PATH##"$_mntpoint"} _fstype=$(get_fs_type_from_target $_target)
@@ -533,8 +544,17 @@ do if [ "$config_opt" = "nfs" ]; then add_dracut_module "nfs" fi
_absolute_save_path=$(make_absolute_save_path $config_val)
What the use of below section? They are redundant?
Talked with Baoquan, SAVE_PATH is used in check_size function, it is not easy to find. Moving functions to lib but still using global variables is bad to me
But it is another issue, we can do a cleanup later.
_mntpoint=$(get_mntpoint_from_path $_absolute_save_path)
if is_atomic && is_bind_mount $_mntpoint; then
SAVE_PATH=${_absolute_save_path##"$_mntpoint"}
# the real dump path in the 2nd kernel, if the mount point is bind mounted.
SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH
fi
add_mount "$config_val"
check_save_path_fs $(make_absolute_save_path $config_val)
raw)check_save_path_fs $_absolute_save_path check_size fs $config_val ;;
-- 1.9.3
On 04/20/15 at 10:23am, Dave Young wrote:
On 04/20/15 at 09:43am, Dave Young wrote:
On 04/17/15 at 04:26pm, Minfei Huang wrote:
kdump will raise the warning in Atomic, if the path is bind mounted directory. The reason why causes this issue is kdump cannt parse the bind mounted directory.
To correct dumping target, we can construct the real dumping path in Atomic, which contains two part, one bind mounted path, the other specified dump target.
Following is an example: -bash-4.2# cat /etc/kdump.conf | grep ^path path /var/crash
-bash-4.2# findmnt /var | tail -n 1 | awk '{print $2}' /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var] -bash-4.2# findmnt -v /var | tail -n 1 | awk '{print $2}' /dev/mapper/atomicos-root
Then we can found it that the real path of dumping vmcore is /ostree/deploy/rhel-atomic-host/var/crash.
To fix this issue, we can replace the target path as the real path which is from above parsing.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 5 ++++- mkdumprd | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 5333fe4..2abb513 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -182,7 +182,10 @@ make_absolute_save_path() local _mnt
[ -n $_target ] && _mnt=$(get_mntpoint_from_target $1)
- echo "${_mnt}/$SAVE_PATH"
- _mnt="${_mnt}/$SAVE_PATH"
- # strip the duplicated "/"
- echo "$_mnt" | tr -s /
}
check_save_path_fs() diff --git a/mkdumprd b/mkdumprd index 14ec70f..8cf3c7b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -362,6 +362,17 @@ handle_default_dump_target()
_mntpoint=$(get_mntpoint_from_path $SAVE_PATH) _target=$(get_target_from_path $SAVE_PATH)
- if is_atomic && is_bind_mount $_mntpoint; then
SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
# the real dump path in the 2nd kernel, if the mount point is bind mounted.
SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH
_mntpoint=$(get_mntpoint_from_target $_target)
# the absolute path in the 1st kernel
SAVE_PATH=$_mntpoint/$SAVE_PATH
- fi
- if [ "$_mntpoint" != "/" ]; then SAVE_PATH=${SAVE_PATH##"$_mntpoint"} _fstype=$(get_fs_type_from_target $_target)
@@ -533,8 +544,17 @@ do if [ "$config_opt" = "nfs" ]; then add_dracut_module "nfs" fi
_absolute_save_path=$(make_absolute_save_path $config_val)
What the use of below section? They are redundant?
Talked with Baoquan, SAVE_PATH is used in check_size function, it is not easy to find. Moving functions to lib but still using global variables is bad to me
SAVE_PATH is used in mkdumprd only.
Yes, I will do a cleanup after these patch set megered, and move the function make_absolute_save_path from kdump-lib.sh to mkdumprd.
Thanks Minfei
But it is another issue, we can do a cleanup later.
_mntpoint=$(get_mntpoint_from_path $_absolute_save_path)
if is_atomic && is_bind_mount $_mntpoint; then
SAVE_PATH=${_absolute_save_path##"$_mntpoint"}
# the real dump path in the 2nd kernel, if the mount point is bind mounted.
SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH
fi
add_mount "$config_val"
check_save_path_fs $(make_absolute_save_path $config_val)
raw)check_save_path_fs $_absolute_save_path check_size fs $config_val ;;
-- 1.9.3
On 04/20/15 at 12:00pm, Minfei Huang wrote:
On 04/20/15 at 10:23am, Dave Young wrote:
On 04/20/15 at 09:43am, Dave Young wrote:
On 04/17/15 at 04:26pm, Minfei Huang wrote:
kdump will raise the warning in Atomic, if the path is bind mounted directory. The reason why causes this issue is kdump cannt parse the bind mounted directory.
To correct dumping target, we can construct the real dumping path in Atomic, which contains two part, one bind mounted path, the other specified dump target.
Following is an example: -bash-4.2# cat /etc/kdump.conf | grep ^path path /var/crash
-bash-4.2# findmnt /var | tail -n 1 | awk '{print $2}' /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var] -bash-4.2# findmnt -v /var | tail -n 1 | awk '{print $2}' /dev/mapper/atomicos-root
Then we can found it that the real path of dumping vmcore is /ostree/deploy/rhel-atomic-host/var/crash.
To fix this issue, we can replace the target path as the real path which is from above parsing.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 5 ++++- mkdumprd | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 5333fe4..2abb513 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -182,7 +182,10 @@ make_absolute_save_path() local _mnt
[ -n $_target ] && _mnt=$(get_mntpoint_from_target $1)
- echo "${_mnt}/$SAVE_PATH"
- _mnt="${_mnt}/$SAVE_PATH"
- # strip the duplicated "/"
- echo "$_mnt" | tr -s /
}
check_save_path_fs() diff --git a/mkdumprd b/mkdumprd index 14ec70f..8cf3c7b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -362,6 +362,17 @@ handle_default_dump_target()
_mntpoint=$(get_mntpoint_from_path $SAVE_PATH) _target=$(get_target_from_path $SAVE_PATH)
- if is_atomic && is_bind_mount $_mntpoint; then
SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
# the real dump path in the 2nd kernel, if the mount point is bind mounted.
SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH
_mntpoint=$(get_mntpoint_from_target $_target)
# the absolute path in the 1st kernel
SAVE_PATH=$_mntpoint/$SAVE_PATH
- fi
- if [ "$_mntpoint" != "/" ]; then SAVE_PATH=${SAVE_PATH##"$_mntpoint"} _fstype=$(get_fs_type_from_target $_target)
@@ -533,8 +544,17 @@ do if [ "$config_opt" = "nfs" ]; then add_dracut_module "nfs" fi
_absolute_save_path=$(make_absolute_save_path $config_val)
What the use of below section? They are redundant?
Talked with Baoquan, SAVE_PATH is used in check_size function, it is not easy to find. Moving functions to lib but still using global variables is bad to me
SAVE_PATH is used in mkdumprd only.
Yes, I will do a cleanup after these patch set megered, and move the function make_absolute_save_path from kdump-lib.sh to mkdumprd.
No, it is get_size function which is using global $SAVE_PATH. What I thouht is do not use global variable in lib function, instead we should pass it as arguments.
Thanks Dave
On 04/20/15 at 04:17pm, Dave Young wrote:
On 04/20/15 at 12:00pm, Minfei Huang wrote:
On 04/20/15 at 10:23am, Dave Young wrote:
On 04/20/15 at 09:43am, Dave Young wrote:
On 04/17/15 at 04:26pm, Minfei Huang wrote:
kdump will raise the warning in Atomic, if the path is bind mounted directory. The reason why causes this issue is kdump cannt parse the bind mounted directory.
To correct dumping target, we can construct the real dumping path in Atomic, which contains two part, one bind mounted path, the other specified dump target.
Following is an example: -bash-4.2# cat /etc/kdump.conf | grep ^path path /var/crash
-bash-4.2# findmnt /var | tail -n 1 | awk '{print $2}' /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var] -bash-4.2# findmnt -v /var | tail -n 1 | awk '{print $2}' /dev/mapper/atomicos-root
Then we can found it that the real path of dumping vmcore is /ostree/deploy/rhel-atomic-host/var/crash.
To fix this issue, we can replace the target path as the real path which is from above parsing.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 5 ++++- mkdumprd | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 5333fe4..2abb513 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -182,7 +182,10 @@ make_absolute_save_path() local _mnt
[ -n $_target ] && _mnt=$(get_mntpoint_from_target $1)
- echo "${_mnt}/$SAVE_PATH"
- _mnt="${_mnt}/$SAVE_PATH"
- # strip the duplicated "/"
- echo "$_mnt" | tr -s /
}
check_save_path_fs() diff --git a/mkdumprd b/mkdumprd index 14ec70f..8cf3c7b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -362,6 +362,17 @@ handle_default_dump_target()
_mntpoint=$(get_mntpoint_from_path $SAVE_PATH) _target=$(get_target_from_path $SAVE_PATH)
- if is_atomic && is_bind_mount $_mntpoint; then
SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
# the real dump path in the 2nd kernel, if the mount point is bind mounted.
SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH
_mntpoint=$(get_mntpoint_from_target $_target)
# the absolute path in the 1st kernel
SAVE_PATH=$_mntpoint/$SAVE_PATH
- fi
- if [ "$_mntpoint" != "/" ]; then SAVE_PATH=${SAVE_PATH##"$_mntpoint"} _fstype=$(get_fs_type_from_target $_target)
@@ -533,8 +544,17 @@ do if [ "$config_opt" = "nfs" ]; then add_dracut_module "nfs" fi
_absolute_save_path=$(make_absolute_save_path $config_val)
What the use of below section? They are redundant?
Talked with Baoquan, SAVE_PATH is used in check_size function, it is not easy to find. Moving functions to lib but still using global variables is bad to me
SAVE_PATH is used in mkdumprd only.
Yes, I will do a cleanup after these patch set megered, and move the function make_absolute_save_path from kdump-lib.sh to mkdumprd.
No, it is get_size function which is using global $SAVE_PATH. What I thouht is do not use global variable in lib function, instead we should pass it as arguments.
Sure.
Since the deadline is coming, I prefer to do it later. I will do a cleanup to remove the global variable.
Thanks Minfei
Thanks Dave
Kdump will dump the vmcore in incorrect target directory, if the target is bind mounted.
As commented in the previous patch, we can construct the real path in Atomic, which contains two part, one bind mounted path, the other specified dump path. Then replace the path as the real path in /etc/kdump.conf.
findmnt can find the real path for nfs, although the path is in bind mode. So nfs can work well with the path in bind mode.
Signed-off-by: Minfei Huang mhuang@redhat.com Acked-by: Dave Young dyoung@redhat.com --- dracut-module-setup.sh | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 540e154..73ab938 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -311,8 +311,7 @@ kdump_install_net() { default_dump_target_install_conf() { local _target _fstype - local _mntpoint - local _save_path + local _mntpoint _save_path
is_user_configured_dump_target && return
@@ -324,6 +323,17 @@ default_dump_target_install_conf()
_mntpoint=$(get_mntpoint_from_path $_save_path) _target=$(get_target_from_path $_save_path) + + if is_atomic && is_bind_mount $_mntpoint; then + _save_path=${_save_path##"$_mntpoint"} + # the real dump path in the 2nd kernel, if the mount point is bind mounted. + _save_path=$(get_bind_mount_directory $_mntpoint)/$_save_path + _mntpoint=$(get_mntpoint_from_target $_target) + + # the absolute path in the 1st kernel + _save_path=$_mntpoint/$_save_path + fi + if [ "$_mntpoint" != "/" ]; then _fstype=$(get_fs_type_from_target $_target)
@@ -336,7 +346,33 @@ default_dump_target_install_conf()
echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf
+ # strip the duplicated "/" + _save_path=$(echo $_save_path | tr -s /) _save_path=${_save_path##"$_mntpoint"} + fi + + #erase the old path line, then insert the parsed path + sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf + echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf +} + +adjust_bind_mount_path() +{ + local _target=$1 + local _save_path=$(get_option_value "path") + [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH + + # strip the duplicated "/" + _save_path=$(echo $_save_path | tr -s /) + + local _absolute_save_path=$(get_mntpoint_from_target $_target)/$_save_path + _absolute_save_path=$(echo "$_absolute_save_path" | tr -s /) + local _mntpoint=$(get_mntpoint_from_path $_absolute_save_path) + + if is_bind_mount $_mntpoint; then + _save_path=${_absolute_save_path##"$_mntpoint"} + # the real dump path in the 2nd kernel, if the mount point is bind mounted. + _save_path=$(get_bind_mount_directory $_mntpoint)/$_save_path
#erase the old path line, then insert the parsed path sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf @@ -355,6 +391,9 @@ kdump_install_conf() { case "$config_opt" in ext[234]|xfs|btrfs|minix|raw) sed -i -e "s#^$config_opt[[:space:]]+$config_val#$config_opt $(kdump_to_udev_name $config_val)#" ${initdir}/tmp/$$-kdump.conf + if is_atomic; then + adjust_bind_mount_path "$config_val" + fi ;; ssh|nfs) kdump_install_net "$config_val"
On 04/17/15 at 04:26pm, Minfei Huang wrote:
Enhance kdump to support bind mounted target, since kdump cann't parse the bind mounted path.
Ack the whole patch series. Thank Minfei for your effort.
Acked-by: Baoquan He bhe@redhat.com
Following is the testcases which kdump can generate the core sucessfully.
- rootfs, default path / specified path
- rootfs with bind mounted path which is in the rootfs device # cat /etc/kdump | grep ^path path /var/crash # mount -o bind /var/crash /mnt/crash
- rootfs with bind mounted path which is not in the rootfs device # cat /etc/kdump | grep ^path path /var/crash # mount /dev/vdb /mnt # mount -o bind /var/crash /mnt/crash
- no-rootfs
- no-rootfs with bind mounted path which is in the same device
- no-rootfs with bind mounted path which is not in the same device
- nfs
- nfs with bind mounted path which is under the nfs mount point path # cat /etc/kdump | grep ^nfs nfs 192.168.122.134:/opt/crash # cat /etc/kdump | grep ^path path /var/crash # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # mount -o bind /mnt/nfs/var/crash /mnt/nfs/dump
- nfs with bind mounted path which is not under the nfs mount point path # cat /etc/kdump | grep ^nfs nfs 192.168.122.134:/opt/crash # cat /etc/kdump | grep ^path path /var/crash # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # mount -o bind /mnt/nfs/var/crash /mnt/dump
- nfs which don't specify the nfs option in the /etc/kdump, with bind mounted path which is under the nfs mount point path # cat /etc/kdump | grep ^nfs # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # cat /etc/kdump | grep ^path path /mnt/nfs/var/crash # mount -o bind /mnt/nfs/var/crash /mnt/nfs/dump
- nfs which don't specify the nfs option in the /etc/kdump, with bind mounted path which is not under the nfs mount point path # cat /etc/kdump | grep ^nfs # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # cat /etc/kdump | grep ^path path /mnt/nfs/var/crash # mount -o bind /mnt/nfs/var/crash /mnt/dump
- ext4
- ext4 with bind mounted path which is under the ext4 mount point path
- ext4 with bind mounted path which is not under the ext4 mount point path
- btrfs
- btrfs with subvolume which mounts under mount point path
- btrfs with subvolume which does not mount under mount point path
changelog: v3:
- modify the commit log and annotation properly
- use function is_atomic as the judgement in check_boot_dir
v2:
- bisect the patch to make it clear to be reviewed
- add the necessary function decription
v1:
- add the judgment to make it work only in Atomic
Minfei Huang (5): kdump-lib: Add the new function to enhance bind mounted judgement kdump-lib: Add new function to judge the system is Atomic or not Get the mount point correctly, if the device has several mount point Fix the warning if the target path is bind mount in Atomic dracut-module-setup: Enhance kdump to support the bind mounted feature in Atomic
dracut-module-setup.sh | 43 +++++++++++++++++++++++++++++-- kdump-lib.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++++-- kdumpctl | 4 +-- mkdumprd | 30 ++++++++++++++++------ 4 files changed, 131 insertions(+), 14 deletions(-)
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec