summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Marko2026-05-21 11:42:26 +0000
committerRobert Marko2026-05-23 15:44:55 +0000
commit16718b6e3c0fc7db7be6ae5848db0eae88ac8a8b (patch)
tree957f4c8114bc97059388d9710a02910600ffa2cd
parent7df188543e26e70b179e649ec227a1dbe8489338 (diff)
downloadfstools-master.tar.gz
libfstools: mount f2fs overlay with zstd compressionHEADmaster
When fstools_overlay_compression_type is set to zstd, pass the f2fs compress_algorithm=zstd:3 mount option while mounting the overlay. Retry the f2fs overlay mount without compression if the compressed mount fails, so existing overlays without compression support can still boot. This pairs the runtime mount behavior with the mkfs.f2fs compression feature bits enabled during overlay formatting. Signed-off-by: Robert Marko <robert.marko@sartura.hr>
-rw-r--r--libfstools/overlay.c48
1 files changed, 36 insertions, 12 deletions
diff --git a/libfstools/overlay.c b/libfstools/overlay.c
index 7a7a95f..ce17a99 100644
--- a/libfstools/overlay.c
+++ b/libfstools/overlay.c
@@ -29,6 +29,7 @@
#include "libfstools.h"
#include "volume.h"
+#include "common.h"
#ifndef GLOB_ONLYDIR
#define GLOB_ONLYDIR 0x100
@@ -284,6 +285,26 @@ static char *overlay_fs_name(int type)
}
}
+static const char *overlay_mount_options(char *fstype)
+{
+ char typeparam[64];
+
+ if (!strcmp(fstype, "f2fs") &&
+ get_var_from_file("/proc/cmdline", "fstools_overlay_compression_type",
+ typeparam, sizeof(typeparam))) {
+ if (!strcmp(typeparam, "zstd")) {
+ ULOG_INFO("mounting f2fs overlay with zstd level 3 compression\n");
+ return "compress_algorithm=zstd:3";
+ }
+ }
+
+#ifdef OVL_MOUNT_COMPRESS_ZLIB
+ return "compr=zlib";
+#else
+ return NULL;
+#endif
+}
+
int
jffs2_switch(struct volume *v)
{
@@ -347,24 +368,27 @@ jffs2_switch(struct volume *v)
static int overlay_mount_fs(struct volume *v, const char *overlay_mp)
{
char *fstype = overlay_fs_name(volume_identify(v));
+ const char *options = overlay_mount_options(fstype);
+#ifdef OVL_MOUNT_FULL_ACCESS_TIME
+ unsigned long mount_flags = MS_RELATIME;
+#else
+ unsigned long mount_flags = MS_NOATIME;
+#endif
if (mkdir(overlay_mp, 0755)) {
ULOG_ERR("failed to mkdir /tmp/overlay: %m\n");
return -1;
}
- if (mount(v->blk, overlay_mp, fstype,
-#ifdef OVL_MOUNT_FULL_ACCESS_TIME
- MS_RELATIME,
-#else
- MS_NOATIME,
-#endif
-#ifdef OVL_MOUNT_COMPRESS_ZLIB
- "compr=zlib"
-#else
- NULL
-#endif
- )) {
+ if (mount(v->blk, overlay_mp, fstype, mount_flags, options)) {
+ if (!strcmp(fstype, "f2fs") && options) {
+ ULOG_WARN("failed to mount f2fs overlay with compression, "
+ "retrying without compression\n");
+
+ if (!mount(v->blk, overlay_mp, fstype, mount_flags, NULL))
+ return 0;
+ }
+
ULOG_ERR("failed to mount -t %s %s /tmp/overlay: %m\n",
fstype, v->blk);
return -1;