zram-swap: enable swap discard
authorRui Salvaterra <rsalvaterra@gmail.com>
Tue, 23 Jun 2020 11:29:54 +0000 (12:29 +0100)
committerPetr Štetiar <ynezz@true.cz>
Sat, 11 Jul 2020 11:33:28 +0000 (13:33 +0200)
Zram block devices have supported trim/discard for over six years, let's
enable it. This allows the zram device to actually free up allocated memory
when it's marked as unused in the filesystem metadata, as explained in more
detail in the original commit message [1].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/drivers/block/zram/zram_drv.c?h=linux-4.14.y&id=f4659d8e620d08bd1a84a8aec5d2f5294a242764

Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
package/system/zram-swap/files/zram.init

index c855bbc087d2b8c86c270725f1533025e63ff9cd..a6126e578f1feee445a6b245f85c255aa0cf05f7 100755 (executable)
@@ -182,7 +182,7 @@ start()
        zram_comp_streams "$zram_dev"
        echo $(( $zram_size * 1024 * 1024 )) >"/sys/block/$( basename "$zram_dev" )/disksize"
        mkswap "$zram_dev"
-       swapon $zram_priority "$zram_dev"
+       swapon -d $zram_priority "$zram_dev"
 }
 
 stop()