Commit Graph

328 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 886cf317c4 coccinelle: also mark previous synthetic errnos as such 2018-11-22 10:54:38 +01:00
Zbigniew Jędrzejewski-Szmek 0c5a109a25 udevd: define main through macro
This removes the call to log_close(), and refactors how fork() is done. Now
the parent also goes through normal cleanup. This isn't necessary to use the
macro, but it feels cleaner this way.
2018-11-21 09:14:00 +01:00
Zbigniew Jędrzejewski-Szmek 294bf0c34a Split out pretty-print.c and move pager.c and main-func.h to shared/
This is high-level functionality, and fits better in shared/ (which is for
our executables), than in basic/ (which is also for libraries).
2018-11-20 18:40:02 +01:00
Yu Watanabe 5ea78a39e5 libudev-list: move libudev-list related definitions to libudev-list-internal.h
This also rename libudev-private.h to libudev-util.h, and cleanups
several unnecessary headers from udev.h and libudev-util.h
2018-11-20 14:38:35 +09:00
Yu Watanabe eb546b3532 udevd: replace udev_device in struct event by sd_device 2018-11-17 21:45:03 +09:00
Yu Watanabe 044497e2a3 udevd: update several log messages 2018-11-17 21:45:03 +09:00
Yu Watanabe ba47b71c2d udevd: decrease indentation 2018-11-17 21:45:03 +09:00
Yu Watanabe d8f462b435 udevd: rename event sources in struct event 2018-11-17 21:45:03 +09:00
Yu Watanabe dc7faf2a6f udevd: capitalize log messages in on_sigchld() 2018-11-17 21:45:03 +09:00
Yu Watanabe e2130348ef udevd: also use sd_device_monitor_start() in worker_main() 2018-11-17 21:45:03 +09:00
Yu Watanabe f00d2b6dd2 udevd: use sd_device_monitor_start() in manager_new() 2018-11-17 21:45:03 +09:00
Yu Watanabe 7f2e3a1409 udevd: replace udev_monitor by sd_device_monitor 2018-11-17 21:45:03 +09:00
Yu Watanabe 7443654e5f udevd: use safe_fork() to spawn worker process 2018-11-17 21:45:03 +09:00
Yu Watanabe abde5ea854 udevd: make worker_process_device() take sd_device instead of udev_device 2018-11-17 21:45:03 +09:00
Yu Watanabe b97897e3e8 udevd: make worker_lock_block_device() take sd_device instead of udev_device
Also adds many debug logs.
2018-11-17 21:45:02 +09:00
Yu Watanabe 0bed242cbe udevd: split worker_spawn() and manager_free() in small pieces 2018-11-17 21:45:02 +09:00
Yu Watanabe 0725c4b9d1 udevd: use event_source_disable() 2018-11-16 22:57:42 +09:00
Yu Watanabe 6d63048a77 udevd: use event_reset_time() to update kill_workers_event 2018-11-16 22:57:42 +09:00
Lennart Poettering 8755568681
Merge pull request #10759 from keszybz/udevd-more-configuration
Udevd more configuration options
2018-11-14 16:21:14 +01:00
Zbigniew Jędrzejewski-Szmek 7fe0d0d5c0 udev: downgrade message when we fail to set inotify watch up
My logs are full of:

systemd-udevd[6586]: seq 13515 queued, 'add' 'block'
systemd-udevd[6586]: seq 13516 queued, 'change' 'block'
systemd-udevd[6586]: seq 13517 queued, 'change' 'block'
systemd-udevd[6586]: seq 13518 queued, 'remove' 'bdi'
systemd-udevd[6586]: seq 13519 queued, 'remove' 'block'
systemd-udevd[9865]: seq 13514 processed
systemd-udevd[9865]: seq 13515 running
systemd-udevd[9865]: GROUP 6 /usr/lib/udev/rules.d/50-udev-default.rules:59
systemd-udevd[9865]: IMPORT builtin 'blkid' /usr/lib/udev/rules.d/60-persistent-storage.rules:95
systemd-udevd[9865]: IMPORT builtin 'blkid' fails: No such file or directory
systemd-udevd[9865]: loop4: Failed to add device '/dev/loop4' to watch: No such file or directory
(the last line is at error level).
If we are too slow to set up a watch and the device is already gone by the time
we try, this is not an error.
2018-11-13 22:02:55 +01:00
Zbigniew Jędrzejewski-Szmek a14e7af162 udev: also allow resolve_names= to be specified in udev.conf 2018-11-13 14:35:36 +01:00
Zbigniew Jędrzejewski-Szmek 4b3ca79ea9 udevd: allow more parameters to be set through udev.conf
Rebooting to set change the kernel command line to set some udev parameters is
inconvenient. Let's allow setting more stuff in the config file.

Also drop quotes from around "info" in udev.conf. We need to accept them for
compatibility, but there is no reason to use them.
2018-11-13 14:03:47 +01:00
Zbigniew Jędrzejewski-Szmek 66f737b415 udev: do not pass timeout_warn_usec around, calculate it on demand
It was always set to one third of timeout_usec, so let's simplify things by
calculating it using a helper function right before it is used.

