On 03/28/2017 at 01:37 PM, Pratyush Anand wrote:
Hi Xunlei,
On Monday 27 March 2017 08:12 AM, Xunlei Pang wrote:
> Consider block device in the special "--dracut-args --mount ..."
> in get_user_configured_dump_disk().
>
Above and below changes are not related. So, it would be good if they are in different
patches. IMHO, it should be divided in 3 patches for easier review.
1) Move stuff from kdumpctl to kdump-lib.sh (no functional change)
2) modification in get_block_dump_target()
3) consider block device in the special "--dracut-args --mount ..."
Yes, I will do it if sending next version. Thanks!
Regards,
Xunlei
~Pratyush
> Consider save path instead of only root fs in get_block_dump_target(),
> and move it into kdump-lib.sh, becuase we will use it in kdumpctl.
> We did not add it, because get_block_dump_target() is only used
> by check_resettable/check_crypt and users are expected to make
> to work for the special "--dracut-args --mount ...", anyway there
> is nothing wrong we add it in. We will have another user in the
> next patch.
>
> Moreover, for nfs/ssh dumping, we do not need check the root device.
>
> Move get_save_path into kdump-lib.sh.
>
> After this patch, get_block_dump_target() can always return our
> correct block dump target specified.
>
> Signed-off-by: Xunlei Pang <xlpang(a)redhat.com>
> ---
> kdump-lib.sh | 44 ++++++++++++++++++++++++++++++++++++--------
> kdumpctl | 10 ----------
> mkdumprd | 13 -------------
> 3 files changed, 36 insertions(+), 31 deletions(-)
>
> diff --git a/kdump-lib.sh b/kdump-lib.sh
> index 8ebad70..ae54b7f 100755
> --- a/kdump-lib.sh
> +++ b/kdump-lib.sh
> @@ -44,12 +44,6 @@ is_fs_dump_target()
> egrep -q "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf
> }
>
> -is_user_configured_dump_target()
> -{
> - return $(is_mount_in_dracut_args || is_ssh_dump_target || is_nfs_dump_target ||
\
> - is_raw_dump_target || is_fs_dump_target)
> -}
> -
> strip_comments()
> {
> echo $@ | sed -e 's/\(.*\)#.*/\1/'
> @@ -88,6 +82,12 @@ to_dev_name() {
> echo $dev
> }
>
> +is_user_configured_dump_target()
> +{
> + return $(is_mount_in_dracut_args || is_ssh_dump_target || is_nfs_dump_target ||
\
> + is_raw_dump_target || is_fs_dump_target)
> +}
> +
> get_user_configured_dump_disk()
> {
> local _target
> @@ -97,9 +97,10 @@ get_user_configured_dump_disk()
> fi
>
> _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw" /etc/kdump.conf
2>/dev/null |awk '{print $2}')
> - [ -n "$_target" ] && echo $_target
> + [ -n "$_target" ] && echo $_target && return
>
> - return
> + _target=$(get_dracut_args_target "$(grep "^dracut_args
.*\-\-mount" /etc/kdump.conf)")
> + [ -b "$_target" ] && echo $_target
> }
>
> get_root_fs_device()
> @@ -111,6 +112,33 @@ get_root_fs_device()
> return
> }
>
> +get_save_path()
> +{
> + local _save_path=$(grep "^path" /etc/kdump.conf|awk '{print
$2}')
> + if [ -z "$_save_path" ]; then
> + _save_path=$DEFAULT_PATH
> + fi
> +
> + echo $_save_path
> +}
> +
> +get_block_dump_target()
> +{
> + local _target _path
> +
> + _target=$(get_user_configured_dump_disk)
> + [ -n "$_target" ] && echo $(to_dev_name $_target) &&
return
> +
> + if is_ssh_dump_target || is_nfs_dump_target; then
> + return
> + fi
> +
> + # Get block device name from local save path
> + _path=$(get_save_path)
> + _target=$(get_target_from_path $_path)
> + [ -b "$_target" ] && echo $(to_dev_name $_target)
> +}
> +
> # 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.
> diff --git a/kdumpctl b/kdumpctl
> index 4d68be0..d8f049f 100755
> --- a/kdumpctl
> +++ b/kdumpctl
> @@ -930,16 +930,6 @@ save_raw()
> return 0
> }
>
> -get_save_path()
> -{
> - local _save_path=$(grep "^path" /etc/kdump.conf|awk '{print
$2}')
> - if [ -z "$_save_path" ]; then
> - _save_path="/var/crash"
> - fi
> -
> - echo $_save_path
> -}
> -
> is_dump_target_configured()
> {
> local _target
> diff --git a/mkdumprd b/mkdumprd
> index f30d9c2..426149b 100644
> --- a/mkdumprd
> +++ b/mkdumprd
> @@ -256,19 +256,6 @@ add_mount() {
> fi
> }
>
> -get_block_dump_target()
> -{
> - local _target
> -
> -
> - _target=$(get_user_configured_dump_disk)
> - [ -n "$_target" ] && echo $(to_dev_name $_target) &&
return
> -
> - #get rootfs device name
> - _target=$(get_root_fs_device)
> - [ -b "$_target" ] && echo $(to_dev_name $_target)
> -}
> -
> #handle the case user does not specify the dump target explicitly
> handle_default_dump_target()
> {
>