Skip to content

Commit 9da9768

Browse files
dmcgowank8s-infra-cherrypick-robot
authored andcommitted
Use default writable size in erofs snapshotter for non-Linux hosts
Non-Linux hosts are not expected to be able to directly mount erofs snapshotters on the host system. Non-Linux hosts should use block mode by default with a reasonably set default block size. Signed-off-by: Derek McGowan <[email protected]>
1 parent eeb0f88 commit 9da9768

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

plugins/snapshots/erofs/erofs.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ type snapshotter struct {
9595
// NewSnapshotter returns a Snapshotter which uses EROFS+OverlayFS. The layers
9696
// are stored under the provided root. A metadata file is stored under the root.
9797
func NewSnapshotter(root string, opts ...Opt) (snapshots.Snapshotter, error) {
98-
var config SnapshotterConfig
98+
config := SnapshotterConfig{
99+
defaultSize: defaultWritableSize,
100+
}
99101
for _, opt := range opts {
100102
opt(&config)
101103
}
@@ -104,8 +106,11 @@ func NewSnapshotter(root string, opts ...Opt) (snapshots.Snapshotter, error) {
104106
return nil, err
105107
}
106108

107-
if err := checkCompatibility(root); err != nil {
108-
return nil, err
109+
if config.defaultSize == 0 {
110+
// If not block mode, check root compatibility
111+
if err := checkCompatibility(root); err != nil {
112+
return nil, err
113+
}
109114
}
110115

111116
// Check fsverity support if enabled

plugins/snapshots/erofs/erofs_linux.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ import (
3333
"github.com/containerd/containerd/v2/internal/erofsutils"
3434
)
3535

36+
// defaultWritableSize is set to 0 for Linux to match the default behavior of
37+
// other snapshotters available on Linux.
38+
const defaultWritableSize = 0
39+
3640
// check if EROFS kernel filesystem is registered or not
3741
func findErofs() bool {
3842
fs, err := os.ReadFile("/proc/filesystems")

plugins/snapshots/erofs/erofs_other.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ import (
2424
"github.com/containerd/errdefs"
2525
)
2626

27+
// defaultWritableSize is the default size allocation for writable
28+
// layers on non-Linux platforms. This is set to 64MiB but may be
29+
// adjusted in the user configuration or per snapshot.
30+
const defaultWritableSize = 64 * 1024 * 1024
31+
2732
func checkCompatibility(root string) error {
2833
return nil
2934
}

0 commit comments

Comments
 (0)