diff mbox series

[fstools] mount_root: support compression on F2FS rootfs

Message ID mailman.24915.1691062051.1880391.openwrt-devel@lists.openwrt.org
State New
Headers show
Series [fstools] mount_root: support compression on F2FS rootfs | expand

Commit Message

Robert Marko Aug. 3, 2023, 11:27 a.m. UTC
The sender domain has a DMARC Reject/Quarantine policy which disallows
sending mailing list messages using the original "From" header.

To mitigate this problem, the original message has been wrapped
automatically by the mailing list software.
Some devices dont utilize overlay but rather use F2FS backed RW rootfs
on eMMC and like.

F2FS does not provide space savings with compression but rather uses
compression to reduce writes and offer some small performance increases.

So, in order to prolong the eMMC life lets add a compile time option to
enable F2FS compression on rootfs mount.

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
---
 CMakeLists.txt | 16 ++++++++++++++++
 mount_root.c   | 14 +++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3421fec..eb605cb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,6 +66,22 @@  IF(DEFINED CMAKE_OVL_MOUNT_FULL_ACCESS_TIME)
 	ADD_DEFINITIONS(-DOVL_MOUNT_FULL_ACCESS_TIME)
 ENDIF(DEFINED CMAKE_OVL_MOUNT_FULL_ACCESS_TIME)
 
+IF(DEFINED CMAKE_F2FS_ROOTFS_MOUNT_COMPRESS_LZO)
+	ADD_DEFINITIONS(-DF2FS_ROOTFS_MOUNT_COMPRESS_LZO)
+ENDIF(DEFINED CMAKE_F2FS_ROOTFS_MOUNT_COMPRESS_LZO)
+
+IF(DEFINED CMAKE_F2FS_ROOTFS_MOUNT_COMPRESS_LZO_RLE)
+	ADD_DEFINITIONS(-DF2FS_ROOTFS_MOUNT_COMPRESS_LZO_RLE)
+ENDIF(DEFINED CMAKE_F2FS_ROOTFS_MOUNT_COMPRESS_LZO_RLE)
+
+IF(DEFINED CMAKE_F2FS_ROOTFS_MOUNT_COMPRESS_LZ4)
+	ADD_DEFINITIONS(-DF2FS_ROOTFS_MOUNT_COMPRESS_LZ4)
+ENDIF(DEFINED CMAKE_F2FS_ROOTFS_MOUNT_COMPRESS_LZ4)
+
+IF(DEFINED CMAKE_F2FS_ROOTFS_MOUNT_COMPRESS_ZSTD)
+	ADD_DEFINITIONS(-DF2FS_ROOTFS_MOUNT_COMPRESS_ZSTD)
+ENDIF(DEFINED CMAKE_F2FS_ROOTFS_MOUNT_COMPRESS_ZSTD)
+
 ADD_EXECUTABLE(mount_root mount_root.c)
 TARGET_LINK_LIBRARIES(mount_root fstools)
 INSTALL(TARGETS mount_root RUNTIME DESTINATION sbin)
diff --git a/mount_root.c b/mount_root.c
index d343909..912ac1c 100644
--- a/mount_root.c
+++ b/mount_root.c
@@ -41,7 +41,19 @@  start(int argc, char *argv[1])
 		root = volume_find("rootfs");
 		volume_init(root);
 		ULOG_NOTE("mounting /dev/root\n");
-		mount("/dev/root", "/", NULL, MS_NOATIME | MS_REMOUNT, 0);
+		mount("/dev/root", "/", NULL, MS_NOATIME | MS_REMOUNT,
+#ifdef F2FS_ROOTFS_MOUNT_COMPRESS_LZO
+		      "compress_algorithm=lzo"
+#elif defined F2FS_ROOTFS_MOUNT_COMPRESS_LZO_RLE
+		      "compress_algorithm=lzo-rle"
+#elif defined F2FS_ROOTFS_MOUNT_COMPRESS_LZ4
+		      "compress_algorithm=lz4"
+#elif defined F2FS_ROOTFS_MOUNT_COMPRESS_ZSTD
+		      "compress_algorithm=zstd"
+#else
+		      0
+#endif
+		      );
 	}
 
 	/* Check for extroot config in rootfs before even trying rootfs_data */