[systemd-commits] 4 commits - TODO src/core
Lennart Poettering
lennart at kemper.freedesktop.org
Thu Jul 11 12:30:25 PDT 2013
TODO | 4 -
src/core/cgroup.c | 2
src/core/dbus-cgroup.c | 32 ++++--------
src/core/dbus-service.c | 2
src/core/dbus-unit.c | 36 +++++---------
src/core/load-fragment-gperf.gperf.m4 | 1
src/core/load-fragment.c | 87 ++++++++++++++++++++++------------
src/core/load-fragment.h | 1
src/core/unit.c | 58 +++++++++++++++++++++-
src/core/unit.h | 6 +-
10 files changed, 146 insertions(+), 83 deletions(-)
New commits:
commit 1e1ddecf405fdeb5a073c0696fafb50946af60d2
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jul 11 21:30:19 2013 +0200
update TODO
diff --git a/TODO b/TODO
index a6eed6f..b8d0151 100644
--- a/TODO
+++ b/TODO
@@ -46,12 +46,8 @@ CGroup Rework Completion:
* logind: implement session kill exceptions
-* fix machine regstration to forward property array
-
* make BlockIODeviceWeight=, BlockIODeviceBandwidth= runtime settable
-* split up BlockIOWeight= and BlockIODeviceWeight=
-
* introduce high-level settings for RT budget, swappiness
* man: document new bus apis
commit b9ec9359369f224bfb13db616f97401a6a177bd8
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jul 11 21:29:33 2013 +0200
core: simplify drop-in writing logic a bit
let's make use of some format string magic!
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index 27b54f9..8ad3d11 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -162,7 +162,7 @@ int bus_cgroup_set_property(
dbus_message_iter_get_basic(i, &b);
c->cpu_accounting = b;
- unit_write_drop_in_private_section(u, mode, name, b ? "CPUAccounting=yes" : "CPUAccounting=no");
+ unit_write_drop_in_private(u, mode, name, b ? "CPUAccounting=yes" : "CPUAccounting=no");
}
return 1;
@@ -181,11 +181,8 @@ int bus_cgroup_set_property(
return -EINVAL;
if (mode != UNIT_CHECK) {
- char buf[sizeof("CPUShares=") + DECIMAL_STR_MAX(ul)];
c->cpu_shares = ul;
-
- sprintf(buf, "CPUShares=%lu", ul);
- unit_write_drop_in_private_section(u, mode, name, buf);
+ unit_write_drop_in_private_format(u, mode, name, "CPUShares=%lu", ul);
}
return 1;
@@ -200,7 +197,7 @@ int bus_cgroup_set_property(
dbus_message_iter_get_basic(i, &b);
c->blockio_accounting = b;
- unit_write_drop_in_private_section(u, mode, name, b ? "BlockIOAccounting=yes" : "BlockIOAccounting=no");
+ unit_write_drop_in_private(u, mode, name, b ? "BlockIOAccounting=yes" : "BlockIOAccounting=no");
}
return 1;
@@ -219,11 +216,8 @@ int bus_cgroup_set_property(
return -EINVAL;
if (mode != UNIT_CHECK) {
- char buf[sizeof("BlockIOWeight=") + DECIMAL_STR_MAX(ul)];
c->cpu_shares = ul;
-
- sprintf(buf, "BlockIOWeight=%lu", ul);
- unit_write_drop_in_private_section(u, mode, name, buf);
+ unit_write_drop_in_private_format(u, mode, name, "BlockIOWeight=%lu", ul);
}
return 1;
@@ -238,7 +232,7 @@ int bus_cgroup_set_property(
dbus_message_iter_get_basic(i, &b);
c->memory_accounting = b;
- unit_write_drop_in_private_section(u, mode, name, b ? "MemoryAccounting=yes" : "MemoryAccounting=no");
+ unit_write_drop_in_private(u, mode, name, b ? "MemoryAccounting=yes" : "MemoryAccounting=no");
}
return 1;
@@ -250,19 +244,15 @@ int bus_cgroup_set_property(
if (mode != UNIT_CHECK) {
uint64_t limit;
- char buf[sizeof("MemorySoftLimit=") + DECIMAL_STR_MAX(limit)];
dbus_message_iter_get_basic(i, &limit);
- if (streq(name, "MemoryLimit")) {
+ if (streq(name, "MemoryLimit"))
c->memory_limit = limit;
- sprintf(buf, "MemoryLimit=%" PRIu64, limit);
- unit_write_drop_in_private_section(u, mode, name, buf);
- } else {
+ else
c->memory_soft_limit = limit;
- sprintf(buf, "MemorySoftLimit=%" PRIu64, limit);
- unit_write_drop_in_private_section(u, mode, name, buf);
- }
+
+ unit_write_drop_in_private_format(u, mode, name, "%s=%" PRIu64, name, limit);
}
return 1;
@@ -285,7 +275,7 @@ int bus_cgroup_set_property(
c->device_policy = p;
buf = strappenda("DevicePolicy=", policy);
- unit_write_drop_in_private_section(u, mode, name, buf);
+ unit_write_drop_in_private(u, mode, name, buf);
}
return 1;
@@ -365,7 +355,7 @@ int bus_cgroup_set_property(
fprintf(f, "DeviceAllow=%s %s%s%s\n", a->path, a->r ? "r" : "", a->w ? "w" : "", a->m ? "m" : "");
fflush(f);
- unit_write_drop_in_private_section(u, mode, name, buf);
+ unit_write_drop_in_private(u, mode, name, buf);
}
return 1;
diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c
index d63ca01..8b157b5 100644
--- a/src/core/dbus-service.c
+++ b/src/core/dbus-service.c
@@ -276,7 +276,7 @@ static int bus_service_set_transient_property(
}
fflush(f);
- unit_write_drop_in_private_section(UNIT(s), mode, name, buf);
+ unit_write_drop_in_private(UNIT(s), mode, name, buf);
}
return 1;
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index 5814971..ba4d426 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -794,7 +794,6 @@ static int bus_unit_set_transient_property(
return -EINVAL;
if (mode != UNIT_CHECK) {
- _cleanup_free_ char *contents = NULL;
const char *description;
dbus_message_iter_get_basic(i, &description);
@@ -803,18 +802,13 @@ static int bus_unit_set_transient_property(
if (r < 0)
return r;
- contents = strjoin("[Unit]\nDescription=", description, "\n", NULL);
- if (!contents)
- return -ENOMEM;
-
- unit_write_drop_in(u, mode, name, contents);
+ unit_write_drop_in_format(u, mode, name, "[Unit]\nDescription=%s\n", description);
}
return 1;
} else if (streq(name, "Slice") && unit_get_cgroup_context(u)) {
const char *s;
- Unit *slice;
if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_STRING)
return -EINVAL;
@@ -822,10 +816,12 @@ static int bus_unit_set_transient_property(
dbus_message_iter_get_basic(i, &s);
if (isempty(s)) {
- if (mode != UNIT_CHECK)
+ if (mode != UNIT_CHECK) {
unit_ref_unset(&u->slice);
+ unit_remove_drop_in(u, mode, name);
+ }
} else {
- _cleanup_free_ char *contents = NULL;
+ Unit *slice;
r = manager_load_unit(u->manager, s, NULL, error, &slice);
if (r < 0)
@@ -834,15 +830,12 @@ static int bus_unit_set_transient_property(
if (slice->type != UNIT_SLICE)
return -EINVAL;
- if (mode != UNIT_CHECK)
+ if (mode != UNIT_CHECK) {
unit_ref_set(&u->slice, slice);
-
- contents = strjoin("[", UNIT_VTABLE(u)->private_section, "]\nSlice=", s, NULL);
- if (!contents)
- return -ENOMEM;
-
- unit_write_drop_in(u, mode, name, contents);
+ unit_write_drop_in_private_format(u, mode, name, "Slice=%s\n", s);
+ }
}
+
return 1;
} else if (streq(name, "Requires") ||
@@ -880,7 +873,7 @@ static int bus_unit_set_transient_property(
return -EINVAL;
if (mode != UNIT_CHECK) {
- _cleanup_free_ char *label = NULL, *contents = NULL;
+ _cleanup_free_ char *label = NULL;
r = unit_add_dependency_by_name(u, d, other, NULL, true);
if (r < 0)
@@ -890,11 +883,7 @@ static int bus_unit_set_transient_property(
if (!label)
return -ENOMEM;
- contents = strjoin("[Unit]\n", name, "=", other, "\n", NULL);
- if (!contents)
- return -ENOMEM;
-
- unit_write_drop_in(u, mode, label, contents);
+ unit_write_drop_in_format(u, mode, label, "[Unit]\n%s=%s\n", name, other);
}
dbus_message_iter_next(&sub);
@@ -1048,10 +1037,11 @@ const BusProperty bus_unit_properties[] = {
{ "ConditionResult", bus_property_append_bool, "b", offsetof(Unit, condition_result) },
{ "LoadError", bus_unit_append_load_error, "(ss)", 0 },
{ "Transient", bus_property_append_bool, "b", offsetof(Unit, transient) },
- { NULL, }
+ {}
};
const BusProperty bus_unit_cgroup_properties[] = {
{ "Slice", bus_unit_append_slice, "s", 0 },
{ "ControlGroup", bus_property_append_string, "s", offsetof(Unit, cgroup_path), true },
+ {}
};
diff --git a/src/core/unit.c b/src/core/unit.c
index 8645285..dd08011 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -2733,6 +2733,7 @@ CGroupContext *unit_get_cgroup_context(Unit *u) {
}
static int drop_in_file(Unit *u, UnitSetPropertiesMode mode, const char *name, char **_p, char **_q) {
+ _cleanup_free_ char *b = NULL;
char *p, *q;
int r;
@@ -2742,7 +2743,11 @@ static int drop_in_file(Unit *u, UnitSetPropertiesMode mode, const char *name, c
assert(_q);
assert(mode & (UNIT_PERSISTENT|UNIT_RUNTIME));
- if (!filename_is_safe(name))
+ b = xescape(name, "/.");
+ if (!b)
+ return -ENOMEM;
+
+ if (!filename_is_safe(b))
return -EINVAL;
if (u->manager->running_as == SYSTEMD_USER) {
@@ -2762,7 +2767,7 @@ static int drop_in_file(Unit *u, UnitSetPropertiesMode mode, const char *name, c
if (!p)
return -ENOMEM;
- q = strjoin(p, "/90-", name, ".conf", NULL);
+ q = strjoin(p, "/90-", b, ".conf", NULL);
if (!q) {
free(p);
return -ENOMEM;
@@ -2792,7 +2797,29 @@ int unit_write_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name, co
return write_string_file_atomic_label(q, data);
}
-int unit_write_drop_in_private_section(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *data) {
+int unit_write_drop_in_format(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *format, ...) {
+ _cleanup_free_ char *p = NULL;
+ va_list ap;
+ int r;
+
+ assert(u);
+ assert(name);
+ assert(format);
+
+ if (!(mode & (UNIT_PERSISTENT|UNIT_RUNTIME)))
+ return 0;
+
+ va_start(ap, format);
+ r = vasprintf(&p, format, ap);
+ va_end(ap);
+
+ if (r < 0)
+ return -ENOMEM;
+
+ return unit_write_drop_in(u, mode, name, p);
+}
+
+int unit_write_drop_in_private(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *data) {
_cleanup_free_ char *ndata = NULL;
assert(u);
@@ -2802,6 +2829,9 @@ int unit_write_drop_in_private_section(Unit *u, UnitSetPropertiesMode mode, cons
if (!UNIT_VTABLE(u)->private_section)
return -EINVAL;
+ if (!(mode & (UNIT_PERSISTENT|UNIT_RUNTIME)))
+ return 0;
+
ndata = strjoin("[", UNIT_VTABLE(u)->private_section, "]\n", data, NULL);
if (!ndata)
return -ENOMEM;
@@ -2809,6 +2839,28 @@ int unit_write_drop_in_private_section(Unit *u, UnitSetPropertiesMode mode, cons
return unit_write_drop_in(u, mode, name, ndata);
}
+int unit_write_drop_in_private_format(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *format, ...) {
+ _cleanup_free_ char *p = NULL;
+ va_list ap;
+ int r;
+
+ assert(u);
+ assert(name);
+ assert(format);
+
+ if (!(mode & (UNIT_PERSISTENT|UNIT_RUNTIME)))
+ return 0;
+
+ va_start(ap, format);
+ r = vasprintf(&p, format, ap);
+ va_end(ap);
+
+ if (r < 0)
+ return -ENOMEM;
+
+ return unit_write_drop_in_private(u, mode, name, p);
+}
+
int unit_remove_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name) {
_cleanup_free_ char *p = NULL, *q = NULL;
int r;
diff --git a/src/core/unit.h b/src/core/unit.h
index ed4df18..0caea18 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -598,7 +598,11 @@ ExecContext *unit_get_exec_context(Unit *u) _pure_;
CGroupContext *unit_get_cgroup_context(Unit *u) _pure_;
int unit_write_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *data);
-int unit_write_drop_in_private_section(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *data);
+int unit_write_drop_in_format(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *format, ...) _printf_attr_(4,5);
+
+int unit_write_drop_in_private(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *data);
+int unit_write_drop_in_private_format(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *format, ...) _printf_attr_(4,5);
+
int unit_remove_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name);
int unit_kill_context(Unit *u, KillContext *c, bool sigkill, pid_t main_pid, pid_t control_pid, bool main_pid_alien);
commit 665f8316f435772ed539be5e164a85cd188f84b4
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jul 11 21:03:06 2013 +0200
core: when writing drop-in files, name them directly after the property we set
Mapping from "FooBar" to "foo-bar" is unnecessary and makes it hard to
handle many different properties with the same code, hence, let's just
not do it.
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index d1d3563..27b54f9 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -162,7 +162,7 @@ int bus_cgroup_set_property(
dbus_message_iter_get_basic(i, &b);
c->cpu_accounting = b;
- unit_write_drop_in_private_section(u, mode, "cpu-accounting", b ? "CPUAccounting=yes" : "CPUAccounting=no");
+ unit_write_drop_in_private_section(u, mode, name, b ? "CPUAccounting=yes" : "CPUAccounting=no");
}
return 1;
@@ -185,7 +185,7 @@ int bus_cgroup_set_property(
c->cpu_shares = ul;
sprintf(buf, "CPUShares=%lu", ul);
- unit_write_drop_in_private_section(u, mode, "cpu-shares", buf);
+ unit_write_drop_in_private_section(u, mode, name, buf);
}
return 1;
@@ -200,7 +200,7 @@ int bus_cgroup_set_property(
dbus_message_iter_get_basic(i, &b);
c->blockio_accounting = b;
- unit_write_drop_in_private_section(u, mode, "block-io-accounting", b ? "BlockIOAccounting=yes" : "BlockIOAccounting=no");
+ unit_write_drop_in_private_section(u, mode, name, b ? "BlockIOAccounting=yes" : "BlockIOAccounting=no");
}
return 1;
@@ -223,7 +223,7 @@ int bus_cgroup_set_property(
c->cpu_shares = ul;
sprintf(buf, "BlockIOWeight=%lu", ul);
- unit_write_drop_in_private_section(u, mode, "blockio-weight", buf);
+ unit_write_drop_in_private_section(u, mode, name, buf);
}
return 1;
@@ -238,7 +238,7 @@ int bus_cgroup_set_property(
dbus_message_iter_get_basic(i, &b);
c->memory_accounting = b;
- unit_write_drop_in_private_section(u, mode, "memory-accounting", b ? "MemoryAccounting=yes" : "MemoryAccounting=no");
+ unit_write_drop_in_private_section(u, mode, name, b ? "MemoryAccounting=yes" : "MemoryAccounting=no");
}
return 1;
@@ -257,11 +257,11 @@ int bus_cgroup_set_property(
if (streq(name, "MemoryLimit")) {
c->memory_limit = limit;
sprintf(buf, "MemoryLimit=%" PRIu64, limit);
- unit_write_drop_in_private_section(u, mode, "memory-limit", buf);
+ unit_write_drop_in_private_section(u, mode, name, buf);
} else {
c->memory_soft_limit = limit;
sprintf(buf, "MemorySoftLimit=%" PRIu64, limit);
- unit_write_drop_in_private_section(u, mode, "memory-soft-limit", buf);
+ unit_write_drop_in_private_section(u, mode, name, buf);
}
}
@@ -285,7 +285,7 @@ int bus_cgroup_set_property(
c->device_policy = p;
buf = strappenda("DevicePolicy=", policy);
- unit_write_drop_in_private_section(u, mode, "device-policy", buf);
+ unit_write_drop_in_private_section(u, mode, name, buf);
}
return 1;
@@ -365,7 +365,7 @@ int bus_cgroup_set_property(
fprintf(f, "DeviceAllow=%s %s%s%s\n", a->path, a->r ? "r" : "", a->w ? "w" : "", a->m ? "m" : "");
fflush(f);
- unit_write_drop_in_private_section(u, mode, "device-allow", buf);
+ unit_write_drop_in_private_section(u, mode, name, buf);
}
return 1;
diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c
index c2e0220..d63ca01 100644
--- a/src/core/dbus-service.c
+++ b/src/core/dbus-service.c
@@ -276,7 +276,7 @@ static int bus_service_set_transient_property(
}
fflush(f);
- unit_write_drop_in_private_section(UNIT(s), mode, "exec-start", buf);
+ unit_write_drop_in_private_section(UNIT(s), mode, name, buf);
}
return 1;
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index 57fac00..5814971 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -807,7 +807,7 @@ static int bus_unit_set_transient_property(
if (!contents)
return -ENOMEM;
- unit_write_drop_in(u, mode, "Description", contents);
+ unit_write_drop_in(u, mode, name, contents);
}
return 1;
@@ -841,7 +841,7 @@ static int bus_unit_set_transient_property(
if (!contents)
return -ENOMEM;
- unit_write_drop_in(u, mode, "Slice", contents);
+ unit_write_drop_in(u, mode, name, contents);
}
return 1;
commit 8e7076caae32a560a11c1643b53fc4f12db4a6b1
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jul 11 20:40:18 2013 +0200
cgroup: split out per-device BlockIOWeight= setting into BlockIODeviceWeight=
This way we can nicely map the configuration directive to properties and
back, without requiring two different signatures for the same property.
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index d0f36cb..5a1c3ad 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -114,7 +114,7 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
LIST_FOREACH(device_weights, w, c->blockio_device_weights)
fprintf(f,
- "%sBlockIOWeight=%s %lu",
+ "%sBlockIODeviceWeight=%s %lu",
prefix,
w->path,
w->weight);
diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
index 76fc9c4..0c337bc 100644
--- a/src/core/load-fragment-gperf.gperf.m4
+++ b/src/core/load-fragment-gperf.gperf.m4
@@ -93,6 +93,7 @@ $1.DeviceAllow, config_parse_device_allow, 0,
$1.DevicePolicy, config_parse_device_policy, 0, offsetof($1, cgroup_context.device_policy)
$1.BlockIOAccounting, config_parse_bool, 0, offsetof($1, cgroup_context.blockio_accounting)
$1.BlockIOWeight, config_parse_blockio_weight, 0, offsetof($1, cgroup_context)
+$1.BlockIODeviceWeight, config_parse_blockio_device_weight, 0, offsetof($1, cgroup_context)
$1.BlockIOReadBandwidth, config_parse_blockio_bandwidth, 0, offsetof($1, cgroup_context)
$1.BlockIOWriteBandwidth, config_parse_blockio_bandwidth, 0, offsetof($1, cgroup_context)'
)m4_dnl
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 2b10d72..cf92f0d 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -2094,7 +2094,44 @@ int config_parse_blockio_weight(
void *data,
void *userdata) {
+ CGroupContext *c = data;
+ unsigned long lu;
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+
+ if (isempty(rvalue)) {
+ c->blockio_weight = 1000;
+ return 0;
+ }
+
+ r = safe_atolu(rvalue, &lu);
+ if (r < 0 || lu < 10 || lu > 1000) {
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Block IO weight '%s' invalid. Ignoring.", rvalue);
+ return 0;
+ }
+
+ c->blockio_weight = lu;
+
+ return 0;
+}
+
+int config_parse_blockio_device_weight(
+ const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
_cleanup_free_ char *path = NULL;
+ CGroupBlockIODeviceWeight *w;
CGroupContext *c = data;
unsigned long lu;
const char *weight;
@@ -2106,8 +2143,6 @@ int config_parse_blockio_weight(
assert(rvalue);
if (isempty(rvalue)) {
- c->blockio_weight = 1000;
-
while (c->blockio_device_weights)
cgroup_context_free_blockio_device_weight(c, c->blockio_device_weights);
@@ -2116,23 +2151,23 @@ int config_parse_blockio_weight(
n = strcspn(rvalue, WHITESPACE);
weight = rvalue + n;
- if (*weight) {
- /* Two params, first device name, then weight */
- path = strndup(rvalue, n);
- if (!path)
- return log_oom();
+ if (!*weight) {
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Expected block device and device weight. Ignoring.");
+ return 0;
+ }
- if (!path_startswith(path, "/dev")) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL,
- "Invalid device node path '%s'. Ignoring.", path);
- return 0;
- }
+ path = strndup(rvalue, n);
+ if (!path)
+ return log_oom();
- weight += strspn(weight, WHITESPACE);
- } else
- /* One param, only weight */
- weight = rvalue;
+ if (!path_startswith(path, "/dev")) {
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Invalid device node path '%s'. Ignoring.", path);
+ return 0;
+ }
+ weight += strspn(weight, WHITESPACE);
r = safe_atolu(weight, &lu);
if (r < 0 || lu < 10 || lu > 1000) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
@@ -2140,23 +2175,17 @@ int config_parse_blockio_weight(
return 0;
}
- if (!path)
- c->blockio_weight = lu;
- else {
- CGroupBlockIODeviceWeight *w;
-
- w = new0(CGroupBlockIODeviceWeight, 1);
- if (!w)
- return log_oom();
- w->path = path;
- path = NULL;
+ w = new0(CGroupBlockIODeviceWeight, 1);
+ if (!w)
+ return log_oom();
- w->weight = lu;
+ w->path = path;
+ path = NULL;
- LIST_PREPEND(CGroupBlockIODeviceWeight, device_weights, c->blockio_device_weights, w);
- }
+ w->weight = lu;
+ LIST_PREPEND(CGroupBlockIODeviceWeight, device_weights, c->blockio_device_weights, w);
return 0;
}
diff --git a/src/core/load-fragment.h b/src/core/load-fragment.h
index 5e36f35..90e5e3a 100644
--- a/src/core/load-fragment.h
+++ b/src/core/load-fragment.h
@@ -81,6 +81,7 @@ int config_parse_memory_limit(const char *unit, const char *filename, unsigned l
int config_parse_device_policy(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_device_allow(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_blockio_weight(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+int config_parse_blockio_device_weight(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_blockio_bandwidth(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
/* gperf prototypes */
More information about the systemd-commits
mailing list