feat(region,host,host-deployer): f2fs filesystem support (#23118)

This commit is contained in:
wanyaoqi
2025-08-22 09:06:31 +08:00
committed by GitHub
parent f1f01ea823
commit cff38d74ec
10 changed files with 20 additions and 4 deletions
+1
View File
@@ -362,6 +362,7 @@ type DiskRebuildInput struct {
BackupId *string `json:"backup_id,allowempty"`
TemplateId *string `json:"template_id,allowempty"`
Size *string `json:"size,allowempty"`
Fs *string `json:"fs,allowempty"`
}
type DiskFsExt4Features struct {
+2
View File
@@ -196,6 +196,8 @@ var (
// supported shared storage types
SHARED_STORAGE = []string{STORAGE_NFS, STORAGE_GPFS, STORAGE_RBD, STORAGE_CLVM, STORAGE_SLVM}
SUPPORTED_FS = []string{"swap", "ext2", "ext3", "ext4", "xfs", "f2fs"}
)
func IsDiskTypeMatch(t1, t2 string) bool {
+3
View File
@@ -3318,6 +3318,9 @@ func (disk *SDisk) resetDiskinfo(
if diskSize > 0 {
disk.DiskSize = diskSize
}
if input.Fs != nil {
disk.FsFormat = *input.Fs
}
return nil
})
if err != nil {
+6
View File
@@ -279,6 +279,10 @@ func ResizePartitionFs(fpath, fs string, raiseError, mounted bool) (error, bool)
// comment out the following codes only impact Windows 2003
// as windows 2003 deprecated, so choose to sacrifies windows 2003
// cmds = [][]string{{"ntfsresize", "-c", fpath}, {"ntfsresize", "-P", "-f", fpath}}
} else if fs == "f2fs" {
if !mounted {
cmds = [][]string{{"resize.f2fs"}}
}
}
if len(cmds) > 0 {
@@ -436,6 +440,8 @@ func FormatPartition(path, fs, uuid string, fsFeatures *apis.FsFeatures) error {
case fs == "xfs":
cmd = []string{"mkfs.xfs", "-f", "-m", "crc=0", "-i", "projid32bit=0", "-n", "ftype=1"}
cmdUuid = []string{"xfs_admin", "-U", uuid}
case fs == "f2fs":
cmd = []string{"mkfs.f2fs", "-U", uuid, "-O", "extra_attr,inode_checksum,sb_checksum"}
}
if len(cmd) > 0 {
+3
View File
@@ -255,6 +255,9 @@ func (p *SKVMGuestDiskPartition) fsck() error {
case "ntfs":
checkCmd = []string{"ntfsfix", "-n", p.partDev}
fixCmd = []string{"ntfsfix", p.partDev}
case "f2fs":
checkCmd = []string{"fsck.f2fs", "-f", p.partDev}
fixCmd = []string{"fsck.f2fs", "-a", p.partDev}
}
if len(checkCmd) > 0 {
_, err := procutils.NewCommand(checkCmd[0], checkCmd[1:]...).Output()
+1 -1
View File
@@ -426,7 +426,7 @@ func (d *SLocalDisk) CreateRaw(ctx context.Context, sizeMB int, diskFormat strin
diskInfo.EncryptPassword = encryptInfo.Key
diskInfo.EncryptAlg = string(encryptInfo.Alg)
}
if utils.IsInStringArray(fsFormat, []string{"swap", "ext2", "ext3", "ext4", "xfs"}) {
if utils.IsInStringArray(fsFormat, api.SUPPORTED_FS) {
d.FormatFs(fsFormat, fsFeatures, diskId, diskInfo)
}
+1 -1
View File
@@ -150,7 +150,7 @@ func (d *SLVMDisk) CreateRaw(ctx context.Context, sizeMB int, diskFormat string,
diskInfo.EncryptPassword = encryptInfo.Key
diskInfo.EncryptAlg = string(encryptInfo.Alg)
}
if utils.IsInStringArray(fsFormat, []string{"swap", "ext2", "ext3", "ext4", "xfs"}) {
if utils.IsInStringArray(fsFormat, api.SUPPORTED_FS) {
d.FormatFs(fsFormat, nil, diskId, diskInfo)
}
return d.GetDiskDesc(), nil
+1 -1
View File
@@ -227,7 +227,7 @@ func (d *SRBDDisk) CreateRaw(ctx context.Context, sizeMb int, diskFormat string,
diskInfo := &deployapi.DiskInfo{
Path: d.GetPath(),
}
if utils.IsInStringArray(fsFormat, []string{"swap", "ext2", "ext3", "ext4", "xfs"}) {
if utils.IsInStringArray(fsFormat, api.SUPPORTED_FS) {
d.FormatFs(fsFormat, nil, diskId, diskInfo)
}
+1
View File
@@ -111,6 +111,7 @@ type DiskRebuildOptions struct {
BackupId string `help:"disk backup id" json:"backup_id"`
TemplateId string `help:"disk template id" json:"template_id"`
Size string `help:"disk size in MB" json:"size"`
Fs string `help:"disk fs type"`
}
func (o *DiskRebuildOptions) Params() (jsonutils.JSONObject, error) {
+1 -1
View File
@@ -382,7 +382,7 @@ func FsFormatToDiskType(fsFormat string) string {
switch {
case fsFormat == "swap":
return "linux-swap"
case strings.HasPrefix(fsFormat, "ext") || fsFormat == "xfs":
case strings.HasPrefix(fsFormat, "ext") || fsFormat == "xfs" || fsFormat == "f2fs":
return "ext2"
case strings.HasPrefix(fsFormat, "fat"):
return "fat32"