mkdumprd: Simplify handling of user specified target
For user specified target, the config value is used as the dump target, and SAVE_PATH (path in kdump.conf) value is used as the dump path within the dump target, no need to do anything extra with the path value. Current code logic is not only complicated, it also wrongly generate an redundantly long path in atomic/silverblue environment. The right way is only check two things, and do nothing else: 1. The path exists within the target; 2. The target is large enough to hold to contain the vmcore. Currently checking the target still requires it to be mounted so it will error out if it's not mounted. Will implement some auto mount as next step. Signed-off-by: Kairui Song <kasong@redhat.com> Acked-by: Lianbo Jiang <lijiang@redhat.com>
This commit is contained in:
parent
fd7e7be483
commit
b5b0b90521
29
kdump-lib.sh
29
kdump-lib.sh
@ -291,26 +291,6 @@ get_option_value() {
|
||||
strip_comments `grep "^$1[[:space:]]\+" /etc/kdump.conf | tail -1 | cut -d\ -f2-`
|
||||
}
|
||||
|
||||
#This function compose a absolute path with the mount
|
||||
#point and the relative $SAVE_PATH.
|
||||
#target is passed in as argument, could be UUID, LABEL,
|
||||
#block device or even nfs server export of the form of
|
||||
#"my.server.com:/tmp/export"?
|
||||
#And possibly this could be used for both default case
|
||||
#as well as when dump taret is specified. When dump
|
||||
#target is not specified, then $target would be null.
|
||||
make_absolute_save_path()
|
||||
{
|
||||
local _target=$1
|
||||
local _mnt
|
||||
|
||||
[ -n $_target ] && _mnt=$(get_mntpoint_from_target $1)
|
||||
_mnt="${_mnt}/$SAVE_PATH"
|
||||
|
||||
# strip the duplicated "/"
|
||||
echo "$_mnt" | tr -s /
|
||||
}
|
||||
|
||||
check_save_path_fs()
|
||||
{
|
||||
local _path=$1
|
||||
@ -320,6 +300,15 @@ check_save_path_fs()
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if path exists within dump target
|
||||
check_save_path_user_configured()
|
||||
{
|
||||
local _target=$1 _path=$2
|
||||
local _mnt=$(get_mntpoint_from_target $_target)
|
||||
|
||||
check_save_path_fs "$_mnt/$_path"
|
||||
}
|
||||
|
||||
is_atomic()
|
||||
{
|
||||
grep -q "ostree" /proc/cmdline
|
||||
|
15
mkdumprd
15
mkdumprd
@ -387,20 +387,13 @@ do
|
||||
perror_exit "Dump target $config_val is probably not mounted."
|
||||
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
|
||||
|
||||
# User configured target, use $SAVE_PATH as the dump path within the target
|
||||
check_save_path_user_configured "$config_val" "$SAVE_PATH"
|
||||
check_size fs "$config_val"
|
||||
add_mount "$config_val"
|
||||
check_save_path_fs $_absolute_save_path
|
||||
check_size fs $config_val
|
||||
;;
|
||||
raw)
|
||||
#checking raw disk writable
|
||||
# checking raw disk writable
|
||||
dd if=$config_val count=1 of=/dev/null > /dev/null 2>&1 || {
|
||||
perror_exit "Bad raw disk $config_val"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user