Skip to content

erofs-differ: support zstd-wrapped EROFS layers#13185

Merged
fuweid merged 1 commit intocontainerd:mainfrom
erofs:erofs-layers
Apr 12, 2026
Merged

erofs-differ: support zstd-wrapped EROFS layers#13185
fuweid merged 1 commit intocontainerd:mainfrom
erofs:erofs-layers

Conversation

@hsiangkao
Copy link
Copy Markdown
Member

@hsiangkao hsiangkao commented Apr 8, 2026

Although EROFS has builtin native compression support (and each filesystem can contain multiple compression algorithms), in many cases, people only consider using zstd compression when transporting on the wire (see #12506) in order to reduce the pulling time but maintain the optimal runtime performance with uncompressed filesystems.

Only +zstd is considered (IOWs, +gzip is never considered at all): it has skippable frames which will be used for the seekable EROFS implementation (#12703) in future containerd versions.

Proposed mediatype: MediaTypeErofsLayer + "+zstd" ("application/vnd.erofs.layer.v1+zstd")

Test steps:

ctr i pull --snapshotter=erofs docker.io/hsiangkao/ubuntu:22.04-erofs-zstd
ctr run --tty --snapshotter=erofs docker.io/hsiangkao/ubuntu:22.04-erofs-zstd test
image

Cc @anniecherk

Support zstd-wrapped EROFS layers

@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Apr 8, 2026
@dosubot dosubot Bot added the area/distribution Image Distribution label Apr 8, 2026
@dmcgowan dmcgowan added this to the 2.3 milestone Apr 9, 2026
@dmcgowan dmcgowan moved this from Needs Triage to Needs Update in Pull Request Review Apr 10, 2026
@dmcgowan dmcgowan moved this from Needs Update to Needs Reviewers in Pull Request Review Apr 10, 2026
Copy link
Copy Markdown
Member

@dmcgowan dmcgowan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can figure out chain logic later, if necessary

@github-project-automation github-project-automation Bot moved this from Needs Reviewers to Review In Progress in Pull Request Review Apr 12, 2026
if err != nil {
return emptyDesc, err
}
_, err = io.Copy(f, content.NewReader(ra))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The replacement does not allow the optimization that this code does, this allows copy file range when there is no decompresssion. The underlying reader supports directly copying from the content store file descriptor to another file descriptor. We should keep in a special path for uncompressed as this is the only case where content to snapshotter can be done like this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, let me update it to allow copy file range

Copy link
Copy Markdown
Member Author

@hsiangkao hsiangkao Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a fastcopy boolean: I admit it's not pretty clean, but I don't have much better ideas; I think we could clean it up later with chain logic changes...

Comment thread plugins/diff/erofs/differ.go
Copilot AI review requested due to automatic review settings April 12, 2026 17:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the EROFS differ to recognize and apply EROFS layers that are wrapped with a +zstd transport compression suffix, enabling faster pulls while keeping uncompressed EROFS blobs on disk.

Changes:

  • Relax EROFS media type detection to allow +suffix variants.
  • In Apply, map EROFS +zstd layers onto the existing diff stream-processor chain to transparently decompress before writing layer.erofs.
  • Return an updated descriptor for processed native EROFS layers (base media type, digest/size of the unwrapped blob), and add debug logging for native apply paths.
Comments suppressed due to low confidence (1)

plugins/diff/erofs/differ.go:188

  • diff.GetProcessor may return processors (notably binaryProcessor) that only surface failures via an Err() error method; without checking that, stream-processor failures can be silently ignored and a truncated/invalid layer can be treated as successful. Consider tracking the processors in the chain (like core/diff/apply/apply.go) and checking Err() on any processor that implements it before returning.
	processor := diff.NewProcessorChain(diffLayerType, content.NewReader(ra))
	for {
		if processor, err = diff.GetProcessor(ctx, processor, config.ProcessorPayloads); err != nil {
			return emptyDesc, fmt.Errorf("failed to get stream processor for %s: %w", desc.MediaType, err)
		}
		if processor.MediaType() == ocispec.MediaTypeImageLayer {
			break
		}
	}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/diff/erofs/differ.go
Comment thread plugins/diff/erofs/differ.go Outdated
Comment thread plugins/diff/erofs/differ.go Outdated
Comment thread plugins/diff/erofs/differ.go
Comment thread plugins/diff/erofs/differ.go
Comment thread plugins/diff/erofs/differ.go
Comment thread plugins/diff/erofs/differ.go Outdated
Although EROFS has native compression support (and each filesystem can
contain multiple compression algorithms), in many cases, people only
consider using zstd compression when transporting on the wire in order
to reduce the pulling time but maintain the optimal runtime performance.

Only `+zstd` is considered: it has skippable frames which will be used
for the seekable EROFS implementation in future containerd versions.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
@hsiangkao
Copy link
Copy Markdown
Member Author

@AkihiroSuda @dmcgowan thanks for approving this, let's merge this?

@dmcgowan dmcgowan added this pull request to the merge queue Apr 12, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 12, 2026
@fuweid fuweid added this pull request to the merge queue Apr 12, 2026
Merged via the queue into containerd:main with commit 997f813 Apr 12, 2026
97 of 100 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

7 participants