-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timeout usbstick automount after 2 seconds #270
Conversation
When user tries to perform any operation that involves USB stick (e.g. "Download IGC") and USB stick is not inserted, openvario appears to "freeze" - becomes unresponsive, with no way to recover. This is because it waits for /dev/sda1 device to appear in order to mount it. With the default 90s timeout the system appears to be stuck. This lowers the timeout to 2 seconds to "unstuck" the system quickly enough before user gets frustrated.
And actually, I wouldn't use the auto-mounter at all. I changed to systemd automount not because I think auto-mounting is fine, but only because I think systemd can do that feature better than the old "autofs" daemon. I think it's better to explicitly mount in all programs that wish to access the USB stick, and more importantly: explicitly unmount when finished. |
Automounter is nice in a way because it handles all the edge cases. E.g. it makes sure device is correctly unmounted even if app that reads the device crashes because the stick was taken out in the middle of copy operation. |
That's what I do in ovshell - wait for device to appear before looking into the |
You're right. Though, reading the systemd source code, it looks like "JobRunningTimeoutSec" is better. The fstab generator translates "x-systemd.device-timeout" ("Configure how long systemd should wait for a device to show up before giving up") to "JobRunningTimeoutSec": https://github.com/systemd/systemd/blob/main/src/shared/generator.c#L281 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK for me.
But we should really think about the solution Max mentioned: Only mount the stick if necessary (an app needs it)
@MaxKellermann |
Can we merge this? |
Assuming no objections. |
Does this mean the systemd generator is buggy? |
I don't see why you would imply that. |
Because:
But I found the answer already: this sets the device's timeout, not the mount's timeout. So... the proper way of fixing this would be to set |
This is the proper fix for Openvario#270 because this is the way systemd's fstab generator does it; it translates "x-systemd.device-timeout" ("Configure how long systemd should wait for a device to show up before giving up") to "JobRunningTimeoutSec" in the device unit: https://github.com/systemd/systemd/blob/main/src/shared/generator.c#L281 The journal now looks like this: systemd[1]: usb-usbstick.automount: Got automount request for /usb/usbstick, triggered by 1224 (ls) systemd[1]: dev-sda1.device: Job dev-sda1.device/start timed out. systemd[1]: Timed out waiting for device USB stick. systemd[1]: Dependency failed for Automatically mount connected USB drives. systemd[1]: usb-usbstick.mount: Job usb-usbstick.mount/start failed with result 'dependency'. systemd[1]: dev-sda1.device: Job dev-sda1.device/start failed with result 'timeout'. Before, it looked like this: systemd[1]: usb-usbstick.automount: Got automount request for /usb/usbstick, triggered by 1320 (ls) systemd[1]: usb-usbstick.mount: Job usb-usbstick.mount/start timed out. systemd[1]: Timed out mounting Automatically mount connected USB drives. systemd[1]: usb-usbstick.mount: Job usb-usbstick.mount/start failed with result 'timeout'. systemd[1]: Unnecessary job was removed for /dev/sda1. Now systemd clearly states that waiting for the USB stick has timed out, not that mounting it has timed out.
When user tries to perform any operation that involves USB stick (e.g.
"Download IGC") and USB stick is not inserted, openvario appears to
"freeze" - becomes unresponsive, with no way to recover.
This is because it waits for /dev/sda1 device to appear in order to
mount it. With the default 90s timeout the system appears to be stuck.
This lowers the timeout to 2 seconds to "unstuck" the system quickly
enough before user gets frustrated.