nefelim4ag / systemd-swap

Script for creating hybrid swap space from zram swaps, swap files and swap partitions.
GNU General Public License v3.0
550 stars 81 forks source link

Zram: If "Device or resource busy", retry exec zramctl #186

Closed robinzt closed 3 years ago

robinzt commented 3 years ago

Sometimes, systemd-swap produced error: TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

The cause is: If zramctl returned "failed to reset: Device or resource busy", systemd-swap just sleep 1 second but not retry exec zramctl.

So I change some code to retry exec zramctl when things happen.

The log:

systemd-swap[643]: INFO: Removing working directory...
systemd-swap[643]: INFO: Removing files in /var/lib/systemd-swap/swapfc/...
systemd-swap[643]: WARN: Combining zram with zswap/swapfc/swapd_auto_swapon can lead to LRU inversion and is strongly recommended against
systemd-swap[643]: INFO: Zram: check availability
systemd-swap[643]: INFO: Zram: not part of kernel, trying to find zram module
systemd-swap[643]: INFO: Zram: module successfully loaded
systemd-swap[643]: INFO: Zram: trying to initialize free device
systemd-swap[643]: Traceback (most recent call last):
systemd-swap[643]:   File "/usr/bin/systemd-swap", line 904, in <module>
systemd-swap[643]:     main()
systemd-swap[643]:   File "/usr/bin/systemd-swap", line 892, in main
systemd-swap[643]:     start()
systemd-swap[643]:   File "/usr/bin/systemd-swap", line 666, in start
systemd-swap[643]:     mode = os.stat(zram_dev).st_mode
systemd-swap[643]: TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
vilgotf commented 3 years ago

We should generally comment the code base better / refractor things as the python indentation syntax makes seeing when loops (etcetera) end hard