mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-31 02:38:07 +08:00
feat(region,host,host-deployer): f2fs filesystem support (#23118)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user