chiark / gitweb /
core: introduce CGroupIOLimitType enums
authorTejun Heo <htejun@fb.com>
Wed, 18 May 2016 20:50:56 +0000 (13:50 -0700)
committerSven Eden <yamakuzure@gmx.net>
Fri, 16 Jun 2017 08:12:58 +0000 (10:12 +0200)
Currently, there are two cgroup IO limits, bandwidth max for read and write,
and they are hard-coded in various places.  This is fine for two limits but IO
is expected to grow more limits - low, high and max limits for bandwidth and
IOPS - and hard-coding each limit won't make sense.

This patch replaces hard-coded limits with an array indexed by
CGroupIOLimitType and accompanying string and default value tables so that new
limits can be added trivially.

src/shared/bus-unit-util.c

index ff5dceaed846b130e7e42d8de80aa632b536fa24..68ec4b4e62816d3ddf168b16ddd859b2998d62b5 100644 (file)
@@ -284,8 +284,7 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
                         r = sd_bus_message_append(m, "v", "a(ss)", 1, path, rwm);
                 }
 
-        } else if (STR_IN_SET(field, "IOReadBandwidthMax", "IOWriteBandwidthMax",
-                              "BlockIOReadBandwidth", "BlockIOWriteBandwidth")) {
+        } else if (cgroup_io_limit_type_from_string(field) >= 0 || STR_IN_SET(field, "BlockIOReadBandwidth", "BlockIOWriteBandwidth")) {
 
                 if (isempty(eq))
                         r = sd_bus_message_append(m, "v", "a(st)", 0);