summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-11-24 15:30:22 +0100
committerLennart Poettering <lennart@poettering.net>2021-11-24 16:12:15 +0100
commit0692548c73fd2736f855cec7b44b13a818b7a560 (patch)
tree258756ba45ddf13ae8d12e821bf00c5415ea8a72
parent032b3afbf4abe3cf760469d9d1cd2e4162829441 (diff)
downloadsystemd-0692548c73fd2736f855cec7b44b13a818b7a560.tar.gz
ioprio-util: add macro for default ioprio settings
IOPRIO_CLASS_NONE with any priority value actually is an alias for IOPRIO_CLASS_BE with priority value 4 – which is the default ioprio for all processes. We got this right at one place, but wrong at three others (where we assumed the default value was 0, not 4). Let's add a macro that encodes this properly, and use it everywhere.
-rw-r--r--src/basic/ioprio-util.h4
-rw-r--r--src/core/execute.c4
-rw-r--r--src/core/load-fragment.c4
3 files changed, 8 insertions, 4 deletions
diff --git a/src/basic/ioprio-util.h b/src/basic/ioprio-util.h
index ffb3e9c890..0d3f70a220 100644
--- a/src/basic/ioprio-util.h
+++ b/src/basic/ioprio-util.h
@@ -16,3 +16,7 @@ static inline bool ioprio_priority_is_valid(int i) {
}
int ioprio_parse_priority(const char *s, int *ret);
+
+/* IOPRIO_CLASS_NONE with any prio value is another way to say IOPRIO_CLASS_BE with level 4. Encode that in a
+ * proper macro. */
+#define IOPRIO_DEFAULT_CLASS_AND_PRIO ioprio_prio_value(IOPRIO_CLASS_BE, 4)
diff --git a/src/core/execute.c b/src/core/execute.c
index e578bace6f..c30e15f614 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -5069,7 +5069,7 @@ void exec_context_init(ExecContext *c) {
assert(c);
c->umask = 0022;
- c->ioprio = ioprio_prio_value(IOPRIO_CLASS_BE, 0);
+ c->ioprio = IOPRIO_DEFAULT_CLASS_AND_PRIO;
c->cpu_sched_policy = SCHED_OTHER;
c->syslog_priority = LOG_DAEMON|LOG_INFO;
c->syslog_level_prefix = true;
@@ -6021,7 +6021,7 @@ int exec_context_get_effective_ioprio(const ExecContext *c) {
p = ioprio_get(IOPRIO_WHO_PROCESS, 0);
if (p < 0)
- return ioprio_prio_value(IOPRIO_CLASS_BE, 4);
+ return IOPRIO_DEFAULT_CLASS_AND_PRIO;
return p;
}
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 0e93ddfbc0..71434a4bee 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -1417,7 +1417,7 @@ int config_parse_exec_io_class(const char *unit,
if (isempty(rvalue)) {
c->ioprio_set = false;
- c->ioprio = ioprio_prio_value(IOPRIO_CLASS_BE, 0);
+ c->ioprio = IOPRIO_DEFAULT_CLASS_AND_PRIO;
return 0;
}
@@ -1454,7 +1454,7 @@ int config_parse_exec_io_priority(const char *unit,
if (isempty(rvalue)) {
c->ioprio_set = false;
- c->ioprio = ioprio_prio_value(IOPRIO_CLASS_BE, 0);
+ c->ioprio = IOPRIO_DEFAULT_CLASS_AND_PRIO;
return 0;
}