Skip to content

Commit

Permalink
libct/configs: rm IOPrioClassMapping
Browse files Browse the repository at this point in the history
This is an internal implementation detail and should not be either
public or visible.

Amend setIOPriority to do own class conversion.

Fixes: bfbd030 ("Add I/O priority")
Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed Nov 2, 2024
1 parent f2c39e9 commit 610e39d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 0 additions & 6 deletions libcontainer/configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,6 @@ func ToSchedAttr(scheduler *Scheduler) (*unix.SchedAttr, error) {
}, nil
}

var IOPrioClassMapping = map[specs.IOPriorityClass]int{
specs.IOPRIO_CLASS_RT: 1,
specs.IOPRIO_CLASS_BE: 2,
specs.IOPRIO_CLASS_IDLE: 3,
}

type IOPriority = specs.LinuxIOPriority

type (
Expand Down
11 changes: 9 additions & 2 deletions libcontainer/init_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,15 @@ func setIOPriority(ioprio *configs.IOPriority) error {
if ioprio == nil {
return nil
}
class, ok := configs.IOPrioClassMapping[ioprio.Class]
if !ok {
class := 0
switch ioprio.Class {
case specs.IOPRIO_CLASS_RT:
class = 1
case specs.IOPRIO_CLASS_BE:
class = 2
case specs.IOPRIO_CLASS_IDLE:
class = 3
default:
return fmt.Errorf("invalid io priority class: %s", ioprio.Class)
}

Expand Down

0 comments on commit 610e39d

Please sign in to comment.