Kexec-tools should be able to recognize if a dump target is reformatted, or dump path mounts another device.
Changes since v4: - patch 4/5 is a new change - patch 4/4 of V3 is now 4/5. There has been many modifications in this patch. It includes feedback from Baoquan and Xunlei. Have also done some modification to recognize changes related to minix and NFS filesystem as well. Infact, whole structure of function is_fs_uuid_changed() has been modified. Now it has been renamed as is_dump_fs_modified() to suit it better. Although I have tested it rigorously, but still a careful review of is_dump_fs_modified() will be helpful.
Changes since v3: - "$ret" unquoted - No message for "$system_modified" != "0" - image_time is now global - is_dump_target_modified has been renamed as is_fs_uuid_changed
Changes since v2: -- now is_system_modified returns 2 in case of invalid modification, 1 in case of valid modification and 0 in case of no modification. -- file modification check has been moved to is_system_modified now -- variables have been put under "" in if condition check
Changes since v1: -- Local variable is defined in shell function now -- raw target does not take persistent names "by-uuid" now -- dracut arguments grep is more robust -- When no UUID then warn and return
Pratyush Anand (5): mkdumprd: do not lookup in by-uuid dirs for raw device's persistent name kdumpctl: force rebuild in case of dynamic system modification kdumpctl: Move file modification check logic in is_system_modified() mkdumprd: move to_dev_name() to kdump-lib.sh kdumpctl: force rebuild in case of file system is modified
kdump-lib.sh | 14 +++++ kdumpctl | 173 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- mkdumprd | 28 ++++------ 3 files changed, 171 insertions(+), 44 deletions(-)
raw devices are not mounted and also does not need to contain any filesystem. So they may have UUIDs(when formatted) and may not have UUIDs when raw. Therefore, do not look for persistent names by-uuid for raw devices.
Signed-off-by: Pratyush Anand panand@redhat.com Suggested-by: Dave Young dyoung@redhat.com --- mkdumprd | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/mkdumprd b/mkdumprd index 6e3d9757f3d8..ad40d2872f98 100644 --- a/mkdumprd +++ b/mkdumprd @@ -30,14 +30,20 @@ perror() { }
get_persistent_dev() { - local i _tmp _dev + local i _tmp _dev _lookup_dirs
_dev=$(udevadm info --query=name --name="$1" 2>/dev/null) [ -z "$_dev" ] && { perror_exit "Kernel dev name of $1 is not found." }
- for i in /dev/mapper/* /dev/disk/by-uuid/* /dev/disk/by-id/*; do + if [[ $2 = "raw" ]];then + _lookup_dirs="/dev/mapper/* /dev/disk/by-id/*" + else + _lookup_dirs="/dev/mapper/* /dev/disk/by-uuid/* /dev/disk/by-id/*" + fi + + for i in $_lookup_dirs; do _tmp=$(udevadm info --query=name --name="$i" 2>/dev/null) if [ "$_tmp" = "$_dev" ]; then echo $i @@ -138,7 +144,7 @@ to_mount() { _mntopts="$_target $_fstype $_options" #for non-nfs _dev converting to use udev persistent name if [ -b "$_source" ]; then - _pdev="$(get_persistent_dev $_source)" + _pdev="$(get_persistent_dev $_source $_fstype)" if [ $? -ne 0 ]; then return 1 fi @@ -565,7 +571,7 @@ do dd if=$config_val count=1 of=/dev/null > /dev/null 2>&1 || { perror_exit "Bad raw disk $config_val" } - _praw=$(get_persistent_dev $config_val) + _praw=$(get_persistent_dev $config_val "raw") if [ $? -ne 0 ]; then exit 1 fi
There could be some dynamic system modification, which may affect kdump kernel boot process. In such situation initramfs must be rebulit on the basis of changes. Since most of these checking methods will use information from TARGET_INITRD, therefore check for its existence in common code.
Signed-off-by: Pratyush Anand panand@redhat.com --- kdumpctl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/kdumpctl b/kdumpctl index ef18a2d4f6ce..41dcf6473e24 100755 --- a/kdumpctl +++ b/kdumpctl @@ -327,10 +327,21 @@ setup_target_initrd() fi }
+# returns 0 if system is not modified +# returns 1 if system is modified +# returns 2 if system modification is invalid +is_system_modified() +{ + [[ -f $TARGET_INITRD ]] || return 1 + + return 0 +} + check_rebuild() { local extra_modules modified_files="" local _force_rebuild force_rebuild="0" + local ret system_modified="0" local initramfs_has_fadump
check_boot_dir @@ -388,6 +399,14 @@ check_rebuild() fi done
+ is_system_modified + ret=$? + if [ $ret -eq 2 ]; then + return 1 + elif [ $ret -eq 1 ];then + system_modified="1" + fi + #check if target initrd has fadump support if [ "$DEFAULT_DUMP_MODE" = "fadump" ] && [ -f "$TARGET_INITRD" ]; then initramfs_has_fadump=`lsinitrd -m $TARGET_INITRD | grep ^kdumpbase$ | wc -l` @@ -399,6 +418,8 @@ check_rebuild() echo "$TARGET_INITRD has no fadump support" elif [ "$force_rebuild" != "0" ]; then echo -n "Force rebuild $TARGET_INITRD"; echo + elif [ "$system_modified" != "0" ]; then + : elif [ -n "$modified_files" ]; then echo "Detected change(s) in the following file(s):" echo -n " "; echo "$modified_files" | sed 's/\s/\n /g'
Relevant kdump files are also part of system. Therefore, moving logic of file modification checking in is_system_modified() function now.
Signed-off-by: Pratyush Anand panand@redhat.com --- kdumpctl | 69 +++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 27 deletions(-)
diff --git a/kdumpctl b/kdumpctl index 41dcf6473e24..1cba00b9dc0f 100755 --- a/kdumpctl +++ b/kdumpctl @@ -14,6 +14,7 @@ FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered" #kdump shall be the default dump mode DEFAULT_DUMP_MODE="kdump" +image_time=0
. /lib/kdump/kdump-lib.sh
@@ -275,7 +276,6 @@ check_config() # return list of modified file for fence_kdump modified in Pacemaker cluster get_pcs_cluster_modified_files() { - local image_time=$1 local time_stamp local modified_files
@@ -327,19 +327,59 @@ setup_target_initrd() fi }
+is_files_modified() +{ + local modified_files="" + + #also rebuild when Pacemaker cluster conf is changed and fence kdump is enabled. + modified_files=$(get_pcs_cluster_modified_files) + + EXTRA_BINS=`grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2` + CHECK_FILES=`grep ^kdump_pre $KDUMP_CONFIG_FILE | cut -d\ -f2` + EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" + CHECK_FILES=`grep ^extra_bins $KDUMP_CONFIG_FILE | cut -d\ -f2-` + EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" + files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS /etc/fstab" + + check_exist "$files" && check_executable "$EXTRA_BINS" + [ $? -ne 0 ] && return 2 + + for file in $files; do + time_stamp=`stat -c "%Y" $file` + if [ "$time_stamp" -gt "$image_time" ]; then + modified_files="$modified_files $file" + fi + done + if [ -n "$modified_files" ]; then + echo "Detected change(s) in the following file(s):" + echo -n " "; echo "$modified_files" | sed 's/\s/\n /g' + return 1 + fi + + return 0 +} + # returns 0 if system is not modified # returns 1 if system is modified # returns 2 if system modification is invalid is_system_modified() { + local ret + [[ -f $TARGET_INITRD ]] || return 1
+ is_files_modified + ret=$? + if [ $ret -ne 0 ]; then + return $ret + fi + return 0 }
check_rebuild() { - local extra_modules modified_files="" + local extra_modules local _force_rebuild force_rebuild="0" local ret system_modified="0" local initramfs_has_fadump @@ -375,30 +415,8 @@ check_rebuild() #since last build of the image file if [ -f $TARGET_INITRD ]; then image_time=`stat -c "%Y" $TARGET_INITRD 2>/dev/null` - else - image_time=0 fi
- #also rebuild when Pacemaker cluster conf is changed and fence kdump is enabled. - modified_files=$(get_pcs_cluster_modified_files $image_time) - - EXTRA_BINS=`grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2` - CHECK_FILES=`grep ^kdump_pre $KDUMP_CONFIG_FILE | cut -d\ -f2` - EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" - CHECK_FILES=`grep ^extra_bins $KDUMP_CONFIG_FILE | cut -d\ -f2-` - EXTRA_BINS="$EXTRA_BINS $CHECK_FILES" - files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS /etc/fstab" - - check_exist "$files" && check_executable "$EXTRA_BINS" - [ $? -ne 0 ] && return 1 - - for file in $files; do - time_stamp=`stat -c "%Y" $file` - if [ "$time_stamp" -gt "$image_time" ]; then - modified_files="$modified_files $file" - fi - done - is_system_modified ret=$? if [ $ret -eq 2 ]; then @@ -420,9 +438,6 @@ check_rebuild() echo -n "Force rebuild $TARGET_INITRD"; echo elif [ "$system_modified" != "0" ]; then : - elif [ -n "$modified_files" ]; then - echo "Detected change(s) in the following file(s):" - echo -n " "; echo "$modified_files" | sed 's/\s/\n /g' else return 0 fi
to_dev_name() can be used by function in kdumpctl. Therefore moving this function to kdump-lib.sh.
Signed-off-by: Pratyush Anand panand@redhat.com --- kdump-lib.sh | 14 ++++++++++++++ mkdumprd | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 4d3420652b2f..e4ffc43c8988 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -63,6 +63,20 @@ is_generic_fence_kdump() grep -q "^fence_kdump_nodes" /etc/kdump.conf }
+to_dev_name() { + local dev="${1//"/}" + + case "$dev" in + UUID=*) + dev=`blkid -U "${dev#UUID=}"` + ;; + LABEL=*) + dev=`blkid -L "${dev#LABEL=}"` + ;; + esac + echo $dev +} + get_user_configured_dump_disk() { local _target diff --git a/mkdumprd b/mkdumprd index ad40d2872f98..82df6447e9e7 100644 --- a/mkdumprd +++ b/mkdumprd @@ -331,20 +331,6 @@ check_block_and_slaves() { return 1 }
-to_dev_name() { - local dev="${1//"/}" - - case "$dev" in - UUID=*) - dev=`blkid -U "${dev#UUID=}"` - ;; - LABEL=*) - dev=`blkid -L "${dev#LABEL=}"` - ;; - esac - echo $dev -} - get_block_dump_target() { local _target
Initramfs must be rebuild if:
-- "dump target" is specified as ext[234], xfs or btrfs and its UUID is changed by reformatting. -- "dump target" is specified as file system type fs1 (say ext3) but actual file system for the target device is of type fs2(ext4), however dracut "--mount" argument has file system type fs1 (say ext3) -- "dump target" is not specified, but "dump path" mounts a device which is different than device for root path and either UUID or file system type changes for a bulk device. -- "dump target" is nots specified, but "dump path" mounts a nfs device, but nfs host path changes
When "dump target" is specified as "raw" or "nfs" then it will rebuild only on the basis of kdump.conf modification time.
Testing:
Initial conditions: -- No dump target specified -- dump path (/var/crash) and root(/) are on same device -- kdumpctl was already executed once after last modification in /etc/kdump.conf
# kdumpctl restart No rebuild # mkfs.ext2 /dev/md0;mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # umount /var/crash;mkfs.ext4 /dev/md0; # mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
# umount /var/crash;mkfs.ext4 /dev/mapper/fedora-swap # mount /dev/mapper/fedora-swap /var/crash/ # kdumpctl restart Rebuilt because "Detected change in File System" # umount /var/crash;mkfs.btrfs /dev/mapper/fedora-swap -f # mount /dev/mapper/fedora-swap /var/crash/ # kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # mount /dev/mapper/fedora-swap /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
# umount /var/crash;mkfs.minix /dev/md0 # mount /dev/md0 /var/crash/; kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
# mount 192.168.1.16:/nfsroot /var/crash/;kdumpctl restart Rebuilt because "Detected change in NFS host" # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # mount 192.168.1.16:/nfsroot /var/crash/;kdumpctl restart Rebuilt because "Detected change in NFS host" # kdumpctl restart No rebuild # umount /var/crash;mount 192.168.1.12:/nfsroot /var/crash/ # kdumpctl restart Rebuilt because "Detected change in NFS host" # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
Added "raw /dev/md0" in /etc/kdump.conf # kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf" # mkfs.ext4 /dev/md0 ;kdumpctl restart No rebuild
Added "ext4 /dev/md0" in /etc/kdump.conf # mkfs.ext4 /dev/md0;mount /dev/md0 /mnt # mkdir /mnt/var;mkdir /mnt/var/crash; kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf" # umount /mnt;mkfs.ext4 /dev/md0;mount /dev/md0 /mnt # mkdir /mnt/var;mkdir /mnt/var/crash; kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf"
Signed-off-by: Pratyush Anand panand@redhat.com --- kdumpctl | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+)
diff --git a/kdumpctl b/kdumpctl index 1cba00b9dc0f..c7abaafdda27 100755 --- a/kdumpctl +++ b/kdumpctl @@ -359,6 +359,85 @@ is_files_modified() return 0 }
+is_dump_fs_modified() +{ + local _dracut_args _mount _uuid _fstype _target _id _dev _tdev + + # No need to ckeck if raw target is specified + is_raw_dump_target && return 0 + + _target=$(get_user_configured_dump_disk) + + if [[ -n "$_target" ]]; then + _fstype=$(blkid $_target | awk -F"TYPE=" '{print $2}' | cut -d '"' -f 2) + else + set -- $(df -T $(get_save_path) 2>/dev/null | tail -1 | awk '{ print $1, $2}') + _target=$1 + _fstype=$2 + fi + _target=$(to_dev_name $_target) + + _dracut_args=$(lsinitrd $TARGET_INITRD | grep "^Arguments:" | head -1) + if [[ -z "$_dracut_args" ]];then + echo "Warning: No dracut arguments found in initrd" + return 0 + fi + + # if --mount argument is not present and, dump path and root path + # mounts same device then no need to check for FS modification + echo $_dracut_args | grep "--mount" &> /dev/null + _mount=$? + [[ _mount -ne 0 ]] && [[ "$_target" = "$(get_root_fs_device)" ]] && return 0 + + # for NFS FS check if dump path still mounts same host + if [[ $(expr substr $_fstype 1 3) = "nfs" ]];then + echo $_dracut_args | grep $_target &> /dev/null + [[ $? -eq 0 ]] && return 0 + echo "Detected change in NFS host" + return 1 + fi + + # if dracut argument has "by-uuid", and darcut argument also contains same uuid and fs type + # as that of _target then also do not rebuild + echo $_dracut_args | grep "by-uuid" &> /dev/null + if [[ $? -eq 0 ]];then + _uuid=$(blkid $_target | awk -F"UUID=" '{print $2}' | cut -d '"' -f 2) + if [[ -n "$_uuid" ]]; then + echo $_dracut_args | grep $_uuid | grep $_fstype &> /dev/null + [[ $? -eq 0 ]] && return 0 + fi + echo "Detected change in File System" + return 1 + fi + # if dracut argument has "mapper", and darcut argument also contains same name and fs type + # as that of _target then also do not rebuild + echo $_dracut_args | grep "mapper" &> /dev/null + if [[ $? -eq 0 ]];then + echo $_dracut_args | grep $_target | grep $_fstype &> /dev/null + [[ $? -eq 0 ]] && return 0 + echo "Detected change in File System" + return 1 + fi + # if dracut argument has "by-id", and darcut argument also contains same id and fs type + # as that of _target then also do not rebuild + echo $_dracut_args | grep "by-id" &> /dev/null + if [[ $? -eq 0 ]];then + _tdev=$(udevadm info --query=name --name="$_target" 2>/dev/null) + for _id in /dev/disk/by-id/*; do + _dev=$(udevadm info --query=name --name="$_id" 2>/dev/null) + if [[ "$_tdev" = "$_dev" ]]; then + echo $_dracut_args | grep $_fstype &> /dev/null + [[ $? -eq 0 ]] && return 0 + fi + done + echo "Detected change in File System" + return 1 + fi + + echo "Detected change in File System" + return 1 +} + # returns 0 if system is not modified # returns 1 if system is modified # returns 2 if system modification is invalid @@ -374,6 +453,12 @@ is_system_modified() return $ret fi
+ is_dump_fs_modified + ret=$? + if [ $ret -ne 0 ]; then + return $ret + fi + return 0 }
On 2016/04/29 at 14:50, Pratyush Anand wrote:
Initramfs must be rebuild if:
-- "dump target" is specified as ext[234], xfs or btrfs and its UUID is changed by reformatting. -- "dump target" is specified as file system type fs1 (say ext3) but actual file system for the target device is of type fs2(ext4), however dracut "--mount" argument has file system type fs1 (say ext3) -- "dump target" is not specified, but "dump path" mounts a device which is different than device for root path and either UUID or file system type changes for a bulk device. -- "dump target" is nots specified, but "dump path" mounts a nfs device, but nfs host path changes
When "dump target" is specified as "raw" or "nfs" then it will rebuild only on the basis of kdump.conf modification time.
Testing:
Initial conditions: -- No dump target specified -- dump path (/var/crash) and root(/) are on same device -- kdumpctl was already executed once after last modification in /etc/kdump.conf
# kdumpctl restart No rebuild # mkfs.ext2 /dev/md0;mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # umount /var/crash;mkfs.ext4 /dev/md0; # mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
# umount /var/crash;mkfs.ext4 /dev/mapper/fedora-swap # mount /dev/mapper/fedora-swap /var/crash/ # kdumpctl restart Rebuilt because "Detected change in File System" # umount /var/crash;mkfs.btrfs /dev/mapper/fedora-swap -f # mount /dev/mapper/fedora-swap /var/crash/ # kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # mount /dev/mapper/fedora-swap /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
# umount /var/crash;mkfs.minix /dev/md0 # mount /dev/md0 /var/crash/; kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
# mount 192.168.1.16:/nfsroot /var/crash/;kdumpctl restart Rebuilt because "Detected change in NFS host" # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # mount 192.168.1.16:/nfsroot /var/crash/;kdumpctl restart Rebuilt because "Detected change in NFS host" # kdumpctl restart No rebuild # umount /var/crash;mount 192.168.1.12:/nfsroot /var/crash/ # kdumpctl restart Rebuilt because "Detected change in NFS host" # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
Added "raw /dev/md0" in /etc/kdump.conf # kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf" # mkfs.ext4 /dev/md0 ;kdumpctl restart No rebuild
Added "ext4 /dev/md0" in /etc/kdump.conf # mkfs.ext4 /dev/md0;mount /dev/md0 /mnt # mkdir /mnt/var;mkdir /mnt/var/crash; kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf" # umount /mnt;mkfs.ext4 /dev/md0;mount /dev/md0 /mnt # mkdir /mnt/var;mkdir /mnt/var/crash; kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf"
Signed-off-by: Pratyush Anand panand@redhat.com
kdumpctl | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+)
diff --git a/kdumpctl b/kdumpctl index 1cba00b9dc0f..c7abaafdda27 100755 --- a/kdumpctl +++ b/kdumpctl @@ -359,6 +359,85 @@ is_files_modified() return 0 }
+is_dump_fs_modified() +{
- local _dracut_args _mount _uuid _fstype _target _id _dev _tdev
- # No need to ckeck if raw target is specified
s/ckeck/check
- is_raw_dump_target && return 0
- _target=$(get_user_configured_dump_disk)
- if [[ -n "$_target" ]]; then
_fstype=$(blkid $_target | awk -F"TYPE=" '{print $2}' | cut -d '"' -f 2)
There needs a name convert for uuid or id target cases, for example: ext4 UUID=1bb705f6-382b-4b49-bae0-ab04ccfdf4ee
blkid "UUID=1bb705f6-382b-4b49-bae0-ab04ccfdf4ee" doesn't work to get its fstype.
- else
set -- $(df -T $(get_save_path) 2>/dev/null | tail -1 | awk '{ print $1, $2}')
_target=$1
_fstype=$2
- fi
- _target=$(to_dev_name $_target)
- _dracut_args=$(lsinitrd $TARGET_INITRD | grep "^Arguments:" | head -1)
- if [[ -z "$_dracut_args" ]];then
echo "Warning: No dracut arguments found in initrd"
return 0
- fi
- # if --mount argument is not present and, dump path and root path
- # mounts same device then no need to check for FS modification
- echo $_dracut_args | grep "--mount" &> /dev/null
- _mount=$?
- [[ _mount -ne 0 ]] && [[ "$_target" = "$(get_root_fs_device)" ]] && return 0
- # for NFS FS check if dump path still mounts same host
- if [[ $(expr substr $_fstype 1 3) = "nfs" ]];then
echo $_dracut_args | grep $_target &> /dev/null
[[ $? -eq 0 ]] && return 0
echo "Detected change in NFS host"
return 1
- fi
- # if dracut argument has "by-uuid", and darcut argument also contains same uuid and fs type
s/darcut/dracut
- # as that of _target then also do not rebuild
- echo $_dracut_args | grep "by-uuid" &> /dev/null
- if [[ $? -eq 0 ]];then
_uuid=$(blkid $_target | awk -F"UUID=" '{print $2}' | cut -d '"' -f 2)
if [[ -n "$_uuid" ]]; then
echo $_dracut_args | grep $_uuid | grep $_fstype &> /dev/null
[[ $? -eq 0 ]] && return 0
fi
echo "Detected change in File System"
return 1
- fi
- # if dracut argument has "mapper", and darcut argument also contains same name and fs type
- # as that of _target then also do not rebuild
- echo $_dracut_args | grep "mapper" &> /dev/null
- if [[ $? -eq 0 ]];then
echo $_dracut_args | grep $_target | grep $_fstype &> /dev/null
[[ $? -eq 0 ]] && return 0
echo "Detected change in File System"
return 1
- fi
- # if dracut argument has "by-id", and darcut argument also contains same id and fs type
- # as that of _target then also do not rebuild
- echo $_dracut_args | grep "by-id" &> /dev/null
- if [[ $? -eq 0 ]];then
_tdev=$(udevadm info --query=name --name="$_target" 2>/dev/null)
for _id in /dev/disk/by-id/*; do
_dev=$(udevadm info --query=name --name="$_id" 2>/dev/null)
if [[ "$_tdev" = "$_dev" ]]; then
echo $_dracut_args | grep $_fstype &> /dev/null
I guess we should add an extra "grep $_id" here?
Now things seem to be more complicated, I need pondering more on the patch later :-(
Regards, Xunlei
[[ $? -eq 0 ]] && return 0
fi
done
echo "Detected change in File System"
return 1
- fi
- echo "Detected change in File System"
- return 1
+}
# returns 0 if system is not modified # returns 1 if system is modified # returns 2 if system modification is invalid @@ -374,6 +453,12 @@ is_system_modified() return $ret fi
- is_dump_fs_modified
- ret=$?
- if [ $ret -ne 0 ]; then
return $ret
- fi
- return 0
}
On Fri, Apr 29, 2016 at 2:10 PM, Xunlei Pang xpang@redhat.com wrote:
On 2016/04/29 at 14:50, Pratyush Anand wrote:
Initramfs must be rebuild if:
-- "dump target" is specified as ext[234], xfs or btrfs and its UUID is changed by reformatting. -- "dump target" is specified as file system type fs1 (say ext3) but actual file system for the target device is of type fs2(ext4), however dracut "--mount" argument has file system type fs1 (say ext3) -- "dump target" is not specified, but "dump path" mounts a device which is different than device for root path and either UUID or file system type changes for a bulk device. -- "dump target" is nots specified, but "dump path" mounts a nfs device, but nfs host path changes
When "dump target" is specified as "raw" or "nfs" then it will rebuild only on the basis of kdump.conf modification time.
Testing:
Initial conditions: -- No dump target specified -- dump path (/var/crash) and root(/) are on same device -- kdumpctl was already executed once after last modification in /etc/kdump.conf
# kdumpctl restart No rebuild # mkfs.ext2 /dev/md0;mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # umount /var/crash;mkfs.ext4 /dev/md0; # mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # umount /var/crash;mkfs.ext4 /dev/mapper/fedora-swap # mount /dev/mapper/fedora-swap /var/crash/ # kdumpctl restart Rebuilt because "Detected change in File System" # umount /var/crash;mkfs.btrfs /dev/mapper/fedora-swap -f # mount /dev/mapper/fedora-swap /var/crash/ # kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # mount /dev/mapper/fedora-swap /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # umount /var/crash;mkfs.minix /dev/md0 # mount /dev/md0 /var/crash/; kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # mount 192.168.1.16:/nfsroot /var/crash/;kdumpctl restart Rebuilt because "Detected change in NFS host" # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # mount 192.168.1.16:/nfsroot /var/crash/;kdumpctl restart Rebuilt because "Detected change in NFS host" # kdumpctl restart No rebuild # umount /var/crash;mount 192.168.1.12:/nfsroot /var/crash/ # kdumpctl restart Rebuilt because "Detected change in NFS host" # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
Added "raw /dev/md0" in /etc/kdump.conf # kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf" # mkfs.ext4 /dev/md0 ;kdumpctl restart No rebuild
Added "ext4 /dev/md0" in /etc/kdump.conf # mkfs.ext4 /dev/md0;mount /dev/md0 /mnt # mkdir /mnt/var;mkdir /mnt/var/crash; kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf" # umount /mnt;mkfs.ext4 /dev/md0;mount /dev/md0 /mnt # mkdir /mnt/var;mkdir /mnt/var/crash; kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf"
Signed-off-by: Pratyush Anand panand@redhat.com
kdumpctl | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+)
diff --git a/kdumpctl b/kdumpctl index 1cba00b9dc0f..c7abaafdda27 100755 --- a/kdumpctl +++ b/kdumpctl @@ -359,6 +359,85 @@ is_files_modified() return 0 }
+is_dump_fs_modified() +{
local _dracut_args _mount _uuid _fstype _target _id _dev _tdev
# No need to ckeck if raw target is specified
s/ckeck/check
OK.
is_raw_dump_target && return 0
_target=$(get_user_configured_dump_disk)
if [[ -n "$_target" ]]; then
_fstype=$(blkid $_target | awk -F"TYPE=" '{print $2}' | cut -d '"' -f 2)
There needs a name convert for uuid or id target cases, for example:
Yes, agreed.
ext4 UUID=1bb705f6-382b-4b49-bae0-ab04ccfdf4ee
blkid "UUID=1bb705f6-382b-4b49-bae0-ab04ccfdf4ee" doesn't work to get its fstype.
else
set -- $(df -T $(get_save_path) 2>/dev/null | tail -1 | awk '{ print $1, $2}')
_target=$1
_fstype=$2
fi
_target=$(to_dev_name $_target)
_dracut_args=$(lsinitrd $TARGET_INITRD | grep "^Arguments:" | head -1)
if [[ -z "$_dracut_args" ]];then
echo "Warning: No dracut arguments found in initrd"
return 0
fi
# if --mount argument is not present and, dump path and root path
# mounts same device then no need to check for FS modification
echo $_dracut_args | grep "\-\-mount" &> /dev/null
_mount=$?
[[ _mount -ne 0 ]] && [[ "$_target" = "$(get_root_fs_device)" ]] && return 0
# for NFS FS check if dump path still mounts same host
if [[ $(expr substr $_fstype 1 3) = "nfs" ]];then
echo $_dracut_args | grep $_target &> /dev/null
[[ $? -eq 0 ]] && return 0
echo "Detected change in NFS host"
return 1
fi
# if dracut argument has "by-uuid", and darcut argument also contains same uuid and fs type
s/darcut/dracut
ok
# as that of _target then also do not rebuild
echo $_dracut_args | grep "by-uuid" &> /dev/null
if [[ $? -eq 0 ]];then
_uuid=$(blkid $_target | awk -F"UUID=" '{print $2}' | cut -d '"' -f 2)
if [[ -n "$_uuid" ]]; then
echo $_dracut_args | grep $_uuid | grep $_fstype &> /dev/null
[[ $? -eq 0 ]] && return 0
fi
echo "Detected change in File System"
return 1
fi
# if dracut argument has "mapper", and darcut argument also contains same name and fs type
# as that of _target then also do not rebuild
echo $_dracut_args | grep "mapper" &> /dev/null
if [[ $? -eq 0 ]];then
echo $_dracut_args | grep $_target | grep $_fstype &> /dev/null
[[ $? -eq 0 ]] && return 0
echo "Detected change in File System"
return 1
fi
# if dracut argument has "by-id", and darcut argument also contains same id and fs type
# as that of _target then also do not rebuild
echo $_dracut_args | grep "by-id" &> /dev/null
if [[ $? -eq 0 ]];then
_tdev=$(udevadm info --query=name --name="$_target" 2>/dev/null)
for _id in /dev/disk/by-id/*; do
_dev=$(udevadm info --query=name --name="$_id" 2>/dev/null)
if [[ "$_tdev" = "$_dev" ]]; then
echo $_dracut_args | grep $_fstype &> /dev/null
I guess we should add an extra "grep $_id" here?
Yes, we should have it.
Now things seem to be more complicated, I need pondering more on the patch later :-(
Sure. Will wait before sending next version.
~Pratyush
On 2016/04/29 at 14:50, Pratyush Anand wrote:
Initramfs must be rebuild if:
-- "dump target" is specified as ext[234], xfs or btrfs and its UUID is changed by reformatting. -- "dump target" is specified as file system type fs1 (say ext3) but actual file system for the target device is of type fs2(ext4), however dracut "--mount" argument has file system type fs1 (say ext3) -- "dump target" is not specified, but "dump path" mounts a device which is different than device for root path and either UUID or file system type changes for a bulk device. -- "dump target" is nots specified, but "dump path" mounts a nfs device, but nfs host path changes
When "dump target" is specified as "raw" or "nfs" then it will rebuild only on the basis of kdump.conf modification time.
Testing:
Initial conditions: -- No dump target specified -- dump path (/var/crash) and root(/) are on same device -- kdumpctl was already executed once after last modification in /etc/kdump.conf
# kdumpctl restart No rebuild # mkfs.ext2 /dev/md0;mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # umount /var/crash;mkfs.ext4 /dev/md0; # mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
# umount /var/crash;mkfs.ext4 /dev/mapper/fedora-swap # mount /dev/mapper/fedora-swap /var/crash/ # kdumpctl restart Rebuilt because "Detected change in File System" # umount /var/crash;mkfs.btrfs /dev/mapper/fedora-swap -f # mount /dev/mapper/fedora-swap /var/crash/ # kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # mount /dev/mapper/fedora-swap /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
# umount /var/crash;mkfs.minix /dev/md0 # mount /dev/md0 /var/crash/; kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
# mount 192.168.1.16:/nfsroot /var/crash/;kdumpctl restart Rebuilt because "Detected change in NFS host" # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # mount 192.168.1.16:/nfsroot /var/crash/;kdumpctl restart Rebuilt because "Detected change in NFS host" # kdumpctl restart No rebuild # umount /var/crash;mount 192.168.1.12:/nfsroot /var/crash/ # kdumpctl restart Rebuilt because "Detected change in NFS host" # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
Added "raw /dev/md0" in /etc/kdump.conf # kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf" # mkfs.ext4 /dev/md0 ;kdumpctl restart No rebuild
Added "ext4 /dev/md0" in /etc/kdump.conf # mkfs.ext4 /dev/md0;mount /dev/md0 /mnt # mkdir /mnt/var;mkdir /mnt/var/crash; kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf" # umount /mnt;mkfs.ext4 /dev/md0;mount /dev/md0 /mnt # mkdir /mnt/var;mkdir /mnt/var/crash; kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf"
Signed-off-by: Pratyush Anand panand@redhat.com
kdumpctl | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+)
diff --git a/kdumpctl b/kdumpctl index 1cba00b9dc0f..c7abaafdda27 100755 --- a/kdumpctl +++ b/kdumpctl @@ -359,6 +359,85 @@ is_files_modified() return 0 }
+is_dump_fs_modified() +{
- local _dracut_args _mount _uuid _fstype _target _id _dev _tdev
- # No need to ckeck if raw target is specified
- is_raw_dump_target && return 0
- _target=$(get_user_configured_dump_disk)
- if [[ -n "$_target" ]]; then
_fstype=$(blkid $_target | awk -F"TYPE=" '{print $2}' | cut -d '"' -f 2)
- else
set -- $(df -T $(get_save_path) 2>/dev/null | tail -1 | awk '{ print $1, $2}')
_target=$1
_fstype=$2
For NFS target, if it got umounted, then "kdumpctl restart" will hit this and got empty _target and _fstype, so I think we should have a judgement here, otherwise it is problematic when executing following scripts.
- fi
- _target=$(to_dev_name $_target)
- _dracut_args=$(lsinitrd $TARGET_INITRD | grep "^Arguments:" | head -1)
- if [[ -z "$_dracut_args" ]];then
echo "Warning: No dracut arguments found in initrd"
return 0
- fi
- # if --mount argument is not present and, dump path and root path
- # mounts same device then no need to check for FS modification
- echo $_dracut_args | grep "--mount" &> /dev/null
- _mount=$?
- [[ _mount -ne 0 ]] && [[ "$_target" = "$(get_root_fs_device)" ]] && return 0
- # for NFS FS check if dump path still mounts same host
- if [[ $(expr substr $_fstype 1 3) = "nfs" ]];then
echo $_dracut_args | grep $_target &> /dev/null
I guess things are more complicated than we thought before, for example, what if the fs mounting option changes? NFS that users mounted beforehand, or fs that users mounted directly onto the PATH. Is it worthy for us to handle with not-so-small code complexity introduced?
Regards, Xunlei
[[ $? -eq 0 ]] && return 0
echo "Detected change in NFS host"
return 1
- fi
- # if dracut argument has "by-uuid", and darcut argument also contains same uuid and fs type
- # as that of _target then also do not rebuild
- echo $_dracut_args | grep "by-uuid" &> /dev/null
- if [[ $? -eq 0 ]];then
_uuid=$(blkid $_target | awk -F"UUID=" '{print $2}' | cut -d '"' -f 2)
if [[ -n "$_uuid" ]]; then
echo $_dracut_args | grep $_uuid | grep $_fstype &> /dev/null
[[ $? -eq 0 ]] && return 0
fi
echo "Detected change in File System"
return 1
- fi
- # if dracut argument has "mapper", and darcut argument also contains same name and fs type
- # as that of _target then also do not rebuild
- echo $_dracut_args | grep "mapper" &> /dev/null
- if [[ $? -eq 0 ]];then
echo $_dracut_args | grep $_target | grep $_fstype &> /dev/null
[[ $? -eq 0 ]] && return 0
echo "Detected change in File System"
return 1
- fi
- # if dracut argument has "by-id", and darcut argument also contains same id and fs type
- # as that of _target then also do not rebuild
- echo $_dracut_args | grep "by-id" &> /dev/null
- if [[ $? -eq 0 ]];then
_tdev=$(udevadm info --query=name --name="$_target" 2>/dev/null)
for _id in /dev/disk/by-id/*; do
_dev=$(udevadm info --query=name --name="$_id" 2>/dev/null)
if [[ "$_tdev" = "$_dev" ]]; then
echo $_dracut_args | grep $_fstype &> /dev/null
[[ $? -eq 0 ]] && return 0
fi
done
echo "Detected change in File System"
return 1
- fi
- echo "Detected change in File System"
- return 1
+}
# returns 0 if system is not modified # returns 1 if system is modified # returns 2 if system modification is invalid @@ -374,6 +453,12 @@ is_system_modified() return $ret fi
- is_dump_fs_modified
- ret=$?
- if [ $ret -ne 0 ]; then
return $ret
- fi
- return 0
}
Hi Xunlei,
On 05/05/2016:11:20:51 AM, Xunlei Pang wrote:
On 2016/04/29 at 14:50, Pratyush Anand wrote:
Initramfs must be rebuild if:
-- "dump target" is specified as ext[234], xfs or btrfs and its UUID is changed by reformatting. -- "dump target" is specified as file system type fs1 (say ext3) but actual file system for the target device is of type fs2(ext4), however dracut "--mount" argument has file system type fs1 (say ext3) -- "dump target" is not specified, but "dump path" mounts a device which is different than device for root path and either UUID or file system type changes for a bulk device. -- "dump target" is nots specified, but "dump path" mounts a nfs device, but nfs host path changes
When "dump target" is specified as "raw" or "nfs" then it will rebuild only on the basis of kdump.conf modification time.
Testing:
Initial conditions: -- No dump target specified -- dump path (/var/crash) and root(/) are on same device -- kdumpctl was already executed once after last modification in /etc/kdump.conf
# kdumpctl restart No rebuild # mkfs.ext2 /dev/md0;mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # umount /var/crash;mkfs.ext4 /dev/md0; # mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
# umount /var/crash;mkfs.ext4 /dev/mapper/fedora-swap # mount /dev/mapper/fedora-swap /var/crash/ # kdumpctl restart Rebuilt because "Detected change in File System" # umount /var/crash;mkfs.btrfs /dev/mapper/fedora-swap -f # mount /dev/mapper/fedora-swap /var/crash/ # kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # mount /dev/mapper/fedora-swap /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
# umount /var/crash;mkfs.minix /dev/md0 # mount /dev/md0 /var/crash/; kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
# mount 192.168.1.16:/nfsroot /var/crash/;kdumpctl restart Rebuilt because "Detected change in NFS host" # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # mount 192.168.1.16:/nfsroot /var/crash/;kdumpctl restart Rebuilt because "Detected change in NFS host" # kdumpctl restart No rebuild # umount /var/crash;mount 192.168.1.12:/nfsroot /var/crash/ # kdumpctl restart Rebuilt because "Detected change in NFS host" # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
Added "raw /dev/md0" in /etc/kdump.conf # kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf" # mkfs.ext4 /dev/md0 ;kdumpctl restart No rebuild
Added "ext4 /dev/md0" in /etc/kdump.conf # mkfs.ext4 /dev/md0;mount /dev/md0 /mnt # mkdir /mnt/var;mkdir /mnt/var/crash; kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf" # umount /mnt;mkfs.ext4 /dev/md0;mount /dev/md0 /mnt # mkdir /mnt/var;mkdir /mnt/var/crash; kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf"
Signed-off-by: Pratyush Anand panand@redhat.com
kdumpctl | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+)
diff --git a/kdumpctl b/kdumpctl index 1cba00b9dc0f..c7abaafdda27 100755 --- a/kdumpctl +++ b/kdumpctl @@ -359,6 +359,85 @@ is_files_modified() return 0 }
+is_dump_fs_modified() +{
- local _dracut_args _mount _uuid _fstype _target _id _dev _tdev
- # No need to ckeck if raw target is specified
- is_raw_dump_target && return 0
- _target=$(get_user_configured_dump_disk)
- if [[ -n "$_target" ]]; then
_fstype=$(blkid $_target | awk -F"TYPE=" '{print $2}' | cut -d '"' -f 2)
- else
set -- $(df -T $(get_save_path) 2>/dev/null | tail -1 | awk '{ print $1, $2}')
_target=$1
_fstype=$2
For NFS target, if it got umounted, then "kdumpctl restart" will hit this and got empty _target and _fstype, so I think we should have a judgement here, otherwise it is problematic when executing following scripts.
But, when NFS target is unmounted then "dump path" will be pointing to a directory (say /var/crash) into a local filesystem. So the _target and _fstype would be of local FS.
See following:
[root@localhost panand]# mount 192.168.1.16:/nfsroot /var/crash/ [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change in NFS host Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# lsinitrd /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img | grep "Arguments" Arguments: --hostonly -o 'plymouth dash resume ifcfg' -a 'watchdog' --add 'nfs' --mount '192.168.1.16:/nfsroot /kdumproot//var/crash nfs4 rw,relatime,vers=4.1,rsize=65536,wsize=65536,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.1.12,local_lock=none,addr=192.168.1.16,x-initrd.mount' -f [root@localhost panand]# umount /var/crash [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change in File System Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# lsinitrd /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img | grep "Arguments" Arguments: --hostonly -o 'plymouth dash resume ifcfg' -a 'watchdog' -f
- fi
- _target=$(to_dev_name $_target)
- _dracut_args=$(lsinitrd $TARGET_INITRD | grep "^Arguments:" | head -1)
- if [[ -z "$_dracut_args" ]];then
echo "Warning: No dracut arguments found in initrd"
return 0
- fi
- # if --mount argument is not present and, dump path and root path
- # mounts same device then no need to check for FS modification
- echo $_dracut_args | grep "--mount" &> /dev/null
- _mount=$?
- [[ _mount -ne 0 ]] && [[ "$_target" = "$(get_root_fs_device)" ]] && return 0
- # for NFS FS check if dump path still mounts same host
- if [[ $(expr substr $_fstype 1 3) = "nfs" ]];then
echo $_dracut_args | grep $_target &> /dev/null
I guess things are more complicated than we thought before, for example, what if the fs mounting option changes? NFS that users mounted beforehand, or fs that users mounted directly onto the PATH. Is it worthy for us to handle with not-so-small code complexity introduced?
Probably, I could not get this correctly. When you say "NFS that users mounted beforehand,", do you mean that NFS mounting option specified through /etc/kdump.conf? and when you say that "nfs that users mounted directly onto the PATH", means when a NFS path is mounted to "dump path"?
I think, for such cases it will work. When we change anything into /etc/kdump.conf then this function will not be called. is_files_modified() will take care of that. If there was no modification in /etc.kdump.conf then only we come here to check for modifications.
~Pratyush
[[ $? -eq 0 ]] && return 0
echo "Detected change in NFS host"
return 1
- fi
- # if dracut argument has "by-uuid", and darcut argument also contains same uuid and fs type
- # as that of _target then also do not rebuild
- echo $_dracut_args | grep "by-uuid" &> /dev/null
- if [[ $? -eq 0 ]];then
_uuid=$(blkid $_target | awk -F"UUID=" '{print $2}' | cut -d '"' -f 2)
if [[ -n "$_uuid" ]]; then
echo $_dracut_args | grep $_uuid | grep $_fstype &> /dev/null
[[ $? -eq 0 ]] && return 0
fi
echo "Detected change in File System"
return 1
- fi
- # if dracut argument has "mapper", and darcut argument also contains same name and fs type
- # as that of _target then also do not rebuild
- echo $_dracut_args | grep "mapper" &> /dev/null
- if [[ $? -eq 0 ]];then
echo $_dracut_args | grep $_target | grep $_fstype &> /dev/null
[[ $? -eq 0 ]] && return 0
echo "Detected change in File System"
return 1
- fi
- # if dracut argument has "by-id", and darcut argument also contains same id and fs type
- # as that of _target then also do not rebuild
- echo $_dracut_args | grep "by-id" &> /dev/null
- if [[ $? -eq 0 ]];then
_tdev=$(udevadm info --query=name --name="$_target" 2>/dev/null)
for _id in /dev/disk/by-id/*; do
_dev=$(udevadm info --query=name --name="$_id" 2>/dev/null)
if [[ "$_tdev" = "$_dev" ]]; then
echo $_dracut_args | grep $_fstype &> /dev/null
[[ $? -eq 0 ]] && return 0
fi
done
echo "Detected change in File System"
return 1
- fi
- echo "Detected change in File System"
- return 1
+}
# returns 0 if system is not modified # returns 1 if system is modified # returns 2 if system modification is invalid @@ -374,6 +453,12 @@ is_system_modified() return $ret fi
- is_dump_fs_modified
- ret=$?
- if [ $ret -ne 0 ]; then
return $ret
- fi
- return 0
}
On 2016/05/05 at 13:10, Pratyush Anand wrote:
Hi Xunlei,
On 05/05/2016:11:20:51 AM, Xunlei Pang wrote:
On 2016/04/29 at 14:50, Pratyush Anand wrote:
Initramfs must be rebuild if:
-- "dump target" is specified as ext[234], xfs or btrfs and its UUID is changed by reformatting. -- "dump target" is specified as file system type fs1 (say ext3) but actual file system for the target device is of type fs2(ext4), however dracut "--mount" argument has file system type fs1 (say ext3) -- "dump target" is not specified, but "dump path" mounts a device which is different than device for root path and either UUID or file system type changes for a bulk device. -- "dump target" is nots specified, but "dump path" mounts a nfs device, but nfs host path changes
When "dump target" is specified as "raw" or "nfs" then it will rebuild only on the basis of kdump.conf modification time.
Testing:
Initial conditions: -- No dump target specified -- dump path (/var/crash) and root(/) are on same device -- kdumpctl was already executed once after last modification in /etc/kdump.conf
# kdumpctl restart No rebuild # mkfs.ext2 /dev/md0;mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # umount /var/crash;mkfs.ext4 /dev/md0; # mount /dev/md0 /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
# umount /var/crash;mkfs.ext4 /dev/mapper/fedora-swap # mount /dev/mapper/fedora-swap /var/crash/ # kdumpctl restart Rebuilt because "Detected change in File System" # umount /var/crash;mkfs.btrfs /dev/mapper/fedora-swap -f # mount /dev/mapper/fedora-swap /var/crash/ # kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # mount /dev/mapper/fedora-swap /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
# umount /var/crash;mkfs.minix /dev/md0 # mount /dev/md0 /var/crash/; kdumpctl restart Rebuilt because "Detected change in File System" # kdumpctl restart No rebuild # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
# mount 192.168.1.16:/nfsroot /var/crash/;kdumpctl restart Rebuilt because "Detected change in NFS host" # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System" # mount 192.168.1.16:/nfsroot /var/crash/;kdumpctl restart Rebuilt because "Detected change in NFS host" # kdumpctl restart No rebuild # umount /var/crash;mount 192.168.1.12:/nfsroot /var/crash/ # kdumpctl restart Rebuilt because "Detected change in NFS host" # umount /var/crash/;kdumpctl restart Rebuilt because "Detected change in File System"
Added "raw /dev/md0" in /etc/kdump.conf # kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf" # mkfs.ext4 /dev/md0 ;kdumpctl restart No rebuild
Added "ext4 /dev/md0" in /etc/kdump.conf # mkfs.ext4 /dev/md0;mount /dev/md0 /mnt # mkdir /mnt/var;mkdir /mnt/var/crash; kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf" # umount /mnt;mkfs.ext4 /dev/md0;mount /dev/md0 /mnt # mkdir /mnt/var;mkdir /mnt/var/crash; kdumpctl restart Rebuilt because "Detected change in /etc/kdump.conf"
Signed-off-by: Pratyush Anand panand@redhat.com
kdumpctl | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+)
diff --git a/kdumpctl b/kdumpctl index 1cba00b9dc0f..c7abaafdda27 100755 --- a/kdumpctl +++ b/kdumpctl @@ -359,6 +359,85 @@ is_files_modified() return 0 }
+is_dump_fs_modified() +{
- local _dracut_args _mount _uuid _fstype _target _id _dev _tdev
- # No need to ckeck if raw target is specified
- is_raw_dump_target && return 0
- _target=$(get_user_configured_dump_disk)
- if [[ -n "$_target" ]]; then
_fstype=$(blkid $_target | awk -F"TYPE=" '{print $2}' | cut -d '"' -f 2)
- else
set -- $(df -T $(get_save_path) 2>/dev/null | tail -1 | awk '{ print $1, $2}')
_target=$1
_fstype=$2
For NFS target, if it got umounted, then "kdumpctl restart" will hit this and got empty _target and _fstype, so I think we should have a judgement here, otherwise it is problematic when executing following scripts.
But, when NFS target is unmounted then "dump path" will be pointing to a directory (say /var/crash) into a local filesystem. So the _target and _fstype
If you configure PATH to be a directory not existent in the 1st kernel, it will fail. For example, in my environment: nfs 10.66.129.115:/export/nfs #nfs_mntopts nolock,timeo=555,rw path /xlpang
"/xlpang" is only existent on the remote server.
would be of local FS.
See following:
[root@localhost panand]# mount 192.168.1.16:/nfsroot /var/crash/ [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change in NFS host Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# lsinitrd /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img | grep "Arguments" Arguments: --hostonly -o 'plymouth dash resume ifcfg' -a 'watchdog' --add 'nfs' --mount '192.168.1.16:/nfsroot /kdumproot//var/crash nfs4 rw,relatime,vers=4.1,rsize=65536,wsize=65536,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.1.12,local_lock=none,addr=192.168.1.16,x-initrd.mount' -f [root@localhost panand]# umount /var/crash [root@localhost panand]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Detected change in File System Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img kexec: loaded kdump kernel Starting kdump: [OK] [root@localhost panand]# lsinitrd /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img | grep "Arguments" Arguments: --hostonly -o 'plymouth dash resume ifcfg' -a 'watchdog' -f
- fi
- _target=$(to_dev_name $_target)
- _dracut_args=$(lsinitrd $TARGET_INITRD | grep "^Arguments:" | head -1)
- if [[ -z "$_dracut_args" ]];then
echo "Warning: No dracut arguments found in initrd"
return 0
- fi
- # if --mount argument is not present and, dump path and root path
- # mounts same device then no need to check for FS modification
- echo $_dracut_args | grep "--mount" &> /dev/null
- _mount=$?
- [[ _mount -ne 0 ]] && [[ "$_target" = "$(get_root_fs_device)" ]] && return 0
- # for NFS FS check if dump path still mounts same host
- if [[ $(expr substr $_fstype 1 3) = "nfs" ]];then
echo $_dracut_args | grep $_target &> /dev/null
I guess things are more complicated than we thought before, for example, what if the fs mounting option changes? NFS that users mounted beforehand, or fs that users mounted directly onto the PATH. Is it worthy for us to handle with not-so-small code complexity introduced?
Probably, I could not get this correctly. When you say "NFS that users mounted beforehand,", do you mean that NFS mounting option specified through /etc/kdump.conf? and when you say that "nfs that users mounted directly onto the PATH", means when a NFS path is mounted to "dump path"?
The latter, but user can mount NFS onto anywhere not on PATH.
I think, for such cases it will work. When we change anything into /etc/kdump.conf then this function will not be called. is_files_modified() will take care of that. If there was no modification in /etc.kdump.conf then only we come here to check for modifications.
Users don't need to change /etc/kdump.conf, they can remount the NFS using different options and different mntpoint.
I am now kind of a supporter of Dave's previous comments :-) "I feel we are doing too much"
Regards, Xunlei
~Pratyush
[[ $? -eq 0 ]] && return 0
echo "Detected change in NFS host"
return 1
- fi
- # if dracut argument has "by-uuid", and darcut argument also contains same uuid and fs type
- # as that of _target then also do not rebuild
- echo $_dracut_args | grep "by-uuid" &> /dev/null
- if [[ $? -eq 0 ]];then
_uuid=$(blkid $_target | awk -F"UUID=" '{print $2}' | cut -d '"' -f 2)
if [[ -n "$_uuid" ]]; then
echo $_dracut_args | grep $_uuid | grep $_fstype &> /dev/null
[[ $? -eq 0 ]] && return 0
fi
echo "Detected change in File System"
return 1
- fi
- # if dracut argument has "mapper", and darcut argument also contains same name and fs type
- # as that of _target then also do not rebuild
- echo $_dracut_args | grep "mapper" &> /dev/null
- if [[ $? -eq 0 ]];then
echo $_dracut_args | grep $_target | grep $_fstype &> /dev/null
[[ $? -eq 0 ]] && return 0
echo "Detected change in File System"
return 1
- fi
- # if dracut argument has "by-id", and darcut argument also contains same id and fs type
- # as that of _target then also do not rebuild
- echo $_dracut_args | grep "by-id" &> /dev/null
- if [[ $? -eq 0 ]];then
_tdev=$(udevadm info --query=name --name="$_target" 2>/dev/null)
for _id in /dev/disk/by-id/*; do
_dev=$(udevadm info --query=name --name="$_id" 2>/dev/null)
if [[ "$_tdev" = "$_dev" ]]; then
echo $_dracut_args | grep $_fstype &> /dev/null
[[ $? -eq 0 ]] && return 0
fi
done
echo "Detected change in File System"
return 1
- fi
- echo "Detected change in File System"
- return 1
+}
# returns 0 if system is not modified # returns 1 if system is modified # returns 2 if system modification is invalid @@ -374,6 +453,12 @@ is_system_modified() return $ret fi
- is_dump_fs_modified
- ret=$?
- if [ $ret -ne 0 ]; then
return $ret
- fi
- return 0
}
Hi,
I think, for such cases it will work. When we change anything into /etc/kdump.conf then this function will not be called. is_files_modified() will take care of that. If there was no modification in /etc.kdump.conf then only we come here to check for modifications.
Users don't need to change /etc/kdump.conf, they can remount the NFS using different options and different mntpoint.
I am now kind of a supporter of Dave's previous comments :-) "I feel we are doing too much"
Handle the fs uuid changes first should be good enough for now. How about dropping nfs for the time being, we can not do 100% perfect. This does not mean we refuse do it we can still evaluate the issue if someone report it as a problem.
Thanks Dave
On 05/05/2016:05:07:45 PM, Dave Young wrote:
Hi,
I think, for such cases it will work. When we change anything into /etc/kdump.conf then this function will not be called. is_files_modified() will take care of that. If there was no modification in /etc.kdump.conf then only we come here to check for modifications.
Users don't need to change /etc/kdump.conf, they can remount the NFS using different options and different mntpoint.
I am now kind of a supporter of Dave's previous comments :-) "I feel we are doing too much"
Handle the fs uuid changes first should be good enough for now. How about dropping nfs for the time being, we can not do 100% perfect. This does not mean we refuse do it we can still evaluate the issue if someone report it as a problem.
OK..Will send final version today and then we can always have add ons latter.
~Pratyush
Hi, Pratyush and xunlei
On 04/29/16 at 12:20pm, Pratyush Anand wrote:
Kexec-tools should be able to recognize if a dump target is reformatted, or dump path mounts another device.
Changes since v4:
- patch 4/5 is a new change
- patch 4/4 of V3 is now 4/5. There has been many modifications in this patch. It includes feedback from Baoquan and Xunlei. Have also done some
modification to recognize changes related to minix and NFS filesystem as well. Infact, whole structure of function is_fs_uuid_changed() has been modified. Now it has been renamed as is_dump_fs_modified() to suit it better. Although I have tested it rigorously, but still a careful review of is_dump_fs_modified() will be helpful.
I feel we are doing too much, for example the fs type changes. Should we really allow that especially for user specified dump targets in /etc/kdump.conf?
It is rare use cases for fs changes, maybe we should limit the support instead of encouraging user to depends on it too much.
Ditto worries about the nfs part, thoughts?
BTW, since we support detect $dump_path fs automaticlly in the future maybe we can drop the "fs dev" in /etc/kdump.conf, we can check the dump_path directly but it is another issue.
Thanks Dave
On 2016/04/29 at 17:16, Dave Young wrote:
Hi, Pratyush and xunlei
On 04/29/16 at 12:20pm, Pratyush Anand wrote:
Kexec-tools should be able to recognize if a dump target is reformatted, or dump path mounts another device.
Changes since v4:
- patch 4/5 is a new change
- patch 4/4 of V3 is now 4/5. There has been many modifications in this patch. It includes feedback from Baoquan and Xunlei. Have also done some
modification to recognize changes related to minix and NFS filesystem as well. Infact, whole structure of function is_fs_uuid_changed() has been modified. Now it has been renamed as is_dump_fs_modified() to suit it better. Although I have tested it rigorously, but still a careful review of is_dump_fs_modified() will be helpful.
I feel we are doing too much, for example the fs type changes. Should we really allow that especially for user specified dump targets in /etc/kdump.conf?
It is rare use cases for fs changes, maybe we should limit the support instead of encouraging user to depends on it too much.
Ditto worries about the nfs part, thoughts?
BTW, since we support detect $dump_path fs automaticlly in the future maybe we can drop the "fs dev" in /etc/kdump.conf, we can check the dump_path directly but it is another issue.
I think for cases that require an explicit modification of kdump.conf in order to ensure correctness, we can ignore, otherwise we should handle.
For example: nfs server changes, and users should modify the kdump.conf for correctness, we can ignore.
But if only a path is specified, once the storage the path is on changes, users don't need to modify kdump.conf as the configuration is correct, they just need a kdump restart to trigger rebuilding.
Regards, Xunlei
Thanks Dave
Hi Dave,
Thanks for your feedback.
On Fri, Apr 29, 2016 at 3:13 PM, Xunlei Pang xpang@redhat.com wrote:
On 2016/04/29 at 17:16, Dave Young wrote:
Hi, Pratyush and xunlei
On 04/29/16 at 12:20pm, Pratyush Anand wrote:
Kexec-tools should be able to recognize if a dump target is reformatted, or dump path mounts another device.
Changes since v4:
- patch 4/5 is a new change
- patch 4/4 of V3 is now 4/5. There has been many modifications in this patch. It includes feedback from Baoquan and Xunlei. Have also done some
modification to recognize changes related to minix and NFS filesystem as well. Infact, whole structure of function is_fs_uuid_changed() has been modified. Now it has been renamed as is_dump_fs_modified() to suit it better. Although I have tested it rigorously, but still a careful review of is_dump_fs_modified() will be helpful.
I feel we are doing too much, for example the fs type changes. Should we really allow that especially for user specified dump targets in /etc/kdump.conf?
In fact explicit modification of user specified dump target in kdump.conf is not an issue. That is well detected by is_files_modified() which has higher precedence over is_dump_fs_modified(). These patches are mostly to take care of the cases when "dump path" mounts a bulk or nfs target. Patch 5/5 will help to detect if either there is a change in the bulk mounted device or "dump path" mounts to another bulk device/nfs directory.
For example: /var/crash was mounting /dev/sdb1, but now it mounts /dev/sdc1 /var/crash was mounting /dev/sdb1, but now /dev/sdb1 has been reformatted to either same file-system type or different file-system type. /var/crash was mounting 192.168.1.16:/nfsroot, but now it mounts 192.168.1.12:/nfsroot
~Pratyush
On 04/29/16 at 05:43pm, Xunlei Pang wrote:
On 2016/04/29 at 17:16, Dave Young wrote:
Hi, Pratyush and xunlei
On 04/29/16 at 12:20pm, Pratyush Anand wrote:
Kexec-tools should be able to recognize if a dump target is reformatted, or dump path mounts another device.
Changes since v4:
- patch 4/5 is a new change
- patch 4/4 of V3 is now 4/5. There has been many modifications in this patch. It includes feedback from Baoquan and Xunlei. Have also done some
modification to recognize changes related to minix and NFS filesystem as well. Infact, whole structure of function is_fs_uuid_changed() has been modified. Now it has been renamed as is_dump_fs_modified() to suit it better. Although I have tested it rigorously, but still a careful review of is_dump_fs_modified() will be helpful.
I feel we are doing too much, for example the fs type changes. Should we really allow that especially for user specified dump targets in /etc/kdump.conf?
It is rare use cases for fs changes, maybe we should limit the support instead of encouraging user to depends on it too much.
Ditto worries about the nfs part, thoughts?
BTW, since we support detect $dump_path fs automaticlly in the future maybe we can drop the "fs dev" in /etc/kdump.conf, we can check the dump_path directly but it is another issue.
I think for cases that require an explicit modification of kdump.conf in order to ensure correctness, we can ignore, otherwise we should handle.
That's fine if both of you want a complete fix.
For example: nfs server changes, and users should modify the kdump.conf for correctness, we can ignore.
But if only a path is specified, once the storage the path is on changes, users don't need to modify kdump.conf as the configuration is correct, they just need a kdump restart to trigger rebuilding.
Got your concern.
Thanks Dave