Before 9d9264ba39, udevd.c would avoid setting
timeout_warn_usec to 0, using 1 instead. This wasn't necessary, because when
timeout_warn_usec is finally used in spawn_wait(), it is ignored if
timeout_usec is 0 or timeout_warn_usec is 0. So there was no need to handle
this case specially.
2018-11-13 14:00:32 +01:00
Yu Watanabe 6f19b42f24 udev: use structured initializer at one more place 2018-11-12 23:25:59 +09:00
Yu Watanabe c4b69e990f udev: drop redundant initializations for file descriptors
As udev_ctrl_new_from_fd() or udev_monitor_new_from_netlink_fd()
creates fd if negative fd is passed.
2018-11-12 23:25:59 +09:00
Yu Watanabe c52cff0748 udev: handle sd_is_socket() failure 2018-11-12 23:25:59 +09:00
Yu Watanabe 46f0fbd8fd udev: drop util_log_priority() and use log_level_from_string()
The function util_log_priority() is almost same as
log_level_from_string(). The difference between them is only that
util_log_priority() accepts such that '3 hogehoge'.
2018-11-12 23:25:40 +09:00
Yu Watanabe 9d9264ba39 udev: use parse_sec() to parse --event-timeout option 2018-11-12 23:25:34 +09:00
Yu Watanabe 389f9bf2cf udev: include error cause of parsing --children-max option in log message 2018-11-12 23:21:49 +09:00
Yu Watanabe c4d44cba4d udev: introduce enum ResolveNameTiming for --resolve-names argument 2018-11-12 23:20:53 +09:00
Yu Watanabe 6b92f42934 udevd: use parse_sec() to parse --exec-delay option 2018-11-12 23:16:54 +09:00
Yu Watanabe 216e8bbe34 udevd: explicitly set default value of global variables 2018-11-12 23:12:06 +09:00
Yu Watanabe edc81c1ccb udevd: do not treat negative value as valid ifindex
Also, some conditions in is_devpath_busy() are similified.
2018-11-12 13:07:10 +09:00
Yu Watanabe cf28ad4689 udev-event: make udev_event_new() take sd_device instead of udev_device 2018-11-07 13:35:03 +09:00
Yu Watanabe e0bb2ff94b udev-event: make udev_event_new() take sd_netlink and take a reference of that 2018-11-07 13:35:03 +09:00
Yu Watanabe 0f86dc900e udev-event: make udev_event_new() take exec_delay 2018-11-07 13:35:03 +09:00
Lennart Poettering 39adc47495
Merge pull request #10658 from yuwata/udevd-worker-performance
udev: improve performance
2018-11-06 20:01:37 +03:00
Lennart Poettering 9edcbc4f44
Merge pull request #10602 from yuwata/sd-device-logs
update log messages
2018-11-06 19:33:51 +03:00
Yu Watanabe faae64fa3d udevd: increase default number of workers
The uevent handling in udevd is not cpu hungry.
So, let's increase the default number of workers per cpu.
This decrease the number of queued uevents.

Without this commit (children_max is 16 on my laptop)
```
$ journalctl -b -u systemd-udevd.service | grep reached | wc -l
1544
```
With this commit (children_max is 30 on my laptop)
```
$ journalctl -b -u systemd-udevd.service | grep reached | wc -l
7
```
2018-11-07 00:25:20 +09:00
Yu Watanabe eca195ec23 udevd: wait 3 seconds before killing worker processes
During boot process, many worker processes are forked and killed.
To decrease cycles of forking and killing worker, let's wait
3 seconds before killing workers. If new uevent or inotify event
comes within the delay, the killing porcess will be cancelled.
2018-11-07 00:25:13 +09:00
Yu Watanabe da14313418 udevd: drop redundant logic of receiving uevent
If there exists pending uevents, then sd-event invokes uevent handler.
So, it is not necessary to receive the next uevent in inotify event.
2018-11-06 23:53:55 +09:00
Yu Watanabe b6107f010a udevd: decrease indentation 2018-11-06 23:53:50 +09:00
Yu Watanabe 05e6d9c64b udevd: merge conditions to decrease indentation 2018-11-06 23:21:25 +09:00
Yu Watanabe 57512c893e tree-wide: set WRITE_STRING_FILE_DISABLE_BUFFER flag when we write files under /proc or /sys 2018-11-06 21:24:03 +09:00
Yu Watanabe 76cdddfb9d udevd: use set_oom_score_adjust() to set OOM score 2018-11-06 21:24:03 +09:00
Yu Watanabe 6174a243f9 udev: setting the same log level to SYSTEMD realm
Otherwise, many debug logs from libsystemd are dropped.
2018-11-06 15:45:22 +09:00
Yu Watanabe 7fe3324c5e udev-watch: make udev_watch_lookup() return 1 when device found 2018-11-06 11:15:39 +09:00
Yu Watanabe b7759e0403 udev: drop redundant log message and fix returned error code 2018-11-06 11:15:39 +09:00
Yu Watanabe c1118ceba4 udev-event: rename udev_event_unref() to udev_event_free()
As struct udev_event does not have a reference counter.
2018-10-27 07:03:39 +09:00
Lennart Poettering 2ff48e981e tree-wide: introduce setsockopt_int() helper and make use of it everywhere
As suggested by @heftig:

6d5e65f645 (commitcomment-30938667)
2018-10-18 19:50:29 +02:00