Skip to content

Commit f7fa414

Browse files
hsiangkaoAnsuel
authored andcommitted
image: add support for EROFS rootfs image generation
Add support for generating EROFS rootfs images. The EROFS filesystem can offer competitive I/O performance while minimizing final image size when using the MicroLZMA compressor. Target platform: linux-x86_generic (target-i386_pentium4_musl) Filesystem Image Size ============= ========== root.erofs 4882432 root.ext4 109051904 root.squashfs 4903302 Co-Developed-by: Gao Xiang <[email protected]> Signed-off-by: Gao Xiang <[email protected]> Link: openwrt/openwrt#19244 Signed-off-by: Christian Marangi <[email protected]>
1 parent 9ece943 commit f7fa414

File tree

8 files changed

+86
-0
lines changed

8 files changed

+86
-0
lines changed

config/Config-build.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ menu "Global build settings"
384384
config TARGET_ROOTFS_SECURITY_LABELS
385385
bool
386386
select KERNEL_SQUASHFS_XATTR
387+
select KERNEL_EROFS_FS_SECURITY
387388
select KERNEL_EXT4_FS_SECURITY
388389
select KERNEL_F2FS_FS_SECURITY
389390
select KERNEL_UBIFS_FS_SECURITY

config/Config-images.in

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,23 @@ menu "Target Images"
8787

8888
comment "Root filesystem images"
8989

90+
menuconfig TARGET_ROOTFS_EROFS
91+
bool "erofs"
92+
default y if USES_EROFS
93+
select KERNEL_EROFS_FS
94+
help
95+
Build a EROFS root filesystem.
96+
97+
config TARGET_EROFS_PCLUSTER_SIZE
98+
int "physical cluster size (in KiB)"
99+
depends on TARGET_ROOTFS_EROFS
100+
default 64 if LOW_MEMORY_FOOTPRINT
101+
default 1024 if (SMALL_FLASH && !LOW_MEMORY_FOOTPRINT)
102+
default 256
103+
help
104+
Specify the EROFS physical cluster size (must be equal
105+
to or a multiple of the filesystem block size).
106+
90107
menuconfig TARGET_ROOTFS_EXT4FS
91108
bool "ext4"
92109
default y if USES_EXT4

config/Config-kernel.in

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,23 @@ config KERNEL_BTRFS_FS
12781278
Say Y here if you want to make the kernel to be able to boot off a
12791279
BTRFS partition.
12801280

1281+
config KERNEL_EROFS_FS
1282+
bool "Compile the kernel with built-in EROFS support"
1283+
help
1284+
Say Y here if you want to make the kernel to be able to boot off a
1285+
EROFS partition.
1286+
1287+
config KERNEL_EROFS_FS_XATTR
1288+
bool "EROFS XATTR support"
1289+
1290+
config KERNEL_EROFS_FS_ZIP
1291+
bool
1292+
default y if KERNEL_EROFS_FS
1293+
1294+
config KERNEL_EROFS_FS_ZIP_LZMA
1295+
bool
1296+
default y if KERNEL_EROFS_FS
1297+
12811298
menu "Filesystem ACL and attr support options"
12821299
config USE_FS_ACL_ATTR
12831300
bool "Use filesystem ACL and attr support by default"
@@ -1298,6 +1315,11 @@ menu "Filesystem ACL and attr support options"
12981315
select KERNEL_FS_POSIX_ACL
12991316
default y if USE_FS_ACL_ATTR
13001317

1318+
config KERNEL_EROFS_FS_POSIX_ACL
1319+
bool "Enable POSIX ACL for EROFS Filesystems"
1320+
select KERNEL_FS_POSIX_ACL
1321+
default y if USE_FS_ACL_ATTR
1322+
13011323
config KERNEL_EXT4_FS_POSIX_ACL
13021324
bool "Enable POSIX ACL for Ext4 Filesystems"
13031325
select KERNEL_FS_POSIX_ACL
@@ -1440,6 +1462,11 @@ config KERNEL_LSM
14401462
default "lockdown,yama,loadpin,safesetid,integrity,selinux"
14411463
depends on KERNEL_SECURITY_SELINUX
14421464

1465+
config KERNEL_EROFS_FS_SECURITY
1466+
bool "EROFS Security Labels"
1467+
default y if !SMALL_FLASH
1468+
select KERNEL_EROFS_FS_XATTR
1469+
14431470
config KERNEL_EXT4_FS_SECURITY
14441471
bool "Ext4 Security Labels"
14451472
default y if !SMALL_FLASH

include/image.mk

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,22 @@ endif
9999

100100
JFFS2_BLOCKSIZE ?= 64k 128k
101101

