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

add xfs option support #72

Merged
merged 6 commits into from
Sep 13, 2024
Merged
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
18 changes: 16 additions & 2 deletions pkg/spdk/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"errors"
"fmt"
"os"
osExec "os/exec"
"strconv"
"time"

"github.com/container-storage-interface/spec/lib/go/csi"
Expand Down Expand Up @@ -180,7 +182,7 @@ func (ns *nodeServer) NodeStageVolume(_ context.Context, req *csi.NodeStageVolum
initiator.Disconnect() //nolint:errcheck // ignore error
}
}()
if err = ns.stageVolume(devicePath, stagingTargetPath, req); err != nil { // idempotent
if err = ns.stageVolume(devicePath, stagingTargetPath, req, vc); err != nil { // idempotent
klog.Errorf("failed to stage volume, volumeID: %s devicePath:%s err: %v", volumeID, devicePath, err)
return nil, status.Error(codes.Internal, err.Error())
}
Expand Down Expand Up @@ -302,7 +304,7 @@ func (ns *nodeServer) NodeExpandVolume(_ context.Context, req *csi.NodeExpandVol
// must be idempotent
//
//nolint:cyclop // many cases in switch increases complexity
func (ns *nodeServer) stageVolume(devicePath, stagingPath string, req *csi.NodeStageVolumeRequest) error {
func (ns *nodeServer) stageVolume(devicePath, stagingPath string, req *csi.NodeStageVolumeRequest, volumeContext map[string]string) error {
mounted, err := ns.createMountPoint(stagingPath)
if err != nil {
return err
Expand All @@ -315,6 +317,18 @@ func (ns *nodeServer) stageVolume(devicePath, stagingPath string, req *csi.NodeS
// if fsType is not specified, use ext4 as default
if fsType == "" {
fsType = "ext4"
} else if fsType == "xfs" {
distrNdcs, errNdcs := strconv.Atoi(volumeContext["distr_ndcs"])
if errNdcs != nil {
return errNdcs
}
cmd := fmt.Sprintf("mkfs.xfs -f -d sunit=%d,swidth=%d -l sunit=%d %s", 8*distrNdcs, 8*distrNdcs, 8*distrNdcs, devicePath)
klog.Infof("Executing command: %s", cmd)
errNdcs = osExec.Command("sh", "-c", cmd).Run()
if errNdcs != nil {
klog.Errorf("Error executing command: %v", errNdcs)
return errNdcs
}
}
mntFlags := req.GetVolumeCapability().GetMount().GetMountFlags()

Expand Down
Loading