Allow multiple whitespace-separated compression-algorithm=s, and give the ones after the first one to /recomp_algorithm
Ref: https://github.com/systemd/zram-generator/issues/178#issuecomment-2361314574
I've tested the error case, @OmegaSquad82 needs to test the "actually setting it" case.
A config like
compression-algorithm = a b c
was previously "compress with a b c" (naturally invalid) and is now "compress with a, recompress with b then c"
Thank you so much I'll test it as soon as I can.
Rebased
Sorry for the delay. I got the notification and then forgot to look at this.
Code-wise this looks good, but I'm not convinced that this is the right interface.
The kernel allows additional parameters to be specified, for example type=huge_idle max_pages=42 algo=zstd. If we allow just a list of algorithm types to be specified, it will be awkward to attach any options to this.
I wonder if the interface shouldn't be inverted, allowing the user to list each "recompression level" separately, with a list of options. But I'm not sure how to express this concisely.
I didn't really notice this because the interface is kinda iffy (/recomp_algorithm takes no options, /recompress takes options for the recompression subsystem or for a single algorithm, depending on the calling convention).
I can't think of a multi-key system that'd be any good. Maybe
compression-algorithm = a b(type=huge,threshold=1000) c (threshold=3000)
for
echo a > /sys/block/zram0/comp_algorithm
echo algo=b priority=1 > /sys/block/zramX/recomp_algorithm
echo type=huge threshold=1000 priority=1 > /sys/block/zramX/recompress
echo algo=c priority=2 > /sys/block/zramX/recomp_algorithm
echo threshold=3000 > /sys/block/zramX/recompress
?
That seems pretty nice.
Added
As a side-effect we also support /algorithm_params (it was easier than not doing that). Needs to be tested by submitter.
LGTM. Let's wait for feedback from the reporter.
OK, let's do this. It'd be good to some testing on a real system, but we can do this later.
LGTM, have tested few parameters. Seems to work as expected. Thank you both.