102+
EROFS_PCLUSTERSIZE := $(shell echo $$(($(CONFIG_TARGET_EROFS_PCLUSTER_SIZE)*1024)))
103+
EROFSOPT := -C$(EROFS_PCLUSTERSIZE)
104+
EROFSOPT += -Efragments,dedupe,ztailpacking -Uclear --all-root
105+
EROFSOPT += $(if $(SOURCE_DATE_EPOCH),-T$(SOURCE_DATE_EPOCH) --ignore-mtime)
106+
EROFSOPT += $(if $(CONFIG_SELINUX),,-x-1)
107+
EROFSCOMP := lz4hc,12
108+
ifeq ($(CONFIG_EROFS_FS_ZIP_LZMA),y)
109+
EROFSCOMP := lzma,109
110+
endif
111+
102112
fs-types-$(CONFIG_TARGET_ROOTFS_SQUASHFS) += squashfs
103113
fs-types-$(CONFIG_TARGET_ROOTFS_JFFS2) += $(addprefix jffs2-,$(JFFS2_BLOCKSIZE))
104114
fs-types-$(CONFIG_TARGET_ROOTFS_JFFS2_NAND) += $(addprefix jffs2-nand-,$(NAND_BLOCKSIZE))
105115
fs-types-$(CONFIG_TARGET_ROOTFS_EXT4FS) += ext4
106116
fs-types-$(CONFIG_TARGET_ROOTFS_UBIFS) += ubifs
117+
fs-types-$(CONFIG_TARGET_ROOTFS_EROFS) += erofs
107118
fs-subtypes-$(CONFIG_TARGET_ROOTFS_JFFS2) += $(addsuffix -raw,$(addprefix jffs2-,$(JFFS2_BLOCKSIZE)))
108119

109120
TARGET_FILESYSTEMS := $(fs-types-y)
@@ -309,6 +320,12 @@ define Image/mkfs/ext4
309320
$@ $(call mkfs_target_dir,$(1))/
310321
endef
311322

323+
# Don't use the mkfs.erofs builtin $SOURCE_DATE_EPOCH behavior
324+
define Image/mkfs/erofs
325+
env -u SOURCE_DATE_EPOCH $(STAGING_DIR_HOST)/bin/mkfs.erofs -z$(EROFSCOMP) $(EROFSOPT) \
326+
$@ $(call mkfs_target_dir,$(1))
327+
endef
328+
312329
define Image/Manifest
313330
$(if $(CONFIG_USE_APK), \
314331
$(call apk,$(TARGET_DIR_ORIG)) list --quiet --manifest --no-network \

scripts/target-metadata.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ (@)
1818
/^dt$/ and $ret .= "\tselect USES_DEVICETREE\n";
1919
/^dt-overlay$/ and $ret .= "\tselect HAS_DT_OVERLAY_SUPPORT\n";
2020
/^emmc$/ and $ret .= "\tselect EMMC_SUPPORT\n";
21+
/^erofs$/ and $ret .= "\tselect USES_EROFS\n";
2122
/^ext4$/ and $ret .= "\tselect USES_EXT4\n";
2223
/^fpu$/ and $ret .= "\tselect HAS_FPU\n";
2324
/^gpio$/ and $ret .= "\tselect GPIO_SUPPORT\n";

target/Config.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ config USES_JFFS2_NAND
6969
config USES_EXT4
7070
bool
7171

72+
config USES_EROFS
73+
bool
74+
7275
config USES_TARGZ
7376
bool
7477

target/linux/generic/config-6.12

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,6 +1901,17 @@ CONFIG_ELFCORE=y
19011901
CONFIG_EPOLL=y
19021902
# CONFIG_EQUALIZER is not set
19031903
# CONFIG_EROFS_FS is not set
1904+
# CONFIG_EROFS_FS_DEBUG is not set
1905+
# CONFIG_EROFS_FS_XATTR is not set
1906+
# CONFIG_EROFS_FS_POSIX_ACL is not set
1907+
# CONFIG_EROFS_FS_SECURITY is not set
1908+
# CONFIG_EROFS_FS_BACKED_BY_FILE is not set
1909+
# CONFIG_EROFS_FS_ZIP is not set
1910+
# CONFIG_EROFS_FS_ZIP_DEFLATE is not set
1911+
# CONFIG_EROFS_FS_ZIP_ZSTD is not set
1912+
# CONFIG_EROFS_FS_ONDEMAND is not set
1913+
CONFIG_EROFS_FS_PCPU_KTHREAD=y
1914+
CONFIG_EROFS_FS_PCPU_KTHREAD_HIPRI=y
19041915
# CONFIG_ET131X is not set
19051916
CONFIG_ETHERNET=y
19061917
# CONFIG_ETHOC is not set

target/linux/generic/config-6.6

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,15 @@ CONFIG_ELFCORE=y
18401840
CONFIG_EPOLL=y
18411841
# CONFIG_EQUALIZER is not set
18421842
# CONFIG_EROFS_FS is not set
1843+
# CONFIG_EROFS_FS_DEBUG is not set
1844+
# CONFIG_EROFS_FS_XATTR is not set
1845+
# CONFIG_EROFS_FS_POSIX_ACL is not set
1846+
# CONFIG_EROFS_FS_SECURITY is not set
1847+
# CONFIG_EROFS_FS_ZIP is not set
1848+
# CONFIG_EROFS_FS_ZIP_DEFLATE is not set
1849+
# CONFIG_EROFS_FS_ONDEMAND is not set
1850+
CONFIG_EROFS_FS_PCPU_KTHREAD=y
1851+
CONFIG_EROFS_FS_PCPU_KTHREAD_HIPRI=y
18431852
# CONFIG_ET131X is not set
18441853
CONFIG_ETHERNET=y
18451854
# CONFIG_ETHOC is not set

0 commit comments

Comments
 (0)