-
Notifications
You must be signed in to change notification settings - Fork 950
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: update blkio device's read/write Bps/IOps
Support update limit of block device, including read/write bps/iops. Signed-off-by: Wang Rui <baijia.wr@antfin.com> Signed-off-by: Leno Hou <lenohou@gmail.com>
- Loading branch information
Showing
6 changed files
with
151 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package utils | ||
|
||
import ( | ||
"syscall" | ||
|
||
"github.com/alibaba/pouch/apis/types" | ||
|
||
specs "github.com/opencontainers/runtime-spec/specs-go" | ||
) | ||
|
||
//Convert weight device from []*types.WeightDevice to []specs.LinuxWeightDevice | ||
func GetWeightDevice(devs []*types.WeightDevice) ([]specs.LinuxWeightDevice, error) { | ||
var stat syscall.Stat_t | ||
var weightDevice []specs.LinuxWeightDevice | ||
|
||
for _, dev := range devs { | ||
if err := syscall.Stat(dev.Path, &stat); err != nil { | ||
return nil, err | ||
} | ||
|
||
d := specs.LinuxWeightDevice{ | ||
Weight: &dev.Weight, | ||
} | ||
d.Major = int64(stat.Rdev >> 8) | ||
d.Minor = int64(stat.Rdev & 255) | ||
weightDevice = append(weightDevice, d) | ||
} | ||
|
||
return weightDevice, nil | ||
} | ||
|
||
// Convert throttle device from []*types.ThrottleDevice to []specs.LinuxThrottleDevice | ||
func GetThrottleDevice(devs []*types.ThrottleDevice) ([]specs.LinuxThrottleDevice, error) { | ||
var stat syscall.Stat_t | ||
var ThrottleDevice []specs.LinuxThrottleDevice | ||
|
||
for _, dev := range devs { | ||
if err := syscall.Stat(dev.Path, &stat); err != nil { | ||
return nil, err | ||
} | ||
|
||
d := specs.LinuxThrottleDevice{ | ||
Rate: dev.Rate, | ||
} | ||
d.Major = int64(stat.Rdev >> 8) | ||
d.Minor = int64(stat.Rdev & 255) | ||
ThrottleDevice = append(ThrottleDevice, d) | ||
} | ||
|
||
return ThrottleDevice, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters