diff --git a/man/zram-generator.conf.md b/man/zram-generator.conf.md index c3fc7d4..42e2166 100644 --- a/man/zram-generator.conf.md +++ b/man/zram-generator.conf.md @@ -79,8 +79,8 @@ Devices with the final size of *0* will be discarded. If unset, none will be configured and the kernel's default will be used.
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. - If a compression algorithm is suffixed with a parenthesised comma-separated list of parameters, those are given to `.../algorithm_params` (and `.../recompress`). - A parenthesised parameter list *without* a compression algorithm is set as the global recompression parameters. + If a compression algorithm is suffixed with a parenthesised comma-separated list of parameters, those are given to `.../algorithm_params`. + A parenthesised parameter list *without* a compression algorithm is set as the global recompression parameters (`.../recompress`). * `writeback-device`= diff --git a/src/setup.rs b/src/setup.rs index 22d16d8..3705ab2 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -35,39 +35,23 @@ pub fn run_device_setup(device: Option, device_name: &str) -> Result<()> .iter() .enumerate() { - let params = if params.is_empty() { - None - } else { - Some(params) - }; - let (path, data, add_pathdata) = if prio == 0 { + let (path, data) = if prio == 0 { ( device_sysfs_path.join("comp_algorithm"), algo, - params.as_ref().map(|p| { - ( - device_sysfs_path.join("algorithm_params"), - format!("algo={} {}", algo, p), - ) - }), ) } else { ( device_sysfs_path.join("recomp_algorithm"), &format!("algo={} priority={}", algo, prio), - params.as_ref().map(|p| { - ( - device_sysfs_path.join("recompress"), - format!("{} priority={}", p, prio), - ) - }), ) }; match fs::write(&path, data) { Ok(_) => { - if let Some((add_path, add_data)) = add_pathdata { - match fs::write(add_path, &add_data) { + if !params.is_empty() { + let add_data = format!("priority={} {}", prio, params); + match fs::write(device_sysfs_path.join("algorithm_params"), &add_data) { Ok(_) => {} Err(err) => { warn!(