On Fri, Apr 29, 2016 at 2:10 PM, Xunlei Pang <xpang(a)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(a)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