Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

Commit

Permalink
don't use btrfs quotas for size tracking
Browse files Browse the repository at this point in the history
this likely has significant performance and stability impact, and we
don't even use size reporting anymore

concourse/concourse#1966
  • Loading branch information
vito committed Jan 22, 2018
1 parent d148145 commit e0cf556
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions volume/driver/btrfs.go
Expand Up @@ -2,12 +2,10 @@ package driver

import (
"bytes"
"errors"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"

"code.cloudfoundry.org/lager"
)
Expand All @@ -33,11 +31,6 @@ func (driver *BtrFSDriver) CreateVolume(path string) error {
return err
}

_, _, err = driver.run(driver.btrfsBin, "quota", "enable", path)
if err != nil {
return err
}

return nil
}

Expand Down Expand Up @@ -85,26 +78,22 @@ func (driver *BtrFSDriver) CreateCopyOnWriteLayer(path string, parent string) er
}

func (driver *BtrFSDriver) GetVolumeSizeInBytes(path string) (int64, error) {
output, _, err := driver.run(driver.btrfsBin, "qgroup", "show", "-F", "--raw", path)
stdout := &bytes.Buffer{}
cmd := exec.Command("du", "-s", path)
cmd.Stdout = stdout

err := cmd.Run()
if err != nil {
return 0, err
}

qgroupsLines := strings.Split(strings.TrimSpace(output), "\n")
qgroupFields := strings.Fields(qgroupsLines[len(qgroupsLines)-1])

if len(qgroupFields) != 3 {
return 0, errors.New("unable-to-parse-btrfs-qgroup-show")
}

var exclusiveSize int64
_, err = fmt.Sscanf(qgroupFields[2], "%d", &exclusiveSize)

var size int64
_, err = fmt.Sscanf(stdout.String(), "%d", &size)
if err != nil {
return 0, err
}

return exclusiveSize, nil
return size * 512, nil
}

func (driver *BtrFSDriver) run(command string, args ...string) (string, string, error) {
Expand Down

0 comments on commit e0cf556

Please sign in to comment.