@@ -97,6 +97,7 @@ type BootConfig struct {
9797 DefaultFsType string `json:"defaultFsType"`
9898 RootfsQuota string `json:"rootfsQuota"` // "20g" rootfs quota, only effective when rwMode is 'overlayfs'
9999 Tenant int `json:"tenant"` // do not set this if only a single snapshotter service in the host
100+ TurboFsType []string `json:"turboFsType"`
100101}
101102
102103func DefaultBootConfig () * BootConfig {
@@ -115,6 +116,10 @@ func DefaultBootConfig() *BootConfig {
115116 DefaultFsType : "ext4" ,
116117 RootfsQuota : "" ,
117118 Tenant : - 1 ,
119+ TurboFsType : []string {
120+ "ext4" ,
121+ "erofs" ,
122+ },
118123 }
119124}
120125
@@ -183,6 +188,7 @@ type snapshotter struct {
183188 defaultFsType string
184189 tenant int
185190 locker * locker.Locker
191+ turboFsType []string
186192
187193 quotaDriver * diskquota.PrjQuotaDriver
188194 quotaSize string
@@ -244,6 +250,7 @@ func NewSnapshotter(bootConfig *BootConfig, opts ...Opt) (snapshots.Snapshotter,
244250 mirrorRegistry : bootConfig .MirrorRegistry ,
245251 defaultFsType : bootConfig .DefaultFsType ,
246252 locker : locker .New (),
253+ turboFsType : bootConfig .TurboFsType ,
247254 tenant : bootConfig .Tenant ,
248255 quotaSize : bootConfig .RootfsQuota ,
249256 quotaDriver : & diskquota.PrjQuotaDriver {
@@ -1390,10 +1397,19 @@ func IsErofsSupported() bool {
13901397
13911398func (o * snapshotter ) turboOCIFsMeta (id string ) (string , string ) {
13921399 // TODO: make the priority order (multi-meta exists) configurable later if needed
1393- erofsmeta := filepath .Join (o .root , "snapshots" , id , "fs" , "erofs.fs.meta" )
1394- if _ , err := os .Stat (erofsmeta ); err == nil && IsErofsSupported () {
1395- return erofsmeta , "erofs"
1400+ for _ , fsType := range o .turboFsType {
1401+ fsmeta := filepath .Join (o .root , "snapshots" , id , "fs" , fsType + ".fs.meta" )
1402+ if _ , err := os .Stat (fsmeta ); err == nil {
1403+ if fsType == "erofs" && ! IsErofsSupported () {
1404+ log .L .Warn ("erofs is not supported on this system, fallback to other fs type" )
1405+ continue
1406+ }
1407+ return fsmeta , fsType
1408+ } else if ! errors .Is (err , os .ErrNotExist ) {
1409+ log .L .Errorf ("error while checking fs meta file: %s" , err )
1410+ }
13961411 }
1412+ log .L .Warn ("no fs meta file found, fallback to ext4" )
13971413 return filepath .Join (o .root , "snapshots" , id , "fs" , "ext4.fs.meta" ), "ext4"
13981414}
13991415
0 commit comments