return 1;
}
+static int mount_subsystem_ratelimited(Manager *m) {
+ assert(m);
+
+ if (!m->mount_event_source)
+ return false;
+
+ return sd_event_source_is_ratelimited(m->mount_event_source);
+}
+
static const char* const mount_exec_command_table[_MOUNT_EXEC_COMMAND_MAX] = {
[MOUNT_EXEC_MOUNT] = "ExecMount",
[MOUNT_EXEC_UNMOUNT] = "ExecUnmount",
.enumerate_perpetual = mount_enumerate_perpetual,
.enumerate = mount_enumerate,
.shutdown = mount_shutdown,
+ .subsystem_ratelimited = mount_subsystem_ratelimited,
.status_message_formats = {
.starting_stopping = {
assert(u);
- /* Let's hold off running start jobs for mount units when /proc/self/mountinfo monitor is rate limited. */
- if (u->type == UNIT_MOUNT && sd_event_source_is_ratelimited(u->manager->mount_event_source))
- return -EAGAIN;
+ /* Let's hold off running start jobs for mount units when /proc/self/mountinfo monitor is ratelimited. */
+ if (UNIT_VTABLE(u)->subsystem_ratelimited) {
+ r = UNIT_VTABLE(u)->subsystem_ratelimited(u->manager);
+ if (r < 0)
+ return r;
+ if (r > 0)
+ return -EAGAIN;
+ }
/* If this is already started, then this will succeed. Note that this will even succeed if this unit
* is not startable by the user. This is relied on to detect when we need to wait for units and when
* limiting checks to occur before we do anything else. */
int (*can_start)(Unit *u);
+ /* Returns > 0 if the whole subsystem is ratelimited, and new start operations should not be started
+ * for this unit type right now. */
+ int (*subsystem_ratelimited)(Manager *m);
+
/* The strings to print in status messages */
UnitStatusMessageFormats status_message_formats;