Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xfs support #46

Open
wants to merge 2 commits into
base: V2.2.14
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/connector/connector_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,11 @@ func ResizeMountPath(volumePath string) error {
switch fsType {
case "ext2", "ext3", "ext4":
return extResize(devicePath)
case "xfs":
return xfsResize(devicePath)
}


return fmt.Errorf("resize of format %s is not supported for device %s", fsType, devicePath)
}

Expand All @@ -739,6 +742,17 @@ func extResize(devicePath string) error {
return nil
}

func xfsResize(devicePath string) error {
output, err := utils.ExecShellCmd("xfs_growfs %s", devicePath)
if err != nil {
log.Errorf("xfs Resize %s error: %s", devicePath, output)
return err
}

log.Infof("xfs Resize success for device path : %v", devicePath)
return nil
}

func findMultiPathWWN(mPath string) (string, error) {
output, err := utils.ExecShellCmd("multipathd show maps")
if err != nil {
Expand Down
29 changes: 17 additions & 12 deletions src/connector/nfs/nfs_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,18 +245,22 @@ func getFSType(sourcePath string) (string, error) {

func formatDisk(sourcePath, fsType, diskSizeType string) error {
var cmd string
switch diskSizeType {
case "default":
cmd = fmt.Sprintf("mkfs -t %s -F %s", fsType, sourcePath)
case "big":
cmd = fmt.Sprintf("mkfs -t %s -T big -F %s", fsType, sourcePath)
case "huge":
cmd = fmt.Sprintf("mkfs -t %s -T huge -F %s", fsType, sourcePath)
case "large":
cmd = fmt.Sprintf("mkfs -t %s -T largefile -F %s", fsType, sourcePath)
case "veryLarge":
cmd = fmt.Sprintf("mkfs -t %s -T largefile4 -F %s", fsType, sourcePath)
}
switch fsType {
case "xfs":
cmd = fmt.Sprintf("mkfs.xfs -f %s", sourcePath)
default:
switch diskSizeType {
case "default":
cmd = fmt.Sprintf("mkfs -t %s -F %s", fsType, sourcePath)
case "big":
cmd = fmt.Sprintf("mkfs -t %s -T big -F %s", fsType, sourcePath)
case "huge":
cmd = fmt.Sprintf("mkfs -t %s -T huge -F %s", fsType, sourcePath)
case "large":
cmd = fmt.Sprintf("mkfs -t %s -T largefile -F %s", fsType, sourcePath)
case "veryLarge":
cmd = fmt.Sprintf("mkfs -t %s -T largefile4 -F %s", fsType, sourcePath)
}
output, err := utils.ExecShellCmd(cmd)
if err != nil {
if strings.Contains(output, "in use by the system") {
Expand All @@ -267,6 +271,7 @@ func formatDisk(sourcePath, fsType, diskSizeType string) error {
log.Errorf("Couldn't mkfs %s to %s: %s", sourcePath, fsType, output)
return err
}

return nil
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func execShellCmd(format string, logFilter bool, args ...interface{}) (string, b
execCmd := []string{"-i/proc/1/ns/ipc", "-m/proc/1/ns/mnt", "-n/proc/1/ns/net", "/bin/sh", "-c", cmd}
shCmd := exec.Command("nsenter", execCmd...)
var timeOut bool
if strings.Contains(cmd, "mkfs") || strings.Contains(cmd, "resize2fs") {
if strings.Contains(cmd, "mkfs") || strings.Contains(cmd, "resize2fs" || strings.Contains(cmd, "xfs_growfs" ) {
time.AfterFunc(longTimeout*time.Second, func() {
timeOut = true
})
Expand Down