From 033936ef767b74e868bbeebb2681d0247e7ce74a Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Fri, 18 Oct 2019 21:33:48 +0900 Subject: [PATCH] io_v2.go: remove blkio v1 code Signed-off-by: Akihiro Suda --- libcontainer/cgroups/fs/io_v2.go | 61 ++++++-------------------------- 1 file changed, 10 insertions(+), 51 deletions(-) diff --git a/libcontainer/cgroups/fs/io_v2.go b/libcontainer/cgroups/fs/io_v2.go index 84b18294..35cda087 100644 --- a/libcontainer/cgroups/fs/io_v2.go +++ b/libcontainer/cgroups/fs/io_v2.go @@ -17,6 +17,7 @@ type IOGroupV2 struct { } func (s *IOGroupV2) Name() string { + // for compatibility with v1 blkio controller return "blkio" } @@ -29,73 +30,31 @@ func (s *IOGroupV2) Apply(d *cgroupData) error { } func (s *IOGroupV2) Set(path string, cgroup *configs.Cgroup) error { - cgroupsv2 := cgroups.IsCgroup2UnifiedMode() - if cgroup.Resources.BlkioWeight != 0 { - filename := "blkio.weight" - if cgroupsv2 { - filename = "io.bfq.weight" - } + filename := "io.bfq.weight" if err := writeFile(path, filename, strconv.FormatUint(uint64(cgroup.Resources.BlkioWeight), 10)); err != nil { return err } } - if cgroup.Resources.BlkioLeafWeight != 0 { - if err := writeFile(path, "blkio.leaf_weight", strconv.FormatUint(uint64(cgroup.Resources.BlkioLeafWeight), 10)); err != nil { - return err - } - } - for _, wd := range cgroup.Resources.BlkioWeightDevice { - if err := writeFile(path, "blkio.weight_device", wd.WeightString()); err != nil { - return err - } - if err := writeFile(path, "blkio.leaf_weight_device", wd.LeafWeightString()); err != nil { - return err - } - } for _, td := range cgroup.Resources.BlkioThrottleReadBpsDevice { - if cgroupsv2 { - if err := writeFile(path, "io.max", td.StringName("rbps")); err != nil { - return err - } - } else { - if err := writeFile(path, "blkio.throttle.read_bps_device", td.String()); err != nil { - return err - } + if err := writeFile(path, "io.max", td.StringName("rbps")); err != nil { + return err } } for _, td := range cgroup.Resources.BlkioThrottleWriteBpsDevice { - if cgroupsv2 { - if err := writeFile(path, "io.max", td.StringName("wbps")); err != nil { - return err - } - } else { - if err := writeFile(path, "blkio.throttle.write_bps_device", td.String()); err != nil { - return err - } + if err := writeFile(path, "io.max", td.StringName("wbps")); err != nil { + return err } } for _, td := range cgroup.Resources.BlkioThrottleReadIOPSDevice { - if cgroupsv2 { - if err := writeFile(path, "io.max", td.StringName("riops")); err != nil { - return err - } - } else { - if err := writeFile(path, "blkio.throttle.read_iops_device", td.String()); err != nil { - return err - } + if err := writeFile(path, "io.max", td.StringName("riops")); err != nil { + return err } } for _, td := range cgroup.Resources.BlkioThrottleWriteIOPSDevice { - if cgroupsv2 { - if err := writeFile(path, "io.max", td.StringName("wiops")); err != nil { - return err - } - } else { - if err := writeFile(path, "blkio.throttle.write_iops_device", td.String()); err != nil { - return err - } + if err := writeFile(path, "io.max", td.StringName("wiops")); err != nil { + return err } }