diff --git a/docs/snapshotters/erofs.md b/docs/snapshotters/erofs.md index ebc46ce63b..bb08286c11 100644 --- a/docs/snapshotters/erofs.md +++ b/docs/snapshotters/erofs.md @@ -141,10 +141,7 @@ forget to restart containerd after changing the configuration. # Enable fsverity support for EROFS layers, default is false enable_fsverity = true - # fsync the snapshot directory, everything in it and its entry in - # snapshots/ before a snapshot is committed, so a power loss cannot - # leave a committed snapshot without its blob or directory. Blobs served - # from layer_content_caches are not synced. Costs a few fsyncs per layer, + # Enable fsyncing a snapshot's directory before the snapshot is committed, # default is false fsync_on_commit = true diff --git a/plugins/snapshots/erofs/erofs.go b/plugins/snapshots/erofs/erofs.go index 5295f0a7c3..4db15f0390 100644 --- a/plugins/snapshots/erofs/erofs.go +++ b/plugins/snapshots/erofs/erofs.go @@ -51,8 +51,7 @@ type SnapshotterConfig struct { enableFsverity bool // setImmutable enables IMMUTABLE_FL file attribute for EROFS layers setImmutable bool - // fsyncOnCommit makes Commit sync the layer blob and the snapshot - // directories before the snapshot is recorded as committed + // fsyncOnCommit enables fsyncing a snapshot's directory before the snapshot is committed fsyncOnCommit bool // defaultSize creates a default size writable layer for active snapshots defaultSize int64 @@ -91,8 +90,7 @@ func WithImmutable() Opt { } } -// WithFsyncOnCommit makes Commit sync the layer blob and the snapshot -// directories to disk before the snapshot is recorded as committed +// WithFsyncOnCommit enables fsyncing a snapshot's directory before the snapshot is committed func WithFsyncOnCommit() Opt { return func(config *SnapshotterConfig) { config.fsyncOnCommit = true @@ -296,9 +294,7 @@ func (s *snapshotter) layerBlobPath(id string) string { return filepath.Join(s.root, "snapshots", id, "layer.erofs") } -// syncDir fsyncs the immediate entries of dir, then dir itself and its parent, -// so that the files in dir, its entry list and its own entry in the parent are -// on disk before the caller records them elsewhere. It does not recurse. +// syncDir fsyncs the entries of dir, then dir and its parent. func syncDir(dir string) error { entries, err := os.ReadDir(dir) if err != nil { @@ -1003,16 +999,6 @@ func (s *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap // Note: dm-verity formatting is handled by the EROFS differ, not here - // The metadata store syncs its own file when the snapshot is committed, so - // with fsync_on_commit enabled the layer is made durable first; otherwise - // a power loss shortly after a successful pull can leave a committed - // snapshot whose blob is truncated or whose directory does not exist, and - // nothing re-pulls a layer whose chain ID already exists. Everything in - // the snapshot directory is synced rather than a list of known files, then - // the directory and its entry in snapshots/, which was created by a rename - // in Prepare and may still be unwritten. A blob served from the layer - // content cache lives elsewhere and is not synced; whoever populates the - // cache must make it durable. if s.fsyncOnCommit { if err := syncDir(filepath.Join(s.root, "snapshots", id)); err != nil { return err diff --git a/plugins/snapshots/erofs/plugin/plugin.go b/plugins/snapshots/erofs/plugin/plugin.go index f77ed3273d..e406ce8b76 100644 --- a/plugins/snapshots/erofs/plugin/plugin.go +++ b/plugins/snapshots/erofs/plugin/plugin.go @@ -51,11 +51,7 @@ type Config struct { // If `SetImmutable` is enabled, IMMUTABLE_FL will be set on layer blobs. SetImmutable bool `toml:"set_immutable"` - // FsyncOnCommit makes Commit fsync the snapshot directory, everything in - // it and its entry in snapshots/ before the snapshot is recorded, so that - // a power loss cannot leave a committed snapshot without its blob or - // directory. Blobs served from a layer content cache are not synced. Off - // by default, like the diff service's sync_fs. + // FsyncOnCommit enables fsyncing a snapshot's directory before the snapshot is committed FsyncOnCommit bool `toml:"fsync_on_commit"` // DefaultSize is the default size of a writable layer in string