I've tried patching both 4.12.5 and 4.13-rc4. The patches apply cleanly and I've set CONFIG_SQUASHFS_ZSTD=y, CONFIG_XXHASH=y and CONFIG_ZSTD_DECOMPRESS=y.
I've used the squashfs toold from here, it compiles fine and I've successfully created the squashfs.
When I mount I just get mounting failed input/output error. In dmesg I've spotted this:
[ 4377.243871] SQUASHFS error: Failed to initialize zstd decompressor
[ 4377.243872] SQUASHFS error: zstd decompression failed, data probably corrupt
[ 4377.243873] SQUASHFS error: squashfs_read_data failed to read block 0x28b3d
[ 4377.243874] SQUASHFS error: Unable to read metadata cache entry [28b3d]
[ 4377.243875] SQUASHFS error: Unable to read inode 0x106709e0
I did read that the kernel patches were meant for 4.10, am I wrong to expect them to work on 4.12+ or is it perhaps the squashfs tools that are creating corrupt filesystems?
Any comment is appreciated, and let me know if there's any more info needed.
Thanks for the report @escalade. I think I've spotted the bug, zstd_wrapper.c:83 should be
stream = ZSTD_initDStream(max_t(size_t, msblk->block_size, SQUASHFS_METADATA_SIZE), wksp->mem, wksp->mem_size);
It must have been exposed when I added some extra tables to the ZSTD_DCtx, which bumped the window size over a power of 2 boundary. I'll update you when I've confirmed it.
That was fast :)
I've confirmed the fix, thanks again for the report. I'll update the patches here and on the mailing lists. I'll also add the squashfs-tools patch to the zstd repo. The patches are now tested on the master branch, I'll remove that outdated comment about 4.10.
Most helpful comment
Thanks for the report @escalade. I think I've spotted the bug,
zstd_wrapper.c:83should beIt must have been exposed when I added some extra tables to the
ZSTD_DCtx, which bumped the window size over a power of 2 boundary. I'll update you when I've confirmed it.