On 04/30/19 at 01:15pm, Kairui Song wrote:
We don't necessarily have to always rebuild the initramfs when
extra_modules is set, instead just detect if any module is updated
and only rebuild initramfs if found any updated kernel module.
Hi Kairui,
About the DUP modules, probably it is RHEL only, but probably in Fedora
it also has something related, I found below thread about weak updates:
https://lists.fedoraproject.org/pipermail/devel/2006-August/088293.html
So it is worth to dig it and do some tests.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
kdumpctl | 38 +++++++++++++++++++++++++++++++++-----
1 file changed, 33 insertions(+), 5 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 3f80ba4..f2e2b76 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -486,6 +486,34 @@ check_wdt_modified()
return 1
}
+# Check if any extra kernel is changed
+check_kmodules_modified()
+{
+ local _extra_modules="$(grep ^extra_modules $KDUMP_CONFIG_FILE | sed
's/^extra_modules\s*//')"
+ local _modified_modules
+
+ # Check for any updated module
+ for _module in $_extra_modules; do
+ _module_file="$(modinfo -k "$kdump_kver" -n "$_module"
2>/dev/null)"
+ if [[ -n "$_module_file" ]]; then
+ _time_stamp="$(stat -c "%Y" "$_module_file")"
+ if [ "$_time_stamp" -gt "$image_time" ]; then
+ _modified_modules+="$_module "
Here once we found a module is changed then we can just print some msg
and return 1, so that we can reduce the kdumpctl checking time.
+ fi
+ fi
+ done
+
+ if [[ -n "$_modified_modules" ]]; then
+ echo "Detected change(s) of following kernel modules:"
+ for _module in $_modified_modules; do
+ echo "$_module"
+ done
+ 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
@@ -513,12 +541,16 @@ check_system_modified()
return 1
fi
+ check_kmodules_modified
+ if [ $? -ne 0 ]; then
+ return 1
+ fi
+
There is a function check_files_modified(), another way is just return
the filenames and let check_files_modified() to check the timestamps.
But I'm not sure which way use less time, maybe do some tests and choose
a better one?
> return 0
> }
>
> check_rebuild()
> {
> - local extra_modules
> local capture_capable_initrd="1"
> local _force_rebuild force_rebuild="0"
> local _force_no_rebuild force_no_rebuild="0"
> @@ -558,10 +590,6 @@ check_rebuild()
> return 0
> fi
>
> - #will rebuild every time if extra_modules are specified
> - extra_modules=`grep ^extra_modules $KDUMP_CONFIG_FILE`
> - [ -n "$extra_modules" ] && force_rebuild="1"
> -
> #check to see if dependent files has been modified
> #since last build of the image file
> if [ -f $TARGET_INITRD ]; then
> --
> 2.20.1
>