Skip to content

Commit

Permalink
feat(btrfs): add online expansion support of btrfs filesystem (#10)
Browse files Browse the repository at this point in the history
This commit add support for online expansion of btrfs filesystem

Signed-off-by: mittachaitu <[email protected]>
  • Loading branch information
sai chaithanya authored Jun 3, 2021
1 parent 313b940 commit 4b057bc
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pkg/btrfs/btrfs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ package btrfs
import (
"os/exec"

"github.com/openebs/lib-csi/pkg/common/errors"
"k8s.io/klog"
)

const (
// BTRFS is a command line utility of btrfs filesystem
BTRFS = "btrfs"
)

/*
* We have to generate a new UUID for the cloned volumes with btrfs filesystem
* otherwise system will mount the same volume if UUID is same. Here, since cloned
Expand All @@ -41,3 +47,22 @@ func GenerateUUID(device string) error {
klog.Infof("btrfs: generated UUID for the device %s \n %v", device, string(out))
return nil
}

// ResizeBTRFS will expand btrfs filesystem at given mount point
func ResizeBTRFS(mountPoint string) error {
args := []string{"filesystem", "resize", "max", mountPoint}
cmd := exec.Command(BTRFS, args...)

out, err := cmd.CombinedOutput()
if err != nil {
klog.Errorf(
"btrfs utility could not expand btrfs filesystem "+
"on mount point: %s cmd: %v error: %s",
mountPoint,
args,
string(out),
)
return errors.Wrap(err, string(out))
}
return nil
}

0 comments on commit 4b057bc

Please sign in to comment.