-
Notifications
You must be signed in to change notification settings - Fork 536
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
rbd: add mkfsOptions
to the StorageClass and pass them to mkfs
#3692
Changes from all commits
7d07b4a
8d2f13d
f30f086
6fc3dfc
4f19b9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,15 @@ var ( | |
// xfsHasReflink is set by xfsSupportsReflink(), use the function when | ||
// checking the support for reflink. | ||
xfsHasReflink = xfsReflinkUnset | ||
|
||
mkfsDefaultArgs = map[string][]string{ | ||
"ext4": {"-m0", "-Enodiscard,lazy_itable_init=1,lazy_journal_init=1"}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. having some references to these options and why we enable them as default options could help There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, but I don't know where they come from. This PR just moves them around... |
||
"xfs": {"-K"}, | ||
} | ||
|
||
mountDefaultOpts = map[string][]string{ | ||
"xfs": {"nouuid"}, | ||
} | ||
) | ||
|
||
// parseBoolOption checks if parameters contain option and parse it. If it is | ||
|
@@ -756,7 +765,8 @@ func (ns *NodeServer) mountVolumeToStagePath( | |
return err | ||
} | ||
|
||
opt := []string{"_netdev"} | ||
opt := mountDefaultOpts[fsType] | ||
opt = append(opt, "_netdev") | ||
opt = csicommon.ConstructMountOptions(opt, req.GetVolumeCapability()) | ||
isBlock := req.GetVolumeCapability().GetBlock() != nil | ||
rOnly := "ro" | ||
|
@@ -771,34 +781,43 @@ func (ns *NodeServer) mountVolumeToStagePath( | |
readOnly = true | ||
} | ||
|
||
if fsType == "xfs" { | ||
opt = append(opt, "nouuid") | ||
} | ||
if existingFormat == "" && !staticVol && !readOnly && !isBlock { | ||
args := mkfsDefaultArgs[fsType] | ||
|
||
if existingFormat == "" && !staticVol && !readOnly { | ||
args := []string{} | ||
// if the VolumeContext contains "mkfsOptions", use those as args instead | ||
volumeCtx := req.GetVolumeContext() | ||
if volumeCtx != nil { | ||
mkfsOptions := volumeCtx["mkfsOptions"] | ||
if mkfsOptions != "" { | ||
args = strings.Split(mkfsOptions, " ") | ||
} | ||
} | ||
|
||
// add extra arguments depending on the filesystem | ||
mkfs := "mkfs." + fsType | ||
switch fsType { | ||
case "ext4": | ||
args = []string{"-m0", "-Enodiscard,lazy_itable_init=1,lazy_journal_init=1"} | ||
if fileEncryption { | ||
args = append(args, "-Oencrypt") | ||
} | ||
args = append(args, devicePath) | ||
case "xfs": | ||
args = []string{"-K", devicePath} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "-K" also needs to move to newly added mkfsDefultArgs ?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, good catch! |
||
// always disable reflink | ||
// TODO: make enabling an option, see ceph/ceph-csi#1256 | ||
if ns.xfsSupportsReflink() { | ||
args = append(args, "-m", "reflink=0") | ||
} | ||
case "": | ||
// no filesystem type specified, just use "mkfs" | ||
mkfs = "mkfs" | ||
} | ||
if len(args) > 0 { | ||
cmdOut, cmdErr := diskMounter.Exec.Command("mkfs."+fsType, args...).CombinedOutput() | ||
if cmdErr != nil { | ||
log.ErrorLog(ctx, "failed to run mkfs error: %v, output: %v", cmdErr, string(cmdOut)) | ||
|
||
return cmdErr | ||
} | ||
// add device as last argument | ||
args = append(args, devicePath) | ||
cmdOut, cmdErr := diskMounter.Exec.Command(mkfs, args...).CombinedOutput() | ||
if cmdErr != nil { | ||
log.ErrorLog(ctx, "failed to run mkfs.%s (%v) error: %v, output: %v", fsType, args, cmdErr, string(cmdOut)) | ||
|
||
return cmdErr | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nixpanic can we have a test case for XFS FS as well ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think there is much value in that. XFS is used in other tests already, so this PR does not break it.