Skip to content

Commit 4b057bc

Browse files
author
sai chaithanya
authored
feat(btrfs): add online expansion support of btrfs filesystem (#10)
This commit add support for online expansion of btrfs filesystem Signed-off-by: mittachaitu <[email protected]>
1 parent 313b940 commit 4b057bc

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pkg/btrfs/btrfs_util.go

+25
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@ package btrfs
1919
import (
2020
"os/exec"
2121

22+
"github.com/openebs/lib-csi/pkg/common/errors"
2223
"k8s.io/klog"
2324
)
2425

26+
const (
27+
// BTRFS is a command line utility of btrfs filesystem
28+
BTRFS = "btrfs"
29+
)
30+
2531
/*
2632
* We have to generate a new UUID for the cloned volumes with btrfs filesystem
2733
* otherwise system will mount the same volume if UUID is same. Here, since cloned
@@ -41,3 +47,22 @@ func GenerateUUID(device string) error {
4147
klog.Infof("btrfs: generated UUID for the device %s \n %v", device, string(out))
4248
return nil
4349
}
50+
51+
// ResizeBTRFS will expand btrfs filesystem at given mount point
52+
func ResizeBTRFS(mountPoint string) error {
53+
args := []string{"filesystem", "resize", "max", mountPoint}
54+
cmd := exec.Command(BTRFS, args...)
55+
56+
out, err := cmd.CombinedOutput()
57+
if err != nil {
58+
klog.Errorf(
59+
"btrfs utility could not expand btrfs filesystem "+
60+
"on mount point: %s cmd: %v error: %s",
61+
mountPoint,
62+
args,
63+
string(out),
64+
)
65+
return errors.Wrap(err, string(out))
66+
}
67+
return nil
68+
}

0 commit comments

Comments
 (0)