libct: simplify setIOPriority/setupScheduler calls

Move the nil check inside, simplifying the callers.

Fixes: bfbd0305 ("Add I/O priority")
Fixes: 770728e1 ("Support `process.scheduler`")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2024-06-26 16:14:44 -07:00
parent 2e906e292e
commit 2dc3ea4b87
4 changed files with 15 additions and 16 deletions
+5 -4
View File
@@ -166,10 +166,8 @@ type setnsProcess struct {
func (p *setnsProcess) start() (retErr error) {
defer p.comm.closeParent()
if p.process.IOPriority != nil {
if err := setIOPriority(p.process.IOPriority); err != nil {
return err
}
if err := setIOPriority(p.process.IOPriority); err != nil {
return err
}
// get the "before" value of oom kill count
@@ -912,6 +910,9 @@ func (p *Process) InitializeIO(rootuid, rootgid int) (i *IO, err error) {
func setIOPriority(ioprio *configs.IOPriority) error {
const ioprioWhoPgrp = 1
if ioprio == nil {
return nil
}
class, ok := configs.IOPrioClassMapping[ioprio.Class]
if !ok {
return fmt.Errorf("invalid io priority class: %s", ioprio.Class)