1/* 2 Copyright The containerd Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15*/ 16 17package v2 18 19import "fmt" 20 21type IOType string 22 23const ( 24 ReadBPS IOType = "rbps" 25 WriteBPS IOType = "wbps" 26 ReadIOPS IOType = "riops" 27 WriteIOPS IOType = "wiops" 28) 29 30type BFQ struct { 31 Weight uint16 32} 33 34type Entry struct { 35 Type IOType 36 Major int64 37 Minor int64 38 Rate uint64 39} 40 41func (e Entry) String() string { 42 return fmt.Sprintf("%d:%d %s=%d", e.Major, e.Minor, e.Type, e.Rate) 43} 44 45type IO struct { 46 BFQ BFQ 47 Max []Entry 48} 49 50func (i *IO) Values() (o []Value) { 51 if i.BFQ.Weight != 0 { 52 o = append(o, Value{ 53 filename: "io.bfq.weight", 54 value: i.BFQ.Weight, 55 }) 56 } 57 for _, e := range i.Max { 58 o = append(o, Value{ 59 filename: "io.max", 60 value: e.String(), 61 }) 62 } 63 return o 64} 65