Skip to content

Commit

Permalink
If fail to set one of zswap_enabled zswap_compressor zswap_max_pool_p…
Browse files Browse the repository at this point in the history
…ercent zswap_zpool don't crash script, just ignore
  • Loading branch information
bigbruno committed Oct 18, 2024
1 parent 77905f6 commit 68a3393
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/systemd-swap.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,10 +641,16 @@ def start_zswap() -> None:
f'{config.get("zswap_max_pool_percent")}, Zpool: '
f'{config.get("zswap_zpool")}'
)
write(config.get("zswap_enabled"), f"{ZSWAP_M_P}/enabled")
write(config.get("zswap_compressor"), f"{ZSWAP_M_P}/compressor")
write(config.get("zswap_max_pool_percent"), f"{ZSWAP_M_P}/max_pool_percent")
write(config.get("zswap_zpool"), f"{ZSWAP_M_P}/zpool")
keys = ["zswap_enabled", "zswap_compressor", "zswap_max_pool_percent", "zswap_zpool"]
paths = ["enabled", "compressor", "max_pool_percent", "zpool"]

for key, path in zip(keys, paths):
try:
write(config.get(key), f"{ZSWAP_M_P}/{path}")
except Exception as e:
print(f"Fail to write '{key}': {e}")


info("Zswap: set new parameters: complete")

def start_zram() -> None:
Expand Down

0 comments on commit 68a3393

Please sign in to comment.