Skip to content

Commit bb9388f

Browse files
committed
Fallback to EXT4 if .TurboOCI_ext4 for TurboOCI
Signed-off-by: Gao Xiang <[email protected]>
1 parent d755525 commit bb9388f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pkg/snapshot/storage.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ const (
6666
// param used to restrict tcmu data area size
6767
// it is worked by setting max_data_area_mb for devices in configfs.
6868
obdMaxDataAreaMB = 4
69+
70+
// Just in case someone really needs to force to ext4
71+
ext4FSFallbackFile = ".TurboOCI_ext4"
6972
)
7073

7174
type mountMatcherFunc func(fields []string, separatorIndex int) bool
@@ -659,6 +662,22 @@ func (o *snapshotter) constructOverlayBDSpec(ctx context.Context, key string, wr
659662
Data: o.overlaybdWritableDataPath(id),
660663
}
661664
}
665+
666+
if isTurboOCI, _, _ := o.checkTurboOCI(info.Labels); isTurboOCI {
667+
// If the fallback file exists, enforce TurboOCI fstype to EXT4
668+
ext4FSFallbackPath := filepath.Join(o.root, ext4FSFallbackFile)
669+
_, err = os.Stat(ext4FSFallbackPath)
670+
if err == nil && configJSON.Lowers[0].File != "" {
671+
var newLowers []sn.OverlayBDBSConfigLower
672+
log.G(ctx).Infof("fallback to EXT4 since %s exists", ext4FSFallbackPath)
673+
for _, l := range configJSON.Lowers {
674+
s, _ := filepath.Split(l.File)
675+
l.File = filepath.Join(s, "ext4.fs.meta")
676+
newLowers = append(newLowers, l)
677+
}
678+
configJSON.Lowers = newLowers
679+
}
680+
}
662681
configBuffer, _ := json.MarshalIndent(configJSON, "", " ")
663682
log.G(ctx).Infoln(string(configBuffer))
664683
return o.atomicWriteOverlaybdTargetConfig(id, &configJSON)

0 commit comments

Comments
 (0)