v1 -> v2: For Patch 1, rename "does_dracut_args_contain_mount" to "is_mount_in_dracut_args". No functional change.
v2 -> v3: For Patch 1, remove the double quota requirement for "--mount". For Patch 2, Improved description according to Dave's suggestion.
v3 -> v4: For Patch 1, Improved "is_mount_in_dracut_args" using: grep -q "^dracut_args .*--mount" /etc/kdump.conf Improved print: echo "Multiple mount targets specified in one "dracut_args"."
There were some complaints about nfs kdump that users must mount nfs beforehand, which may cause some overhead to nfs server. For example, there're thounsands of diskless clients deployed with nfs dumping, each time the client is boot up, it will trigger kdump rebuilding so will mount nfs, thus resulting in thousands of nfs request concurrently imposed on the same nfs server.
In order to solve this, we introduce a new way of specifying mount information via the already-existent "dracut_args" directive, this is not only for nfs mount, also including other supported filesystems like ext[2-4]/xfs, etc.
This feature relys on the latest fedora dracut version: http://koji.fedoraproject.org/koji/taskinfo?taskID=15307615
The last patch is a fix found when designing this feature for nfs, so attached in passing.
Xunlei Pang (4): Support special mount information via "dracut_args" kexec-kdump-howto: Add doc about the special mount information via "dracut_args" spec: Update to add dependency on dracut version >= 044-117 mkdumprd: Do not add "nfs" dracut module explicitly
dracut-kdump.sh | 4 ++++ dracut-module-setup.sh | 5 +++++ kdump-lib.sh | 27 +++++++++++++++++++++++++-- kdumpctl | 13 ++++++++++++- kexec-kdump-howto.txt | 18 ++++++++++++++++++ kexec-tools.spec | 5 +++-- mkdumprd | 8 -------- 7 files changed, 67 insertions(+), 13 deletions(-)
There are some complaints about nfs kdump that users must mount nfs beforehand, which may cause some overhead to nfs server. For example, there're thounsands of diskless clients deployed with nfs dumping, each time the client is boot up, it will trigger kdump rebuilding so will mount nfs, thus resulting in thousands of nfs request concurrently imposed on the same nfs server.
We introduce a new way of specifying mount information via the already-existent "dracut_args" directive(so avoid adding extra directives in /etc/kdump.conf), we will skip all the filesystem mounting and checking stuff for it. So it can be used in the above-mentioned nfs scenario to avoid severe nfs server overhead.
Specifically, if there is any "--mount" information specified via "dracut_args" in /etc/kdump.conf, always use it as the final mount without any validation(mounting or checking like mount options, fs size, etc), so users are expected to ensure its correctness.
NOTE: -Only one mount target is allowed using "dracut_args" globally. -Dracut will create <mountpoint> if it doesn't exist in kdump kernel, <mountpoint> must be specified as an absolute path. -Users should do a test first and ensure it works because kdump does not prepare the mount or check all the validity.
Reviewed-by: Pratyush Anand panand@redhat.com Suggested-by: Dave Young dyoung@redhat.com Acked-by: Dave Young dyoung@redhat.com Signed-off-by: Xunlei Pang xlpang@redhat.com --- dracut-kdump.sh | 4 ++++ dracut-module-setup.sh | 5 +++++ kdump-lib.sh | 26 ++++++++++++++++++++++++-- kdumpctl | 13 ++++++++++++- 4 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh index 4aab205..42ba37f 100755 --- a/dracut-kdump.sh +++ b/dracut-kdump.sh @@ -146,6 +146,10 @@ read_kdump_conf() # remove inline comments after the end of a directive. config_val=$(strip_comments $config_val) case "$config_opt" in + dracut_args) + config_val=$(get_dracut_args_target "$config_val") + [[ -n "$config_val" ]] && add_dump_code "dump_fs $config_val" + ;; ext[234]|xfs|btrfs|minix|nfs) add_dump_code "dump_fs $config_val" ;; diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index f5c0218..68e0ff8 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -450,6 +450,11 @@ kdump_install_conf() { ssh|nfs) kdump_install_net "$config_val" ;; + dracut_args) + if [[ $(get_dracut_args_fstype "$config_val") = nfs* ]] ; then + kdump_install_net "$(get_dracut_args_target "$config_val")" + fi + ;; kdump_pre|kdump_post|extra_bins) dracut_install $config_val ;; diff --git a/kdump-lib.sh b/kdump-lib.sh index 4567a05..e594496 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -23,7 +23,8 @@ is_ssh_dump_target()
is_nfs_dump_target() { - grep -q "^nfs" /etc/kdump.conf + grep -q "^nfs" /etc/kdump.conf || \ + [[ $(get_dracut_args_fstype "$(grep "^dracut_args .*--mount" /etc/kdump.conf)") = nfs* ]] }
is_raw_dump_target() @@ -45,7 +46,8 @@ is_fs_dump_target()
is_user_configured_dump_target() { - return $(is_ssh_dump_target || is_nfs_dump_target || is_raw_dump_target || is_fs_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() @@ -406,3 +408,23 @@ is_wdt_mod_omitted() {
return $ret } + +# If "dracut_args" contains "--mount" information, use it +# directly without any check(users are expected to ensure +# its correctness). +is_mount_in_dracut_args() +{ + grep -q "^dracut_args .*--mount" /etc/kdump.conf +} + +# If $1 contains dracut_args "--mount", return <filesystem type> +get_dracut_args_fstype() +{ + echo $1 | grep "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f3 +} + +# If $1 contains dracut_args "--mount", return <device> +get_dracut_args_target() +{ + echo $1 | grep "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f1 +} diff --git a/kdumpctl b/kdumpctl index 0436bfc..4d83e69 100755 --- a/kdumpctl +++ b/kdumpctl @@ -236,12 +236,18 @@ check_config() { local nr
- nr=$(awk 'BEGIN{cnt=0} /^raw|^ssh[[:blank:]]|^nfs|^ext[234]|^xfs|^btrfs|^minix/{cnt++} END{print cnt}' $KDUMP_CONFIG_FILE) + nr=$(awk 'BEGIN{cnt=0} /^raw|^ssh[[:blank:]]|^nfs|^ext[234]|^xfs|^btrfs|^minix|^dracut_args .*--mount/{cnt++} END{print cnt}' $KDUMP_CONFIG_FILE) [ $nr -gt 1 ] && { echo "More than one dump targets specified." return 1 }
+ nr=$(grep "^dracut_args .*--mount" $KDUMP_CONFIG_FILE | grep -o "--mount" | wc -l) + [ $nr -gt 1 ] && { + echo "Multiple mount targets specified in one "dracut_args"." + return 1 + } + while read config_opt config_val; do # remove inline comments after the end of a directive. config_val=$(strip_comments $config_val) @@ -365,6 +371,11 @@ check_dump_fs_modified() local _new_dev _new_mntpoint _new_fstype local _target _path _dracut_args
+ # No need to check in case of mount target specified via "dracut_args". + if is_mount_in_dracut_args; then + return 0 + fi + # No need to check in case of raw target. # Currently we do not check also if ssh/nfs target is specified if is_ssh_dump_target || is_nfs_dump_target || is_raw_dump_target; then
Update "kexec-kdump-howto" to illustrate the usage of special mount information via "dracut_args".
Suggested-by: Dave Young dyoung@redhat.com Acked-by: Dave Young dyoung@redhat.com Signed-off-by: Xunlei Pang xlpang@redhat.com --- kexec-kdump-howto.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index 38f831e..f46563f 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -345,6 +345,24 @@ mount the NFS mount and copy out the vmcore to your NFS server. Restart the kdump service via '/sbin/systemctl restart kdump.service' to commit this change to your kdump initrd.
+Special mount via "dracut_args" + +You can utilize "dracut_args" to pass "--mount" to kdump, see dracut manpage +about the format of "--mount" for details. If there is any "--mount" specified +via "dracut_args", kdump will build it as the mount target without doing any +validation (mounting or checking like mount options, fs size, save path, etc), +so you must test it to ensure all the correctness. You cannot use other targets +in /etc/kdump.conf if you use "--mount" in "dracut_args". You also cannot specify +mutliple "--mount" targets via "dracut_args". + +One use case of "--mount" in "dracut_args" is you do not want to mount dump target +before kdump service startup, for example, to reduce the burden of the shared nfs +server. Such as the example below: +dracut_args --mount "192.168.1.1:/share /mnt/test nfs4 defaults" + +NOTE: +- <mountpoint> must be specified as an absolute path. + Remote system via ssh/scp
Dumping over ssh/scp requires setting up passwordless ssh keys for every
Fedora dracut-network version >= 044-117 must be installed to work with this set of kexec-tools patches. Therefore adding dependency for them.
Acked-by: Dave Young dyoung@redhat.com Signed-off-by: Xunlei Pang xlpang@redhat.com --- kexec-tools.spec | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kexec-tools.spec b/kexec-tools.spec index d70b561..d386af1 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -45,8 +45,9 @@ Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units Requires(pre): coreutils sed zlib -Requires: dracut >= 044-75 -Requires: dracut-network, ethtool +Requires: dracut >= 044-117 +Requires: dracut-network >= 044-117 +Requires: ethtool BuildRequires: zlib-devel zlib zlib-static elfutils-devel-static glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel BuildRequires: pkgconfig intltool gettext BuildRequires: systemd-units
Kdump explicitly adds "nfs" dracut module in case of nfs dumping, actually in case of nfs dump, nfs is a mount target, and will be added into host_fs_types[], thus dracut will add it automatically, according to 95nfs/module-setup.sh check().
So, we can safely remove all the add_dracut_module "nfs".
Acked-by: Dave Young dyoung@redhat.com Signed-off-by: Xunlei Pang xlpang@redhat.com --- mkdumprd | 8 -------- 1 file changed, 8 deletions(-)
diff --git a/mkdumprd b/mkdumprd index 2791613..3705749 100644 --- a/mkdumprd +++ b/mkdumprd @@ -355,10 +355,6 @@ handle_default_dump_target() SAVE_PATH=${SAVE_PATH##"$_mntpoint"} _fstype=$(get_fs_type_from_target $_target)
- if $(is_fs_type_nfs $_fstype); then - add_dracut_module "nfs" - fi - add_mount "$_target" check_size fs $_target fi @@ -519,10 +515,6 @@ do perror_exit "Dump target $config_val is probably not mounted." fi
- 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