v2 of the patch. uses lz4 compression by default. lz4 is always
installed by openwrt Makefile Config.in if zram.

lz4 is best for compressed filesystems as we all know (if you had to
choose between that and lzo).
zram-swap can keep using lzo for speed!

I'll work in a compatibility patch for zram-swap script next to see if
zram0 is already being used and hot-add a new device.
--- a/initd/zram.c	2016-07-03 06:39:51.011999930 +0700
+++ b/initd/zram.c	2016-07-03 07:00:34.143492847 +0700
@@ -82,7 +82,7 @@
 int
 mount_zram_on_tmp(void)
 {
-	char *mkfs[] = { "/usr/sbin/mkfs.ext4", "-b", "4096", "-F", "-L", "TEMP", "-m", "0", "/dev/zram0", NULL };
+	char *mkfs[] = { "/sbin/mkfs.ext2", "-b", "4096", "-F", "-L", "TEMP", "-m", "0", "/dev/zram0", NULL };
 	FILE *fp;
 	long zramsize;
 	pid_t pid;
@@ -94,6 +95,14 @@
 	}
 
 	mkdev("*", 0600);
+	
+	fp = fopen("/sys/block/zram0/comp_algorithm", "r+");
+	if (fp == NULL) {
+		ERROR("Can't open /sys/block/zram0/comp_algorithm: %s\n", strerror(errno));
+		return errno;
+	}
+	fprintf(fp, "%s", "lz4" );
+	fclose(fp);
 
 	zramsize = proc_meminfo() / 2;
 	fp = fopen("/sys/block/zram0/disksize", "r+");
@@ -107,10 +116,10 @@
 	pid = fork();
 	if (!pid) {
 		execvp(mkfs[0], mkfs);
-		ERROR("Can't exec /sbin/mkfs.ext4\n");
+		ERROR("Can't exec /sbin/mkfs.ext2\n");
 		exit(-1);
 	} else if (pid <= 0) {
-		ERROR("Can't exec /sbin/mkfs.ext4\n");
+		ERROR("Can't exec /sbin/mkfs.ext2\n");
 		return -1;
 	} else {
 		waitpid(pid, NULL, 0);
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to