On 04/06/17 at 02:24pm, Xunlei Pang wrote:
On 04/06/2017 at 02:18 PM, Dave Young wrote:
> On 04/05/17 at 07:34pm, Xunlei Pang wrote:
>> Since the current dracut of Fedora already supports not always
>> mounting root device, we can remove "root=X" from the command
>> line directly, and always get the dump target specified in
>> "/etc/kdump.conf" and mount it. If the dump target is located
>> at root filesystem, we will add the root mount info explicitly
>> from kdump side instead of from dracut side.
>>
>> For example, in case of nfs/ssh/usb/raw/etc(non-root) dumping,
>> kdump will not mount the unnecessary root fs after this change.
>>
>> This patch removes "root=X" via the
"KDUMP_COMMANDLINE_REMOVE"
>> (if "default dump_to_rootfs" is specified, don't remove
"root=X"),
>> and mounts non-root target under "/kdumproot", the root target
>> still under "/sysroot"(to be align with systemd sysroot.mount).
>>
>> After removing "root=X", we now add root fs mount information
>> explicitly from the kdump side.
>>
>> Changed check_dump_fs_modified() a little to avoid rebuild when
>> dump target is root, since we add root fs mount explicitly now.
>>
>> Signed-off-by: Xunlei Pang <xlpang(a)redhat.com>
>> ---
>> v1->v2:
>> - Merged previous Patch1 "module-setup: install network for diskless
environment".
>> - Treat root dump target the same way in default_dump_target_install_conf().
>> - Confirmed special root targets such as "nfs root", "iscsi
root", etc.
>> - Confirmed fadump should be avoided.
>>
>> dracut-module-setup.sh | 24 ++++++++++++------------
>> kdumpctl | 31 ++++++++++++++++++++++++++-----
>> mkdumprd | 29 +++++++++--------------------
>> 3 files changed, 47 insertions(+), 37 deletions(-)
>>
>> diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
>> index bdf67ce..9f88b4e 100755
>> --- a/dracut-module-setup.sh
>> +++ b/dracut-module-setup.sh
>> @@ -390,20 +390,20 @@ default_dump_target_install_conf()
>> _save_path=$_mntpoint/$_save_path
>> fi
>>
>> - if [ "$_mntpoint" != "/" ]; then
>> - _fstype=$(get_fs_type_from_target $_target)
>> -
>> - if $(is_fs_type_nfs $_fstype); then
>> - kdump_install_net "$_target"
>> - _fstype="nfs"
>> - else
>> - _target=$(kdump_get_persistent_dev $_target)
>> - fi
>> + _fstype=$(get_fs_type_from_target $_target)
>> + if is_fs_type_nfs $_fstype; then
>> + kdump_install_net "$_target"
>> + _fstype="nfs"
>> + else
>> + _target=$(kdump_get_persistent_dev $_target)
>> + fi
>>
>> - echo "$_fstype $_target" >>
${initdir}/tmp/$$-kdump.conf
>> + echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf
>>
>> - # strip the duplicated "/"
>> - _save_path=$(echo $_save_path | tr -s /)
>> + # strip the duplicated "/"
>> + _save_path=$(echo $_save_path | tr -s /)
>> + # don't touch the path under root mount
>> + if [ "$_mntpoint" != "/" ]; then
>> _save_path=${_save_path##"$_mntpoint"}
>> fi
>>
>> diff --git a/kdumpctl b/kdumpctl
>> index 01a2ad8..ed76098 100755
>> --- a/kdumpctl
>> +++ b/kdumpctl
>> @@ -171,6 +171,11 @@ check_kdump_cpus()
>> echo " try nr_cpus=$nr_min or larger instead"
>> }
>>
>> +is_dump_to_rootfs()
>> +{
>> + grep "^default[[:space:]]dump_to_rootfs" /etc/kdump.conf
>/dev/null
>> +}
>> +
>> # This function performs a series of edits on the command line.
>> # Store the final result in global $KDUMP_COMMANDLINE.
>> prepare_cmdline()
>> @@ -192,6 +197,17 @@ prepare_cmdline()
>> # These params can be removed configurably
>> cmdline=`remove_cmdline_param "$cmdline"
${KDUMP_COMMANDLINE_REMOVE}`
>>
>> + # Always remove "root=X", as we now explicitly generate all kinds
>> + # of dump target mount information including root fs. But we can
>> + # not remove it in case of fadump or "default dump_to_rootfs".
>> + #
>> + # We do this before KDUMP_COMMANDLINE_APPEND, if one really cares
>> + # about it(e.g. for debug purpose), then can pass "root=X" using
>> + # KDUMP_COMMANDLINE_APPEND.
>> + if [ $DEFAULT_DUMP_MODE != "fadump" ] && !
is_dump_to_rootfs; then
>> + cmdline=`remove_cmdline_param "$cmdline" root`
>> + fi
>> +
>> cmdline="${cmdline} ${KDUMP_COMMANDLINE_APPEND}"
>>
>> id=`get_bootcpu_initial_apicid`
>> @@ -512,11 +528,16 @@ check_dump_fs_modified()
>> fi
>> fi
>>
>> - if ! findmnt $_target >/dev/null; then
>> - echo "Dump target $_target is probably not mounted."
>> - return 2
>> - fi
>> - _new_mntpoint="/kdumproot/$(get_mntpoint_from_target $_target)"
>> + if ! findmnt $_target >/dev/null; then
>> + echo "Dump target $_target is probably not mounted."
>> + return 2
>> + fi
>> +
>> + if [[ "$_target" = "$(get_root_fs_device)" ]]; then
>> + _new_mntpoint="/sysroot"
>> + else
>> + _new_mntpoint="/kdumproot/$(get_mntpoint_from_target $_target)"
>> + fi
>
> Xunlei, the new version looks good to me, except one new question, is
> there any code depends on "sysroot"? If no maybe we can juse use same
> /kdumproot as new_mntpoint then no need the if/else, and move the
> striping duplicate of slash after above _new_mnt_point assignment.
This is needed by systemd fstab generator, if we don't use /sysroot, there will
be some conflicts between "root=X" and "--mount xxx" kdump
generated.
For example, in case of "default dump_to_rootfs" we keep "root=X", so
systemd
will generate one sysroot.mount from "root=X" and another kdumproot-xxx.mount
with the same mount information, conflict will arise.
Ok, thanks for explaining about this, we probably can change
dump_to_rootfs to use --mount instead like other mounts in the future.
For the series
Acked-by: Dave Young <dyoung(a)redhat.com>
Regards,
Xunlei
>
>>
>> _dracut_args=$(lsinitrd $TARGET_INITRD | grep "^Arguments:" | head
-1)
>> if [[ -z "$_dracut_args" ]];then
>> diff --git a/mkdumprd b/mkdumprd
>> index f30d9c2..5a25853 100644
>> --- a/mkdumprd
>> +++ b/mkdumprd
>> @@ -80,12 +80,6 @@ add_dracut_sshkey() {
>> add_dracut_arg "--sshkey" "$1"
>> }
>>
>> -target_is_root() {
>> - local _t
>> - _t=$(findmnt -k -n -r -o TARGET $1|sort|head -1)
>> - [ "$_t" = "/" ]
>> -}
>> -
>> # caller should ensure $1 is valid and mounted in 1st kernel
>> to_mount() {
>> local _dev=$1 _source _target _fstype _options _mntopts _pdev
>> @@ -247,13 +241,13 @@ verify_core_collector() {
>> }
>>
>> add_mount() {
>> - if ! target_is_root "$1"; then
>> - local _mnt=$(to_mount "$1")
>> - if [ $? -ne 0 ]; then
>> - exit 1
>> - fi
>> - add_dracut_mount "$_mnt"
>> + local _mnt=$(to_mount "$1")
>> +
>> + if [ $? -ne 0 ]; then
>> + exit 1
>> fi
>> +
>> + add_dracut_mount "$_mnt"
>> }
>>
>> get_block_dump_target()
>> @@ -274,7 +268,6 @@ handle_default_dump_target()
>> {
>> local _target
>> local _mntpoint
>> - local _fstype
>>
>> is_user_configured_dump_target && return
>>
>> @@ -293,13 +286,9 @@ handle_default_dump_target()
>> SAVE_PATH=$_mntpoint/$SAVE_PATH
>> fi
>>
>> - if [ "$_mntpoint" != "/" ]; then
>> - SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
>> - _fstype=$(get_fs_type_from_target $_target)
>> -
>> - add_mount "$_target"
>> - check_size fs $_target
>> - fi
>> + SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
>> + add_mount "$_target"
>> + check_size fs $_target
>> }
>>
>> get_default_action_target()
>> --
>> 1.8.3.1
>> _______________________________________________
>> kexec mailing list -- kexec(a)lists.fedoraproject.org
>> To unsubscribe send an email to kexec-leave(a)lists.fedoraproject.org
> Thanks
> Dave
Thanks
Dave