MCPcopy Index your code
hub / github.com/containerd/containerd / GetUsage

Method GetUsage

plugins/snapshots/devmapper/pool_device.go:526–542  ·  view source on GitHub ↗

GetUsage reports total size in bytes consumed by a thin-device. It relies on the number of used blocks reported by 'dmsetup status'. The output looks like: device2: 0 204800 thin 17280 204799 Where 17280 is the number of used sectors

(deviceName string)

Source from the content-addressed store, hash-verified

524//
525// Where 17280 is the number of used sectors
526func (p *PoolDevice) GetUsage(deviceName string) (int64, error) {
527 status, err := dmsetup.Status(deviceName)
528 if err != nil {
529 return 0, fmt.Errorf("can't get status for device %q: %w", deviceName, err)
530 }
531
532 if len(status.Params) == 0 {
533 return 0, errors.New("failed to get the number of used blocks, unexpected output from dmsetup status")
534 }
535
536 count, err := strconv.ParseInt(status.Params[0], 10, 64)
537 if err != nil {
538 return 0, fmt.Errorf("failed to parse status params: %q: %w", status.Params[0], err)
539 }
540
541 return count * dmsetup.SectorSize, nil
542}
543
544// RemoveDevice completely wipes out thin device from thin-pool and frees it's device ID
545func (p *PoolDevice) RemoveDevice(ctx context.Context, deviceName string) error {

Callers 6

memory.goFile · 0.80
cpuContainerStatsMethod · 0.80
UsageMethod · 0.80
CommitMethod · 0.80
testCreateThinDeviceFunction · 0.80
testMakeFileSystemFunction · 0.80

Calls 1

StatusFunction · 0.92

Tested by 2

testCreateThinDeviceFunction · 0.64
testMakeFileSystemFunction · 0.64