diff mbox series

[v2,2/2] fs/erofs: add support for creating EROFS rootfs image

Message ID 20200316015838.15183-2-hsiangkao@aol.com
State Accepted
Headers show
Series [v2,1/2] package/erofs-utils: new package | expand

Commit Message

Gao Xiang March 16, 2020, 1:58 a.m. UTC
This patch makes possible to create rootfs image using
EROFS filesystem.

Signed-off-by: Gao Xiang <hsiangkao@aol.com>
---
 fs/Config.in       |  1 +
 fs/erofs/Config.in | 24 ++++++++++++++++++++++++
 fs/erofs/erofs.mk  | 17 +++++++++++++++++
 3 files changed, 42 insertions(+)
 create mode 100644 fs/erofs/Config.in
 create mode 100644 fs/erofs/erofs.mk

Comments

Yann E. MORIN March 19, 2020, 5:49 p.m. UTC | #1
Gao, All,

On 2020-03-16 09:58 +0800, Gao Xiang spake thusly:
> This patch makes possible to create rootfs image using
> EROFS filesystem.
> 
> Signed-off-by: Gao Xiang <hsiangkao@aol.com>
> ---
[--SNIP--]
> diff --git a/fs/erofs/Config.in b/fs/erofs/Config.in
> new file mode 100644
> index 0000000000..dad2498a15
> --- /dev/null
> +++ b/fs/erofs/Config.in
> @@ -0,0 +1,24 @@
> +config BR2_TARGET_ROOTFS_EROFS
> +	bool "erofs root filesystem"
> +	select BR2_PACKAGE_HOST_EROFS_UTILS
> +	help
> +	  Build a EROFS root filesystem. If you enable this option,
> +	  you probably want to enable the erofs-utils package too.

Since erofs is a read-only filesystem, and since erofs-utils only
provide an mkfs tool, I don't see how erofs-utils would be useful on the
target. So I've dropped that part from the help text.

> +if BR2_TARGET_ROOTFS_EROFS
> +
> +choice
> +	prompt "Compression algorithm"
> +	default BR2_TARGET_ROOTFS_EROFS_LZ4HC
> +	help
> +	  Select the primary compression algorithm to use when
> +	  generating EROFS filesystem image.
> +
> +config BR2_TARGET_ROOTFS_EROFS_NONE
> +	bool "none"
> +
> +config BR2_TARGET_ROOTFS_EROFS_LZ4HC
> +	bool "lz4hc"

Do you envision adding other compression schemes? As far as I can see,
the erofs-utils as well as the linux driver only ever supports lz4 (and
I think you are well aware of that ;-) ).

I know the other filesystems (squashfs, jffs2...) have a choice about
the compression method, but for those ther are two or more such
possibilities, so it makes sense they have a choice. For erofs, not so
much.

As such, I have dropped the choice altogether, and just kept the single
boolean to enable compression.

Applied to master with the above changes. Thanks!

Regards,
Yann E. MORIN.

> +endchoice
> +endif # BR2_TARGET_ROOTFS_EROFS
> diff --git a/fs/erofs/erofs.mk b/fs/erofs/erofs.mk
> new file mode 100644
> index 0000000000..58559d4833
> --- /dev/null
> +++ b/fs/erofs/erofs.mk
> @@ -0,0 +1,17 @@
> +################################################################################
> +#
> +# Build the EROFS root filesystem image
> +#
> +################################################################################
> +
> +ROOTFS_EROFS_DEPENDENCIES = host-erofs-utils
> +
> +ifeq ($(BR2_TARGET_ROOTFS_EROFS_LZ4HC),y)
> +ROOTFS_EROFS_ARGS += -zlz4hc
> +endif
> +
> +define ROOTFS_EROFS_CMD
> +	$(HOST_DIR)/bin/mkfs.erofs $(ROOTFS_EROFS_ARGS) $@ $(TARGET_DIR)
> +endef
> +
> +$(eval $(rootfs))
> -- 
> 2.20.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Gao Xiang March 20, 2020, 7:13 a.m. UTC | #2
Hi Yann,

On Thu, Mar 19, 2020 at 06:49:42PM +0100, Yann E. MORIN wrote:
> Gao, All,
> 
> On 2020-03-16 09:58 +0800, Gao Xiang spake thusly:
> > This patch makes possible to create rootfs image using
> > EROFS filesystem.
> > 
> > Signed-off-by: Gao Xiang <hsiangkao@aol.com>
> > ---
> [--SNIP--]
> > diff --git a/fs/erofs/Config.in b/fs/erofs/Config.in
> > new file mode 100644
> > index 0000000000..dad2498a15
> > --- /dev/null
> > +++ b/fs/erofs/Config.in
> > @@ -0,0 +1,24 @@
> > +config BR2_TARGET_ROOTFS_EROFS
> > +	bool "erofs root filesystem"
> > +	select BR2_PACKAGE_HOST_EROFS_UTILS
> > +	help
> > +	  Build a EROFS root filesystem. If you enable this option,
> > +	  you probably want to enable the erofs-utils package too.
> 
> Since erofs is a read-only filesystem, and since erofs-utils only
> provide an mkfs tool, I don't see how erofs-utils would be useful on the
> target. So I've dropped that part from the help text.

