Skip to content

Commit 400ef70

Browse files
Fix how we configure compression parameters
Closes: #215
1 parent 0007613 commit 400ef70

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

man/zram-generator.conf.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ Devices with the final size of *0* will be discarded.
7979
If unset, none will be configured and the kernel's default will be used.<br />
8080
If more than one is given, and recompression is enabled in the kernel, subsequent ones will be set as the recompression algorithms, with decreasing priority.
8181

82-
If a compression algorithm is suffixed with a parenthesised comma-separated list of parameters, those are given to `.../algorithm_params` (and `.../recompress`).
83-
A parenthesised parameter list *without* a compression algorithm is set as the global recompression parameters.
82+
If a compression algorithm is suffixed with a parenthesised comma-separated list of parameters, those are given to `.../algorithm_params`.
83+
A parenthesised parameter list *without* a compression algorithm is set as the global recompression parameters (`.../recompress`).
8484

8585
* `writeback-device`=
8686

src/setup.rs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,39 +35,23 @@ pub fn run_device_setup(device: Option<Device>, device_name: &str) -> Result<()>
3535
.iter()
3636
.enumerate()
3737
{
38-
let params = if params.is_empty() {
39-
None
40-
} else {
41-
Some(params)
42-
};
43-
let (path, data, add_pathdata) = if prio == 0 {
38+
let (path, data) = if prio == 0 {
4439
(
4540
device_sysfs_path.join("comp_algorithm"),
4641
algo,
47-
params.as_ref().map(|p| {
48-
(
49-
device_sysfs_path.join("algorithm_params"),
50-
format!("algo={} {}", algo, p),
51-
)
52-
}),
5342
)
5443
} else {
5544
(
5645
device_sysfs_path.join("recomp_algorithm"),
5746
&format!("algo={} priority={}", algo, prio),
58-
params.as_ref().map(|p| {
59-
(
60-
device_sysfs_path.join("recompress"),
61-
format!("{} priority={}", p, prio),
62-
)
63-
}),
6447
)
6548
};
6649

6750
match fs::write(&path, data) {
6851
Ok(_) => {
69-
if let Some((add_path, add_data)) = add_pathdata {
70-
match fs::write(add_path, &add_data) {
52+
if !params.is_empty() {
53+
let add_data = format!("priority={} {}", prio, params);
54+
match fs::write(device_sysfs_path.join("algorithm_params"), &add_data) {
7155
Ok(_) => {}
7256
Err(err) => {
7357
warn!(

0 commit comments

Comments
 (0)