VnodeStats builds a VnodeStats from a slice of uint32s.
(us []uint32)
| 372 | |
| 373 | // VnodeStats builds a VnodeStats from a slice of uint32s. |
| 374 | func vnodeStats(us []uint32) (VnodeStats, error) { |
| 375 | // The attribute "Free" appears to not be available on older XFS |
| 376 | // stats versions. Therefore, 7 or 8 elements may appear in |
| 377 | // this slice. |
| 378 | l := len(us) |
| 379 | if l != 7 && l != 8 { |
| 380 | return VnodeStats{}, fmt.Errorf("incorrect number of values for XFS vnode stats: %d", l) |
| 381 | } |
| 382 | |
| 383 | s := VnodeStats{ |
| 384 | Active: us[0], |
| 385 | Allocate: us[1], |
| 386 | Get: us[2], |
| 387 | Hold: us[3], |
| 388 | Release: us[4], |
| 389 | Reclaim: us[5], |
| 390 | Remove: us[6], |
| 391 | } |
| 392 | |
| 393 | // Skip adding free, unless it is present. The zero value will |
| 394 | // be used in place of an actual count. |
| 395 | if l == 7 { |
| 396 | return s, nil |
| 397 | } |
| 398 | |
| 399 | s.Free = us[7] |
| 400 | return s, nil |
| 401 | } |
| 402 | |
| 403 | // BufferStats builds a BufferStats from a slice of uint32s. |
| 404 | func bufferStats(us []uint32) (BufferStats, error) { |
no outgoing calls
no test coverage detected
searching dependent graphs…