Hi Kairui,
On Fri, 17 Sep 2021 02:03:27 +0800
Kairui Song <kasong(a)redhat.com> wrote:
Only acquire the single instance lock when following commands are
used:
- kdumpctl start
- kdumpctl restart
- kdumpctl rebuild
- kdumpctl reload
- kdumpctl stop
- kdumpctl propagate
in my opinion kdumpctl status should also be protected by the lock.
Otherwise there could be a race with e.g. kdumpctl start creating the
initramfs.
Thanks
Philipp
For other commands, like showmem, estimate or help, there is no
reason
for kdumpctl to be blocked.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
This is based on the series: [PATCH 0/3] Remove harcoded FDs
kdumpctl | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 048404b1..720820f8 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -1346,6 +1346,7 @@ main()
case "$1" in
start)
+ single_instance_lock
if [[ -s /proc/vmcore ]]; then
save_core
reboot
@@ -1354,6 +1355,7 @@ main()
fi
;;
stop)
+ single_instance_lock
stop
;;
status)
@@ -1372,17 +1374,22 @@ main()
exit $EXIT_CODE
;;
reload)
+ single_instance_lock
reload
;;
restart)
+ single_instance_lock
stop
start
;;
rebuild)
+ single_instance_lock
rebuild
;;
- condrestart) ;;
+ condrestart)
+ ;;
propagate)
+ single_instance_lock
propagate_ssh_key
;;
showmem)
@@ -1401,9 +1408,6 @@ main()
esac
}
-# Other kdumpctl instances will block in queue, until this one exits
-single_instance_lock
-
main "$@"
exit $?