"ratelimit" is a real word, so we don't need to use the other form anywhere.
We had both forms in various places, let's standarize on the shorter and more
correct one.
SD_BUS_PROPERTY("SyslogLevel", "i", property_get_syslog_level, offsetof(ExecContext, syslog_priority), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("SyslogFacility", "i", property_get_syslog_facility, offsetof(ExecContext, syslog_priority), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("LogLevelMax", "i", bus_property_get_int, offsetof(ExecContext, log_level_max), SD_BUS_VTABLE_PROPERTY_CONST),
- SD_BUS_PROPERTY("LogRateLimitIntervalUSec", "t", bus_property_get_usec, offsetof(ExecContext, log_rate_limit_interval_usec), SD_BUS_VTABLE_PROPERTY_CONST),
- SD_BUS_PROPERTY("LogRateLimitBurst", "u", bus_property_get_unsigned, offsetof(ExecContext, log_rate_limit_burst), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("LogRateLimitIntervalUSec", "t", bus_property_get_usec, offsetof(ExecContext, log_ratelimit_interval_usec), SD_BUS_VTABLE_PROPERTY_CONST),
+ SD_BUS_PROPERTY("LogRateLimitBurst", "u", bus_property_get_unsigned, offsetof(ExecContext, log_ratelimit_burst), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("LogExtraFields", "aay", property_get_log_extra_fields, 0, SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("SecureBits", "i", bus_property_get_int, offsetof(ExecContext, secure_bits), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("CapabilityBoundingSet", "t", NULL, offsetof(ExecContext, capability_bounding_set), SD_BUS_VTABLE_PROPERTY_CONST),
return bus_set_transient_log_level(u, name, &c->log_level_max, message, flags, error);
if (streq(name, "LogRateLimitIntervalUSec"))
- return bus_set_transient_usec(u, name, &c->log_rate_limit_interval_usec, message, flags, error);
+ return bus_set_transient_usec(u, name, &c->log_ratelimit_interval_usec, message, flags, error);
if (streq(name, "LogRateLimitBurst"))
- return bus_set_transient_unsigned(u, name, &c->log_rate_limit_burst, message, flags, error);
+ return bus_set_transient_unsigned(u, name, &c->log_ratelimit_burst, message, flags, error);
if (streq(name, "Personality"))
return bus_set_transient_personality(u, name, &c->personality, message, flags, error);
exec_context_free_log_extra_fields(c);
- c->log_rate_limit_interval_usec = 0;
- c->log_rate_limit_burst = 0;
+ c->log_ratelimit_interval_usec = 0;
+ c->log_ratelimit_burst = 0;
c->stdin_data = mfree(c->stdin_data);
c->stdin_data_size = 0;
fprintf(f, "%sLogLevelMax: %s\n", prefix, strna(t));
}
- if (c->log_rate_limit_interval_usec > 0) {
+ if (c->log_ratelimit_interval_usec > 0) {
char buf_timespan[FORMAT_TIMESPAN_MAX];
fprintf(f,
"%sLogRateLimitIntervalSec: %s\n",
- prefix, format_timespan(buf_timespan, sizeof(buf_timespan), c->log_rate_limit_interval_usec, USEC_PER_SEC));
+ prefix, format_timespan(buf_timespan, sizeof(buf_timespan), c->log_ratelimit_interval_usec, USEC_PER_SEC));
}
- if (c->log_rate_limit_burst > 0)
- fprintf(f, "%sLogRateLimitBurst: %u\n", prefix, c->log_rate_limit_burst);
+ if (c->log_ratelimit_burst > 0)
+ fprintf(f, "%sLogRateLimitBurst: %u\n", prefix, c->log_ratelimit_burst);
if (c->n_log_extra_fields > 0) {
size_t j;
struct iovec* log_extra_fields;
size_t n_log_extra_fields;
- usec_t log_rate_limit_interval_usec;
- unsigned log_rate_limit_burst;
+ usec_t log_ratelimit_interval_usec;
+ unsigned log_ratelimit_burst;
int log_level_max;
$1.SyslogLevel, config_parse_log_level, 0, offsetof($1, exec_context.syslog_priority)
$1.SyslogLevelPrefix, config_parse_bool, 0, offsetof($1, exec_context.syslog_level_prefix)
$1.LogLevelMax, config_parse_log_level, 0, offsetof($1, exec_context.log_level_max)
-$1.LogRateLimitIntervalSec, config_parse_sec, 0, offsetof($1, exec_context.log_rate_limit_interval_usec)
-$1.LogRateLimitBurst, config_parse_unsigned, 0, offsetof($1, exec_context.log_rate_limit_burst)
+$1.LogRateLimitIntervalSec, config_parse_sec, 0, offsetof($1, exec_context.log_ratelimit_interval_usec)
+$1.LogRateLimitBurst, config_parse_unsigned, 0, offsetof($1, exec_context.log_ratelimit_burst)
$1.LogExtraFields, config_parse_log_extra_fields, 0, offsetof($1, exec_context)
$1.Capabilities, config_parse_warn_compat, DISABLED_LEGACY, offsetof($1, exec_context)
$1.SecureBits, config_parse_exec_secure_bits, 0, offsetof($1, exec_context.secure_bits)
(void) serialize_bool(f, "exported-invocation-id", u->exported_invocation_id);
(void) serialize_bool(f, "exported-log-level-max", u->exported_log_level_max);
(void) serialize_bool(f, "exported-log-extra-fields", u->exported_log_extra_fields);
- (void) serialize_bool(f, "exported-log-rate-limit-interval", u->exported_log_rate_limit_interval);
- (void) serialize_bool(f, "exported-log-rate-limit-burst", u->exported_log_rate_limit_burst);
+ (void) serialize_bool(f, "exported-log-rate-limit-interval", u->exported_log_ratelimit_interval);
+ (void) serialize_bool(f, "exported-log-rate-limit-burst", u->exported_log_ratelimit_burst);
(void) serialize_item_format(f, "cpu-usage-base", "%" PRIu64, u->cpu_usage_base);
if (u->cpu_usage_last != NSEC_INFINITY)
if (r < 0)
log_unit_debug(u, "Failed to parse exported log rate limit interval %s, ignoring.", v);
else
- u->exported_log_rate_limit_interval = r;
+ u->exported_log_ratelimit_interval = r;
continue;
if (r < 0)
log_unit_debug(u, "Failed to parse exported log rate limit burst %s, ignoring.", v);
else
- u->exported_log_rate_limit_burst = r;
+ u->exported_log_ratelimit_burst = r;
continue;
return r;
}
-static int unit_export_log_rate_limit_interval(Unit *u, const ExecContext *c) {
+static int unit_export_log_ratelimit_interval(Unit *u, const ExecContext *c) {
_cleanup_free_ char *buf = NULL;
const char *p;
int r;
assert(u);
assert(c);
- if (u->exported_log_rate_limit_interval)
+ if (u->exported_log_ratelimit_interval)
return 0;
- if (c->log_rate_limit_interval_usec == 0)
+ if (c->log_ratelimit_interval_usec == 0)
return 0;
p = strjoina("/run/systemd/units/log-rate-limit-interval:", u->id);
- if (asprintf(&buf, "%" PRIu64, c->log_rate_limit_interval_usec) < 0)
+ if (asprintf(&buf, "%" PRIu64, c->log_ratelimit_interval_usec) < 0)
return log_oom();
r = symlink_atomic(buf, p);
if (r < 0)
return log_unit_debug_errno(u, r, "Failed to create log rate limit interval symlink %s: %m", p);
- u->exported_log_rate_limit_interval = true;
+ u->exported_log_ratelimit_interval = true;
return 0;
}
-static int unit_export_log_rate_limit_burst(Unit *u, const ExecContext *c) {
+static int unit_export_log_ratelimit_burst(Unit *u, const ExecContext *c) {
_cleanup_free_ char *buf = NULL;
const char *p;
int r;
assert(u);
assert(c);
- if (u->exported_log_rate_limit_burst)
+ if (u->exported_log_ratelimit_burst)
return 0;
- if (c->log_rate_limit_burst == 0)
+ if (c->log_ratelimit_burst == 0)
return 0;
p = strjoina("/run/systemd/units/log-rate-limit-burst:", u->id);
- if (asprintf(&buf, "%u", c->log_rate_limit_burst) < 0)
+ if (asprintf(&buf, "%u", c->log_ratelimit_burst) < 0)
return log_oom();
r = symlink_atomic(buf, p);
if (r < 0)
return log_unit_debug_errno(u, r, "Failed to create log rate limit burst symlink %s: %m", p);
- u->exported_log_rate_limit_burst = true;
+ u->exported_log_ratelimit_burst = true;
return 0;
}
if (c) {
(void) unit_export_log_level_max(u, c);
(void) unit_export_log_extra_fields(u, c);
- (void) unit_export_log_rate_limit_interval(u, c);
- (void) unit_export_log_rate_limit_burst(u, c);
+ (void) unit_export_log_ratelimit_interval(u, c);
+ (void) unit_export_log_ratelimit_burst(u, c);
}
}
u->exported_log_extra_fields = false;
}
- if (u->exported_log_rate_limit_interval) {
+ if (u->exported_log_ratelimit_interval) {
p = strjoina("/run/systemd/units/log-rate-limit-interval:", u->id);
(void) unlink(p);
- u->exported_log_rate_limit_interval = false;
+ u->exported_log_ratelimit_interval = false;
}
- if (u->exported_log_rate_limit_burst) {
+ if (u->exported_log_ratelimit_burst) {
p = strjoina("/run/systemd/units/log-rate-limit-burst:", u->id);
(void) unlink(p);
- u->exported_log_rate_limit_burst = false;
+ u->exported_log_ratelimit_burst = false;
}
}
bool exported_invocation_id:1;
bool exported_log_level_max:1;
bool exported_log_extra_fields:1;
- bool exported_log_rate_limit_interval:1;
- bool exported_log_rate_limit_burst:1;
+ bool exported_log_ratelimit_interval:1;
+ bool exported_log_ratelimit_burst:1;
/* Whether we warned about clamping the CPU quota period */
bool warned_clamping_cpu_quota_period:1;
uint64_t written_uncompressed;
unsigned last_percent;
- RateLimit progress_rate_limit;
+ RateLimit progress_ratelimit;
struct stat st;
.on_finished = on_finished,
.userdata = userdata,
.last_percent = (unsigned) -1,
- .progress_rate_limit = { 100 * USEC_PER_MSEC, 1 },
+ .progress_ratelimit = { 100 * USEC_PER_MSEC, 1 },
};
if (event)
if (percent == e->last_percent)
return;
- if (!ratelimit_below(&e->progress_rate_limit))
+ if (!ratelimit_below(&e->progress_ratelimit))
return;
sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent);
uint64_t quota_referenced;
unsigned last_percent;
- RateLimit progress_rate_limit;
+ RateLimit progress_ratelimit;
bool eof;
bool tried_splice;
.userdata = userdata,
.quota_referenced = (uint64_t) -1,
.last_percent = (unsigned) -1,
- .progress_rate_limit = { 100 * USEC_PER_MSEC, 1 },
+ .progress_ratelimit = { 100 * USEC_PER_MSEC, 1 },
};
if (event)
if (percent == e->last_percent)
return;
- if (!ratelimit_below(&e->progress_rate_limit))
+ if (!ratelimit_below(&e->progress_ratelimit))
return;
sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent);
struct stat st;
unsigned last_percent;
- RateLimit progress_rate_limit;
+ RateLimit progress_ratelimit;
};
RawImport* raw_import_unref(RawImport *i) {
.userdata = userdata,
.last_percent = (unsigned) -1,
.image_root = TAKE_PTR(root),
- .progress_rate_limit = { 100 * USEC_PER_MSEC, 1 },
+ .progress_ratelimit = { 100 * USEC_PER_MSEC, 1 },
};
if (event)
if (percent == i->last_percent)
return;
- if (!ratelimit_below(&i->progress_rate_limit))
+ if (!ratelimit_below(&i->progress_ratelimit))
return;
sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent);
pid_t tar_pid;
unsigned last_percent;
- RateLimit progress_rate_limit;
+ RateLimit progress_ratelimit;
};
TarImport* tar_import_unref(TarImport *i) {
.userdata = userdata,
.last_percent = (unsigned) -1,
.image_root = TAKE_PTR(root),
- .progress_rate_limit = { 100 * USEC_PER_MSEC, 1 },
+ .progress_ratelimit = { 100 * USEC_PER_MSEC, 1 },
};
if (event)
if (percent == i->last_percent)
return;
- if (!ratelimit_below(&i->progress_rate_limit))
+ if (!ratelimit_below(&i->progress_ratelimit))
return;
sd_notifyf(false, "X_IMPORT_PROGRESS=%u", percent);
c->timestamp = USEC_INFINITY;
c->extra_fields_mtime = NSEC_INFINITY;
c->log_level_max = -1;
- c->log_rate_limit_interval = s->rate_limit_interval;
- c->log_rate_limit_burst = s->rate_limit_burst;
+ c->log_ratelimit_interval = s->ratelimit_interval;
+ c->log_ratelimit_burst = s->ratelimit_burst;
r = hashmap_put(s->client_contexts, PID_TO_PTR(pid), c);
if (r < 0) {
c->log_level_max = -1;
- c->log_rate_limit_interval = s->rate_limit_interval;
- c->log_rate_limit_burst = s->rate_limit_burst;
+ c->log_ratelimit_interval = s->ratelimit_interval;
+ c->log_ratelimit_burst = s->ratelimit_burst;
}
static ClientContext* client_context_free(Server *s, ClientContext *c) {
return 0;
}
-static int client_context_read_log_rate_limit_interval(ClientContext *c) {
+static int client_context_read_log_ratelimit_interval(ClientContext *c) {
_cleanup_free_ char *value = NULL;
const char *p;
int r;
if (r < 0)
return r;
- return safe_atou64(value, &c->log_rate_limit_interval);
+ return safe_atou64(value, &c->log_ratelimit_interval);
}
-static int client_context_read_log_rate_limit_burst(ClientContext *c) {
+static int client_context_read_log_ratelimit_burst(ClientContext *c) {
_cleanup_free_ char *value = NULL;
const char *p;
int r;
if (r < 0)
return r;
- return safe_atou(value, &c->log_rate_limit_burst);
+ return safe_atou(value, &c->log_ratelimit_burst);
}
static void client_context_really_refresh(
(void) client_context_read_invocation_id(s, c);
(void) client_context_read_log_level_max(s, c);
(void) client_context_read_extra_fields(s, c);
- (void) client_context_read_log_rate_limit_interval(c);
- (void) client_context_read_log_rate_limit_burst(c);
+ (void) client_context_read_log_ratelimit_interval(c);
+ (void) client_context_read_log_ratelimit_burst(c);
c->timestamp = timestamp;
void *extra_fields_data;
nsec_t extra_fields_mtime;
- usec_t log_rate_limit_interval;
- unsigned log_rate_limit_burst;
+ usec_t log_ratelimit_interval;
+ unsigned log_ratelimit_burst;
};
int client_context_get(
Journal.ReadKMsg, config_parse_bool, 0, offsetof(Server, read_kmsg)
Journal.SyncIntervalSec, config_parse_sec, 0, offsetof(Server, sync_interval_usec)
# The following is a legacy name for compatibility
-Journal.RateLimitInterval, config_parse_sec, 0, offsetof(Server, rate_limit_interval)
-Journal.RateLimitIntervalSec,config_parse_sec, 0, offsetof(Server, rate_limit_interval)
-Journal.RateLimitBurst, config_parse_unsigned, 0, offsetof(Server, rate_limit_burst)
+Journal.RateLimitInterval, config_parse_sec, 0, offsetof(Server, ratelimit_interval)
+Journal.RateLimitIntervalSec,config_parse_sec, 0, offsetof(Server, ratelimit_interval)
+Journal.RateLimitBurst, config_parse_unsigned, 0, offsetof(Server, ratelimit_burst)
Journal.SystemMaxUse, config_parse_iec_uint64, 0, offsetof(Server, system_storage.metrics.max_use)
Journal.SystemMaxFileSize, config_parse_iec_uint64, 0, offsetof(Server, system_storage.metrics.max_size)
Journal.SystemKeepFree, config_parse_iec_uint64, 0, offsetof(Server, system_storage.metrics.keep_free)
uint8_t hash_key[16];
};
-JournalRateLimit *journal_rate_limit_new(void) {
+JournalRateLimit *journal_ratelimit_new(void) {
JournalRateLimit *r;
r = new0(JournalRateLimit, 1);
return r;
}
-static void journal_rate_limit_group_free(JournalRateLimitGroup *g) {
+static void journal_ratelimit_group_free(JournalRateLimitGroup *g) {
assert(g);
if (g->parent) {
free(g);
}
-void journal_rate_limit_free(JournalRateLimit *r) {
+void journal_ratelimit_free(JournalRateLimit *r) {
assert(r);
while (r->lru)
- journal_rate_limit_group_free(r->lru);
+ journal_ratelimit_group_free(r->lru);
free(r);
}
-_pure_ static bool journal_rate_limit_group_expired(JournalRateLimitGroup *g, usec_t ts) {
+_pure_ static bool journal_ratelimit_group_expired(JournalRateLimitGroup *g, usec_t ts) {
unsigned i;
assert(g);
return true;
}
-static void journal_rate_limit_vacuum(JournalRateLimit *r, usec_t ts) {
+static void journal_ratelimit_vacuum(JournalRateLimit *r, usec_t ts) {
assert(r);
/* Makes room for at least one new item, but drop all
* expored items too. */
while (r->n_groups >= GROUPS_MAX ||
- (r->lru_tail && journal_rate_limit_group_expired(r->lru_tail, ts)))
- journal_rate_limit_group_free(r->lru_tail);
+ (r->lru_tail && journal_ratelimit_group_expired(r->lru_tail, ts)))
+ journal_ratelimit_group_free(r->lru_tail);
}
-static JournalRateLimitGroup* journal_rate_limit_group_new(JournalRateLimit *r, const char *id, usec_t interval, usec_t ts) {
+static JournalRateLimitGroup* journal_ratelimit_group_new(JournalRateLimit *r, const char *id, usec_t interval, usec_t ts) {
JournalRateLimitGroup *g;
assert(r);
g->interval = interval;
- journal_rate_limit_vacuum(r, ts);
+ journal_ratelimit_vacuum(r, ts);
LIST_PREPEND(bucket, r->buckets[g->hash % BUCKETS_MAX], g);
LIST_PREPEND(lru, r->lru, g);
return g;
fail:
- journal_rate_limit_group_free(g);
+ journal_ratelimit_group_free(g);
return NULL;
}
return burst;
}
-int journal_rate_limit_test(JournalRateLimit *r, const char *id, usec_t rl_interval, unsigned rl_burst, int priority, uint64_t available) {
+int journal_ratelimit_test(JournalRateLimit *r, const char *id, usec_t rl_interval, unsigned rl_burst, int priority, uint64_t available) {
uint64_t h;
JournalRateLimitGroup *g;
JournalRateLimitPool *p;
break;
if (!g) {
- g = journal_rate_limit_group_new(r, id, rl_interval, ts);
+ g = journal_ratelimit_group_new(r, id, rl_interval, ts);
if (!g)
return -ENOMEM;
} else
typedef struct JournalRateLimit JournalRateLimit;
-JournalRateLimit *journal_rate_limit_new(void);
-void journal_rate_limit_free(JournalRateLimit *r);
-int journal_rate_limit_test(JournalRateLimit *r, const char *id, usec_t rl_interval, unsigned rl_burst, int priority, uint64_t available);
+JournalRateLimit *journal_ratelimit_new(void);
+void journal_ratelimit_free(JournalRateLimit *r);
+int journal_ratelimit_test(JournalRateLimit *r, const char *id, usec_t rl_interval, unsigned rl_burst, int priority, uint64_t available);
if (c && c->unit) {
(void) determine_space(s, &available, NULL);
- rl = journal_rate_limit_test(s->rate_limit, c->unit, c->log_rate_limit_interval, c->log_rate_limit_burst, priority & LOG_PRIMASK, available);
+ rl = journal_ratelimit_test(s->ratelimit, c->unit, c->log_ratelimit_interval, c->log_ratelimit_burst, priority & LOG_PRIMASK, available);
if (rl == 0)
return;
.sync_interval_usec = DEFAULT_SYNC_INTERVAL_USEC,
.sync_scheduled = false,
- .rate_limit_interval = DEFAULT_RATE_LIMIT_INTERVAL,
- .rate_limit_burst = DEFAULT_RATE_LIMIT_BURST,
+ .ratelimit_interval = DEFAULT_RATE_LIMIT_INTERVAL,
+ .ratelimit_burst = DEFAULT_RATE_LIMIT_BURST,
.forward_to_wall = true,
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
- if (!!s->rate_limit_interval ^ !!s->rate_limit_burst) {
+ if (!!s->ratelimit_interval ^ !!s->ratelimit_burst) {
log_debug("Setting both rate limit interval and burst from "USEC_FMT",%u to 0,0",
- s->rate_limit_interval, s->rate_limit_burst);
- s->rate_limit_interval = s->rate_limit_burst = 0;
+ s->ratelimit_interval, s->ratelimit_burst);
+ s->ratelimit_interval = s->ratelimit_burst = 0;
}
(void) mkdir_p("/run/systemd/journal", 0755);
if (r < 0)
return r;
- s->rate_limit = journal_rate_limit_new();
- if (!s->rate_limit)
+ s->ratelimit = journal_ratelimit_new();
+ if (!s->ratelimit)
return -ENOMEM;
r = cg_get_root_path(&s->cgroup_root);
safe_close(s->hostname_fd);
safe_close(s->notify_fd);
- if (s->rate_limit)
- journal_rate_limit_free(s->rate_limit);
+ if (s->ratelimit)
+ journal_ratelimit_free(s->ratelimit);
if (s->kernel_seqnum)
munmap(s->kernel_seqnum, sizeof(uint64_t));
char *buffer;
size_t buffer_size;
- JournalRateLimit *rate_limit;
+ JournalRateLimit *ratelimit;
usec_t sync_interval_usec;
- usec_t rate_limit_interval;
- unsigned rate_limit_burst;
+ usec_t ratelimit_interval;
+ unsigned ratelimit_burst;
JournalStorage runtime_storage;
JournalStorage system_storage;