Currently I agree with you. So that's fine. :)

> 
> > +if BR2_TARGET_ROOTFS_EROFS
> > +
> > +choice
> > +	prompt "Compression algorithm"
> > +	default BR2_TARGET_ROOTFS_EROFS_LZ4HC
> > +	help
> > +	  Select the primary compression algorithm to use when
> > +	  generating EROFS filesystem image.
> > +
> > +config BR2_TARGET_ROOTFS_EROFS_NONE
> > +	bool "none"
> > +
> > +config BR2_TARGET_ROOTFS_EROFS_LZ4HC
> > +	bool "lz4hc"
> 
> Do you envision adding other compression schemes? As far as I can see,
> the erofs-utils as well as the linux driver only ever supports lz4 (and
> I think you are well aware of that ;-) ).

I have been still working on support LZMA algorithm (a lot of work to
achieve LZMA fixed-sized output compression) in my spare time.

> 
> I know the other filesystems (squashfs, jffs2...) have a choice about
> the compression method, but for those ther are two or more such
> possibilities, so it makes sense they have a choice. For erofs, not so
> much.
> 
> As such, I have dropped the choice altogether, and just kept the single
> boolean to enable compression.

Currently, I'm fine with that as well. After LZMA algorithm is ready
upstream, I could submit another patch then.

> 
> Applied to master with the above changes. Thanks!

Thank you very much!

Thanks,
Gao Xiang

> 
> Regards,
> Yann E. MORIN.
>
Yann E. MORIN March 20, 2020, 8:20 p.m. UTC | #3
Gao, All,

On 2020-03-20 15:13 +0800, Gao Xiang spake thusly:
> On Thu, Mar 19, 2020 at 06:49:42PM +0100, Yann E. MORIN wrote:
[--SNIP--]
> > I know the other filesystems (squashfs, jffs2...) have a choice about
> > the compression method, but for those ther are two or more such
> > possibilities, so it makes sense they have a choice. For erofs, not so
> > much.
> > As such, I have dropped the choice altogether, and just kept the single
> > boolean to enable compression.
> Currently, I'm fine with that as well. After LZMA algorithm is ready
> upstream, I could submit another patch then.

Yes, the choice can then be reinstated, and that would even not break
existing configurations.

Regards,
Yann E. MORIN.
diff mbox series

Patch

diff --git a/fs/Config.in b/fs/Config.in
index 527051ef54..37a2aa21f8 100644
--- a/fs/Config.in
+++ b/fs/Config.in
@@ -5,6 +5,7 @@  source "fs/btrfs/Config.in"
 source "fs/cloop/Config.in"
 source "fs/cpio/Config.in"
 source "fs/cramfs/Config.in"
+source "fs/erofs/Config.in"
 source "fs/ext2/Config.in"
 source "fs/f2fs/Config.in"
 source "fs/initramfs/Config.in"
diff --git a/fs/erofs/Config.in b/fs/erofs/Config.in
new file mode 100644
index 0000000000..dad2498a15
--- /dev/null
+++ b/fs/erofs/Config.in
@@ -0,0 +1,24 @@ 
+config BR2_TARGET_ROOTFS_EROFS
+	bool "erofs root filesystem"
+	select BR2_PACKAGE_HOST_EROFS_UTILS
+	help
+	  Build a EROFS root filesystem. If you enable this option,
+	  you probably want to enable the erofs-utils package too.
+
+if BR2_TARGET_ROOTFS_EROFS
+
+choice
+	prompt "Compression algorithm"
+	default BR2_TARGET_ROOTFS_EROFS_LZ4HC
+	help
+	  Select the primary compression algorithm to use when
+	  generating EROFS filesystem image.
+
+config BR2_TARGET_ROOTFS_EROFS_NONE
+	bool "none"
+
+config BR2_TARGET_ROOTFS_EROFS_LZ4HC
+	bool "lz4hc"
+
+endchoice
+endif # BR2_TARGET_ROOTFS_EROFS
diff --git a/fs/erofs/erofs.mk b/fs/erofs/erofs.mk
new file mode 100644
index 0000000000..58559d4833
--- /dev/null
+++ b/fs/erofs/erofs.mk
@@ -0,0 +1,17 @@ 
+################################################################################
+#
+# Build the EROFS root filesystem image
+#
+################################################################################
+
+ROOTFS_EROFS_DEPENDENCIES = host-erofs-utils
+
+ifeq ($(BR2_TARGET_ROOTFS_EROFS_LZ4HC),y)
+ROOTFS_EROFS_ARGS += -zlz4hc
+endif
+
+define ROOTFS_EROFS_CMD
+	$(HOST_DIR)/bin/mkfs.erofs $(ROOTFS_EROFS_ARGS) $@ $(TARGET_DIR)
+endef
+
+$(eval $(rootfs))