The PuzzleFS container filesystem
The PuzzleFS container filesystem
Posted Sep 26, 2023 7:31 UTC (Tue) by hsiangkao (guest, #123981)Parent article: The PuzzleFS container filesystem
Side note is that EROFS already supports a varient CDC with compression since Linux v6.1. It would be nice to make a comparsion too in some extent so I could know what people care about more for our further enhancements. I know people enjoy new stuffs all the time but it would be nice to get more hints why state-of-art projects don't work well except for Rust adaption.
Similar to Christian said before [3], AFAIK, there were already four container image approaches raised for Linux kernel in addition to Composefs:
1. original Nydus [4], also called Dragonfly Image service in OCIv2 brainstorm [5] --- Actually they already had an in-kernel implementation of their RAFS v5 before I joined Alibaba Cloud, if needed, they could post the original kernel implementation at that time to the mailing list;
2. TarFS [6];
3. Overlaybd [7] --- Another QCOW2-like block driver approach from another team in Alibaba Cloud;
4. Puzzlefs.
I'm not sure if Linux could accept all of them for the same use case, anyway.
[1] https://0pointer.net/blog/casync-a-tool-for-distributing-...
[2] https://www.usenix.org/system/files/conference/atc16/atc1...
[3] https://lore.kernel.org/r/20230609-nachrangig-handwagen-3...
[4] https://github.com/opencontainers/.github/blob/master/mee...
https://github.com/dragonflyoss/image-service/blob/master...
[5] https://hackmd.io/@cyphar/ociv2-brainstorm
[6] https://github.com/kata-containers/kata-containers/pull/7106
https://kangrejos.com/2023/Read-only%20FS%20abstractions%...
[7] https://lore.kernel.org/r/9505927dabc3b6695d62dfe1be371b1...
Posted Sep 26, 2023 8:05 UTC (Tue)
by alexl (subscriber, #19068)
[Link] (6 responses)
PuzzleFS (as well as e.g. nydus, etc) does block-chunking de-duplication, whereas composefs does entire-file de-duplication. Yes, the block-chunking approach is more efficient during download (as you may reuse blocks when files are only partially the same), and will use less disk-space.
However the entire-file dedup approach is more efficient at runtime.
This is because the page cache, and things like vm address spaces, are tied to a single inode. You can't get a single inode out of the multiple chunk files. This means the chunked approach doubles the page cache use. Once to cache the chunk, and once to cache the merged file. You also can't share page cache use between different puzzlefs mounts even if they use shared base files. With composefs, the page caching *only* happens on the base file, and is shared between any composefs mounts using the same backing file. This allows better container density, as e.g. all the glibc mmaps shared between any running containers are the same in the page cache.
I guess an optimal system would use a block-chunked approach for downloads, but expand into full-file dedup in the local storage.
Posted Sep 26, 2023 8:18 UTC (Tue)
by hsiangkao (guest, #123981)
[Link] (1 responses)
Yes, yet in that way, there are more effective backup/restore technologies such as delta compression (frequently discussed in several academic conferences such as ATC) to reduce I/Os than just do content-defined chunking. And not necessary in a real filesystem form to keep such delta compression archival format.
Posted Sep 26, 2023 13:52 UTC (Tue)
by alexl (subscriber, #19068)
[Link]
Also, you can use filesystem level compression (in e.g. btrfs) to compress the files in the backing dir. Or even use reflinks copy create backing files that share some (but not all) blocks.
The sky is the limit, and all these approaches are compatible with using composefs to mount them.
Posted Sep 26, 2023 14:47 UTC (Tue)
by tych0 (subscriber, #105844)
[Link] (1 responses)
This is a great point. I guess it could be worked around with some core mm+fs fu, but it would definitely not be simple.
> I guess an optimal system would use a block-chunked approach for downloads, but expand into full-file dedup in the local storage.
It was an explicit design goal of PuzzleFS not to have any translation step between the image that is pushed to the container registry and the one that's mounted+run on the host, so any translation step here would be a non-starter, which seems like you need to pick "one or the other" unfortunately.
Posted Sep 27, 2023 19:01 UTC (Wed)
by calumapplepie (guest, #143655)
[Link]
Could KSM be extended to work on file-backed pages?
Posted Sep 26, 2023 16:11 UTC (Tue)
by walters (subscriber, #7396)
[Link] (1 responses)
Posted Sep 26, 2023 20:28 UTC (Tue)
by rcampos (subscriber, #59737)
[Link]
There were some patches to FUSE to allow a passthrough in some cases, that is what I wish is used to do this in a reasonable way.
Posted Sep 26, 2023 12:45 UTC (Tue)
by bluca (subscriber, #118303)
[Link] (10 responses)
Posted Sep 26, 2023 13:40 UTC (Tue)
by hsiangkao (guest, #123981)
[Link] (9 responses)
Hi! Using EROFS + dm-verity + blockdevice + overlayfs (composefs-like model), you could already implement a clean file-based runtime dedup by using overlayfs.
I understand that you mean EROFS self-contained file-based runtime dedupe across images as you mentioned in some previous article. Actually we already have an internal version for internal products by Jingbo, but it's still unclean for now. We will try to clean up and post it to fsdevel mailing list later, but not quite sure it could land smoothly, anyway.
Posted Sep 26, 2023 14:17 UTC (Tue)
by bluca (subscriber, #118303)
[Link] (8 responses)
Posted Sep 26, 2023 14:30 UTC (Tue)
by alexl (subscriber, #19068)
[Link] (3 responses)
Posted Sep 26, 2023 14:52 UTC (Tue)
by hsiangkao (guest, #123981)
[Link] (2 responses)
I think if some blob storage layer is just an EROFS image, you could directly apply dm-verity on these layers.
We can also use fs-verity to verity the blob storage layers if these layers are on a RW fs (the current composefs does.)
Posted Sep 26, 2023 15:02 UTC (Tue)
by alexl (subscriber, #19068)
[Link] (1 responses)
Posted Sep 26, 2023 15:09 UTC (Tue)
by hsiangkao (guest, #123981)
[Link]
Posted Sep 26, 2023 14:35 UTC (Tue)
by hsiangkao (guest, #123981)
[Link] (3 responses)
Alternatively, as an EROFS self-containerd approach, EROFS could share page cache if files with same data across images without relying on overlayfs, anyway.
Posted Sep 26, 2023 15:57 UTC (Tue)
by bluca (subscriber, #118303)
[Link] (2 responses)
Posted Sep 26, 2023 16:08 UTC (Tue)
by hsiangkao (guest, #123981)
[Link] (1 responses)
In that case, memory of /usr/foo/a is deduplicated according to how overlayfs works since /usr/foo/a is on the same EROFS instance.
Posted Sep 26, 2023 16:57 UTC (Tue)
by bluca (subscriber, #118303)
[Link]
The PuzzleFS container filesystem
The PuzzleFS container filesystem
The PuzzleFS container filesystem
The PuzzleFS container filesystem
The PuzzleFS container filesystem
> This is a great point. I guess it could be worked around with some core mm+fs fu, but it would definitely not be simple.
The PuzzleFS container filesystem
The PuzzleFS container filesystem
The PuzzleFS container filesystem
The PuzzleFS container filesystem
The PuzzleFS container filesystem
The PuzzleFS container filesystem
The PuzzleFS container filesystem
And check dm-verity root digests of these layers before mounting. I think that would be in the same effect, anyway.
The PuzzleFS container filesystem
The PuzzleFS container filesystem
I'm not sure if some people really rely on layering concept (such as system using raw partitions/devices without real filesystem storage), anyway.
The PuzzleFS container filesystem
- EROFS + dm-verity block device blobs as data only layers;
- a small overlayfs meta layer (with EROFS + dm-verity) to merge these data storage blobs into a merged rootfs.
Thus all layers are under dm-verity protection, so the whole image won't be tampered.
The PuzzleFS container filesystem
The PuzzleFS container filesystem
That already works without any extra built-in feature.
The PuzzleFS container filesystem