X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/863570108a2c901a8eff22dc8a9bc72635ba7b95..6f461f4d0a996da85140982846a5d5c10ccfaae4:/services/keepstore/volume.go diff --git a/services/keepstore/volume.go b/services/keepstore/volume.go index 19a59960e1..b72258d51a 100644 --- a/services/keepstore/volume.go +++ b/services/keepstore/volume.go @@ -55,7 +55,7 @@ type Volume interface { // CollisionError or DiskHashError (depending on whether the // data on disk matches the expected hash), or whatever error // was encountered opening/reading the stored data. - Compare(loc string, data []byte) error + Compare(ctx context.Context, loc string, data []byte) error // Put writes a block to an underlying storage device. // @@ -85,7 +85,7 @@ type Volume interface { // // Put should not verify that loc==hash(block): this is the // caller's responsibility. - Put(loc string, block []byte) error + Put(ctx context.Context, loc string, block []byte) error // Touch sets the timestamp for the given locator to the // current time. @@ -243,6 +243,10 @@ type VolumeManager interface { // with more free space, etc. NextWritable() Volume + // VolumeStats returns the ioStats used for tracking stats for + // the given Volume. + VolumeStats(Volume) *ioStats + // Close shuts down the volume manager cleanly. Close() } @@ -254,12 +258,16 @@ type RRVolumeManager struct { readables []Volume writables []Volume counter uint32 + iostats map[Volume]*ioStats } // MakeRRVolumeManager initializes RRVolumeManager func MakeRRVolumeManager(volumes []Volume) *RRVolumeManager { - vm := &RRVolumeManager{} + vm := &RRVolumeManager{ + iostats: make(map[Volume]*ioStats), + } for _, v := range volumes { + vm.iostats[v] = &ioStats{} vm.readables = append(vm.readables, v) if v.Writable() { vm.writables = append(vm.writables, v) @@ -287,18 +295,35 @@ func (vm *RRVolumeManager) NextWritable() Volume { return vm.writables[i%uint32(len(vm.writables))] } +// VolumeStats returns an ioStats for the given volume. +func (vm *RRVolumeManager) VolumeStats(v Volume) *ioStats { + return vm.iostats[v] +} + // Close the RRVolumeManager func (vm *RRVolumeManager) Close() { } -// VolumeStatus provides status information of the volume consisting of: -// * mount_point -// * device_num (an integer identifying the underlying storage system) -// * bytes_free -// * bytes_used +// VolumeStatus describes the current condition of a volume type VolumeStatus struct { - MountPoint string `json:"mount_point"` - DeviceNum uint64 `json:"device_num"` - BytesFree uint64 `json:"bytes_free"` - BytesUsed uint64 `json:"bytes_used"` + MountPoint string + DeviceNum uint64 + BytesFree uint64 + BytesUsed uint64 +} + +// ioStats tracks I/O statistics for a volume or server +type ioStats struct { + Errors uint64 + Ops uint64 + CompareOps uint64 + GetOps uint64 + PutOps uint64 + TouchOps uint64 + InBytes uint64 + OutBytes uint64 +} + +type InternalStatser interface { + InternalStats() interface{} }