Skip to contentSkip to conversation

fs/erofs: new filesystem

PATCH Superseded Huang Jianan 4 participants 30 messages Aug 22, 2021 – Feb 10, 2022

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 fs/erofs: new filesystem

From: Huang Jianan <[email protected]>

Add erofs filesystem support.

The code is adapted from erofs-utils in order to reduce maintenance burden and keep with the latest feature.

This patch mainly deals with uncompressed files.

---
 fs/Kconfig          |   1 +
 fs/Makefile         |   1 +
 fs/erofs/Kconfig    |  12 ++
 fs/erofs/Makefile   |   7 +
 fs/erofs/data.c     | 124 ++++++++++++++
 fs/erofs/erofs_fs.h | 384 ++++++++++++++++++++++++++++++++++++++++++++
 fs/erofs/fs.c       | 230 ++++++++++++++++++++++++++
 fs/erofs/internal.h | 203 +++++++++++++++++++++++
 fs/erofs/namei.c    | 238 +++++++++++++++++++++++++++
 fs/erofs/super.c    |  65 ++++++++
 fs/fs.c             |  22 +++
 include/erofs.h     |  19 +++
 include/fs.h        |   1 +
 13 files changed, 1307 insertions(+)
 create mode 100644 fs/erofs/Kconfig
 create mode 100644 fs/erofs/Makefile
 create mode 100644 fs/erofs/data.c
 create mode 100644 fs/erofs/erofs_fs.h
 create mode 100644 fs/erofs/fs.c
 create mode 100644 fs/erofs/internal.h
 create mode 100644 fs/erofs/namei.c
 create mode 100644 fs/erofs/super.c
 create mode 100644 include/erofs.h
fs/Kconfig +1 -0
index 620af7f044..4d04c2c2ce 100644
@@ -24,4 +24,5 @@ source "fs/yaffs2/Kconfig"
 
 source "fs/squashfs/Kconfig"
 
+source "fs/erofs/Kconfig"
 endmenu
fs/Makefile +1 -0
index 937cbcf6e8..f05a21c9e6 100644
@@ -25,5 +25,6 @@ obj-$(CONFIG_CMD_UBIFS) += ubifs/
 obj-$(CONFIG_YAFFS2) += yaffs2/
 obj-$(CONFIG_CMD_ZFS) += zfs/
 obj-$(CONFIG_FS_SQUASHFS) += squashfs/
+obj-$(CONFIG_FS_EROFS) += erofs/
 endif
 obj-y += fs_internal.o
fs/erofs/Kconfig new file +12 -0
new file mode 100644
index 0000000000..f4b2d51a23
@@ -0,0 +1,12 @@
+config FS_EROFS
+	bool "Enable EROFS filesystem support"
+	help
+	  This provides support for reading images from EROFS filesystem.
+	  EROFS (Enhanced Read-Only File System) is a lightweight read-only
+	  file system for scenarios which need high-performance read-only
+	  requirements.
+
+	  It also provides fixed-sized output compression support, which
+	  improves storage density, keeps relatively higher compression
+	  ratios, which is more useful to achieve high performance for
+	  embedded devices with limited memory.
fs/erofs/Makefile new file +7 -0
new file mode 100644
index 0000000000..7398ab7a36
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-$(CONFIG_$(SPL_)FS_EROFS) = fs.o \
+				super.o \
+				namei.o \
+				data.o
fs/erofs/data.c new file +124 -0

124 lines not on this page · raw message

fs/erofs/erofs_fs.h new file +384 -0

384 lines not on this page · raw message

fs/erofs/fs.c new file +230 -0

230 lines not on this page · raw message

fs/erofs/internal.h new file +203 -0

203 lines not on this page · raw message

fs/erofs/namei.c new file +238 -0

238 lines not on this page · raw message

fs/erofs/super.c new file +65 -0

65 lines not on this page · raw message

fs/fs.c +22 -0
index 7c682582c8..3c06b0252b 100644
@@ -26,6 +26,7 @@
 #include <linux/math64.h>
 #include <efi_loader.h>
 #include <squashfs.h>
+#include <erofs.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -304,6 +305,27 @@ static struct fstype_info fstypes[] = {
 		.unlink = fs_unlink_unsupported,
 		.mkdir = fs_mkdir_unsupported,
 	},
+#endif
+#if IS_ENABLED(CONFIG_FS_EROFS)
+	{
+		.fstype = FS_TYPE_EROFS,
+		.name = "erofs",
+		.null_dev_desc_ok = false,
+		.probe = erofs_probe,
+		.opendir = erofs_opendir,
+		.readdir = erofs_readdir,
+		.ls = fs_ls_generic,
+		.read = erofs_read,
+		.size = erofs_size,
+		.close = erofs_close,
+		.closedir = erofs_closedir,
+		.exists = erofs_exists,
+		.uuid = fs_uuid_unsupported,
+		.write = fs_write_unsupported,
+		.ln = fs_ln_unsupported,
+		.unlink = fs_unlink_unsupported,
+		.mkdir = fs_mkdir_unsupported,
+	},
 #endif
 	{
 		.fstype = FS_TYPE_ANY,
include/erofs.h new file +19 -0
new file mode 100644
index 0000000000..79de78257f
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _EROFS_H_
+#define _EROFS_H_
+
+struct disk_partition;
+
+int erofs_opendir(const char *filename, struct fs_dir_stream **dirsp);
+int erofs_readdir(struct fs_dir_stream *dirs, struct fs_dirent **dentp);
+int erofs_probe(struct blk_desc *fs_dev_desc,
+	       struct disk_partition *fs_partition);
+int erofs_read(const char *filename, void *buf, loff_t offset,
+	      loff_t len, loff_t *actread);
+int erofs_size(const char *filename, loff_t *size);
+int erofs_exists(const char *filename);
+void erofs_close(void);
+void erofs_closedir(struct fs_dir_stream *dirs);
+int erofs_uuid(char *uuid_str);
+
+#endif /* _EROFS_H  */
include/fs.h +1 -0
index 1c79e299fd..f96afc4c89 100644
@@ -17,6 +17,7 @@ struct cmd_tbl;
 #define FS_TYPE_UBIFS	4
 #define FS_TYPE_BTRFS	5
 #define FS_TYPE_SQUASHFS 6
+#define FS_TYPE_EROFS   7
 
 struct blk_desc;
 
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 2/3 fs/erofs: add lz4 1.8.3 decompressor

From: Huang Jianan <[email protected]>

In order to use the newest LZ4_decompress_safe_partial() which can now decode exactly the nb of bytes requested.

---
 fs/erofs/Makefile |   3 +-
 fs/erofs/lz4.c    | 534 ++++++++++++++++++++++++++++++++++++++++++++++
 fs/erofs/lz4.h    |   4 +
 3 files changed, 540 insertions(+), 1 deletion(-)
 create mode 100644 fs/erofs/lz4.c
 create mode 100644 fs/erofs/lz4.h
fs/erofs/Makefile +2 -1
index 7398ab7a36..c4fc5b794e 100644
@@ -4,4 +4,5 @@
 obj-$(CONFIG_$(SPL_)FS_EROFS) = fs.o \
 				super.o \
 				namei.o \
-				data.o
+				data.o \
+				lz4.o
fs/erofs/lz4.c new file +534 -0

534 lines not on this page · raw message

fs/erofs/lz4.h new file +4 -0
new file mode 100644
index 0000000000..0b4bdf4fbe
@@ -0,0 +1,4 @@
+int LZ4_decompress_safe(const char *source, char *dest,
+	int compressedSize, int maxDecompressedSize);
+int LZ4_decompress_safe_partial(const char *src, char *dst,
+	int compressedSize, int targetOutputSize, int dstCapacity);
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 3/3 fs/erofs: add lz4 decompression support

In reply to Huang Jianan

From: Huang Jianan <[email protected]>

Support EROFS lz4 compressed files.

---
 fs/erofs/Makefile     |   4 +-
 fs/erofs/data.c       |  84 ++++++-
 fs/erofs/decompress.c |  74 ++++++
 fs/erofs/decompress.h |  29 +++
 fs/erofs/namei.c      |   2 +-
 fs/erofs/zmap.c       | 517 ++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 707 insertions(+), 3 deletions(-)
 create mode 100644 fs/erofs/decompress.c
 create mode 100644 fs/erofs/decompress.h
 create mode 100644 fs/erofs/zmap.c
fs/erofs/Makefile +3 -1
index c4fc5b794e..8f1f99a096 100644
@@ -5,4 +5,6 @@ obj-$(CONFIG_$(SPL_)FS_EROFS) = fs.o \
 				super.o \
 				namei.o \
 				data.o \
-				lz4.o
+				lz4.o \
+				decompress.o \
+				zmap.o
fs/erofs/data.c +83 -1

101 lines not on this page · raw message

fs/erofs/decompress.c new file +74 -0

74 lines not on this page · raw message

fs/erofs/decompress.h new file +29 -0
new file mode 100644
index 0000000000..a12e11f386
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+#ifndef __EROFS_DECOMPRESS_H
+#define __EROFS_DECOMPRESS_H
+
+#include "internal.h"
+
+enum {
+	Z_EROFS_COMPRESSION_SHIFTED = Z_EROFS_COMPRESSION_MAX,
+	Z_EROFS_COMPRESSION_RUNTIME_MAX
+};
+
+struct z_erofs_decompress_req {
+	char *in, *out;
+
+	/*
+	 * initial decompressed bytes that need to be skipped
+	 * when finally copying to output buffer
+	 */
+	unsigned int decodedskip;
+	unsigned int inputsize, decodedlength;
+
+	/* indicate the algorithm will be used for decompression */
+	unsigned int alg;
+	bool partial_decoding;
+};
+
+int z_erofs_decompress(struct z_erofs_decompress_req *rq);
+
+#endif
fs/erofs/namei.c +1 -1
index 4c5d614483..7a0fbe2bc1 100644
@@ -101,7 +101,7 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi)
 
 	vi->flags = 0;
 	if (erofs_inode_is_data_compressed(vi->datalayout))
-		return -EOPNOTSUPP;
+		z_erofs_fill_inode(vi);
 	return 0;
 bogusimode:
 	erofs_err("bogus i_mode (%o) @ nid %llu", vi->i_mode, vi->nid | 0ULL);
fs/erofs/zmap.c new file +517 -0

517 lines not on this page · raw message

Signature · 1 line
2.25.1
#3 lore raw
In reply to Huang Jianan
Quoted 11 lines · Huang Jianan

From: Huang Jianan <[email protected]>

Add erofs filesystem support.

The code is adapted from erofs-utils in order to reduce maintenance burden and keep with the latest feature.

This patch mainly deals with uncompressed files.

From and SoB should be the same person.

Quoted 16 lines
---
 fs/Kconfig          |   1 +
 fs/Makefile         |   1 +
 fs/erofs/Kconfig    |  12 ++
 fs/erofs/Makefile   |   7 +
 fs/erofs/data.c     | 124 ++++++++++++++
 fs/erofs/erofs_fs.h | 384 ++++++++++++++++++++++++++++++++++++++++++++
 fs/erofs/fs.c       | 230 ++++++++++++++++++++++++++
 fs/erofs/internal.h | 203 +++++++++++++++++++++++
 fs/erofs/namei.c    | 238 +++++++++++++++++++++++++++
 fs/erofs/super.c    |  65 ++++++++
 fs/fs.c             |  22 +++
 include/erofs.h     |  19 +++
 include/fs.h        |   1 +
 13 files changed, 1307 insertions(+)
 create mode 100644 fs/erofs/Kconfig
Quoted 9 lines
 create mode 100644 fs/erofs/Makefile
 create mode 100644 fs/erofs/data.c
 create mode 100644 fs/erofs/erofs_fs.h
 create mode 100644 fs/erofs/fs.c
 create mode 100644 fs/erofs/internal.h
 create mode 100644 fs/erofs/namei.c
 create mode 100644 fs/erofs/super.c
 create mode 100644 include/erofs.h

Regards,
Bin

#4 lore raw
Quoted 5 lines · Bin Meng
Quoted 4 lines · Huang Jianan

From: Huang Jianan <[email protected]>

Add erofs filesystem support.

Quoted 7 lines
Quoted 6 lines

The code is adapted from erofs-utils in order to reduce maintenance burden and keep with the latest feature.

This patch mainly deals with uncompressed files.

From and SoB should be the same person.

Thanks for pointing this out,I will update soon.

Quoted 27 lines
Quoted 15 lines
---
  fs/Kconfig          |   1 +
  fs/Makefile         |   1 +
  fs/erofs/Kconfig    |  12 ++
  fs/erofs/Makefile   |   7 +
  fs/erofs/data.c     | 124 ++++++++++++++
  fs/erofs/erofs_fs.h | 384 ++++++++++++++++++++++++++++++++++++++++++++
  fs/erofs/fs.c       | 230 ++++++++++++++++++++++++++
  fs/erofs/internal.h | 203 +++++++++++++++++++++++
  fs/erofs/namei.c    | 238 +++++++++++++++++++++++++++
  fs/erofs/super.c    |  65 ++++++++
  fs/fs.c             |  22 +++
  include/erofs.h     |  19 +++
  include/fs.h        |   1 +
  13 files changed, 1307 insertions(+)
Quoted 10 lines

create mode 100644 fs/erofs/Kconfig
create mode 100644 fs/erofs/Makefile
create mode 100644 fs/erofs/data.c
create mode 100644 fs/erofs/erofs_fs.h
create mode 100644 fs/erofs/fs.c
create mode 100644 fs/erofs/internal.h
create mode 100644 fs/erofs/namei.c
create mode 100644 fs/erofs/super.c
create mode 100644 include/erofs.h

Regards,
Bin

#5 lore raw

v2 cover fs/erofs: new filesystem

In reply to Huang Jianan

From: Huang Jianan <[email protected]>

Add erofs filesystem support.

The code is adapted from erofs-utils in order to reduce maintenance burden and keep with the latest feature.

Changes since v1:
- fix the inconsistency between From and SoB (Bin Meng);
- add missing license header;

Huang Jianan (3):
fs/erofs: add erofs filesystem support
fs/erofs: add lz4 1.8.3 decompressor
fs/erofs: add lz4 decompression support

 fs/Kconfig            |   1 +
 fs/Makefile           |   1 +
 fs/erofs/Kconfig      |  12 +
 fs/erofs/Makefile     |  10 +
 fs/erofs/data.c       | 206 ++++++++++++++++
 fs/erofs/decompress.c |  74 ++++++
 fs/erofs/decompress.h |  29 +++
 fs/erofs/erofs_fs.h   | 384 ++++++++++++++++++++++++++++++
 fs/erofs/fs.c         | 231 ++++++++++++++++++
 fs/erofs/internal.h   | 203 ++++++++++++++++
 fs/erofs/lz4.c        | 534 ++++++++++++++++++++++++++++++++++++++++++
 fs/erofs/lz4.h        |   5 +
 fs/erofs/namei.c      | 238 +++++++++++++++++++
 fs/erofs/super.c      |  65 +++++
 fs/erofs/zmap.c       | 517 ++++++++++++++++++++++++++++++++++++++++
 fs/fs.c               |  22 ++
 include/erofs.h       |  19 ++
 include/fs.h          |   1 +
 18 files changed, 2552 insertions(+)
 create mode 100644 fs/erofs/Kconfig
 create mode 100644 fs/erofs/Makefile
 create mode 100644 fs/erofs/data.c
 create mode 100644 fs/erofs/decompress.c
 create mode 100644 fs/erofs/decompress.h
 create mode 100644 fs/erofs/erofs_fs.h
 create mode 100644 fs/erofs/fs.c
 create mode 100644 fs/erofs/internal.h
 create mode 100644 fs/erofs/lz4.c
 create mode 100644 fs/erofs/lz4.h
 create mode 100644 fs/erofs/namei.c
 create mode 100644 fs/erofs/super.c
 create mode 100644 fs/erofs/zmap.c
 create mode 100644 include/erofs.h
Signature · 1 line
2.25.1
#6 lore raw

PATCH v2 1/3 fs/erofs: add erofs filesystem support

From: Huang Jianan <[email protected]>

This patch mainly deals with uncompressed files.

---
 fs/Kconfig          |   1 +
 fs/Makefile         |   1 +
 fs/erofs/Kconfig    |  12 ++
 fs/erofs/Makefile   |   7 +
 fs/erofs/data.c     | 124 ++++++++++++++
 fs/erofs/erofs_fs.h | 384 ++++++++++++++++++++++++++++++++++++++++++++
 fs/erofs/fs.c       | 231 ++++++++++++++++++++++++++
 fs/erofs/internal.h | 203 +++++++++++++++++++++++
 fs/erofs/namei.c    | 238 +++++++++++++++++++++++++++
 fs/erofs/super.c    |  65 ++++++++
 fs/fs.c             |  22 +++
 include/erofs.h     |  19 +++
 include/fs.h        |   1 +
 13 files changed, 1308 insertions(+)
 create mode 100644 fs/erofs/Kconfig
 create mode 100644 fs/erofs/Makefile
 create mode 100644 fs/erofs/data.c
 create mode 100644 fs/erofs/erofs_fs.h
 create mode 100644 fs/erofs/fs.c
 create mode 100644 fs/erofs/internal.h
 create mode 100644 fs/erofs/namei.c
 create mode 100644 fs/erofs/super.c
 create mode 100644 include/erofs.h
fs/Kconfig +1 -0
index 620af7f044..4d04c2c2ce 100644
@@ -24,4 +24,5 @@ source "fs/yaffs2/Kconfig"
 
 source "fs/squashfs/Kconfig"
 
+source "fs/erofs/Kconfig"
 endmenu
fs/Makefile +1 -0
index 937cbcf6e8..f05a21c9e6 100644
@@ -25,5 +25,6 @@ obj-$(CONFIG_CMD_UBIFS) += ubifs/
 obj-$(CONFIG_YAFFS2) += yaffs2/
 obj-$(CONFIG_CMD_ZFS) += zfs/
 obj-$(CONFIG_FS_SQUASHFS) += squashfs/
+obj-$(CONFIG_FS_EROFS) += erofs/
 endif
 obj-y += fs_internal.o
fs/erofs/Kconfig new file +12 -0
new file mode 100644
index 0000000000..f4b2d51a23
@@ -0,0 +1,12 @@
+config FS_EROFS
+	bool "Enable EROFS filesystem support"
+	help
+	  This provides support for reading images from EROFS filesystem.
+	  EROFS (Enhanced Read-Only File System) is a lightweight read-only
+	  file system for scenarios which need high-performance read-only
+	  requirements.
+
+	  It also provides fixed-sized output compression support, which
+	  improves storage density, keeps relatively higher compression
+	  ratios, which is more useful to achieve high performance for
+	  embedded devices with limited memory.
fs/erofs/Makefile new file +7 -0
new file mode 100644
index 0000000000..7398ab7a36
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-$(CONFIG_$(SPL_)FS_EROFS) = fs.o \
+				super.o \
+				namei.o \
+				data.o
fs/erofs/data.c new file +124 -0

124 lines not on this page · raw message

fs/erofs/erofs_fs.h new file +384 -0

384 lines not on this page · raw message

fs/erofs/fs.c new file +231 -0

231 lines not on this page · raw message

fs/erofs/internal.h new file +203 -0

203 lines not on this page · raw message

fs/erofs/namei.c new file +238 -0

238 lines not on this page · raw message

fs/erofs/super.c new file +65 -0

65 lines not on this page · raw message

fs/fs.c +22 -0
index 7c682582c8..3c06b0252b 100644
@@ -26,6 +26,7 @@
 #include <linux/math64.h>
 #include <efi_loader.h>
 #include <squashfs.h>
+#include <erofs.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -304,6 +305,27 @@ static struct fstype_info fstypes[] = {
 		.unlink = fs_unlink_unsupported,
 		.mkdir = fs_mkdir_unsupported,
 	},
+#endif
+#if IS_ENABLED(CONFIG_FS_EROFS)
+	{
+		.fstype = FS_TYPE_EROFS,
+		.name = "erofs",
+		.null_dev_desc_ok = false,
+		.probe = erofs_probe,
+		.opendir = erofs_opendir,
+		.readdir = erofs_readdir,
+		.ls = fs_ls_generic,
+		.read = erofs_read,
+		.size = erofs_size,
+		.close = erofs_close,
+		.closedir = erofs_closedir,
+		.exists = erofs_exists,
+		.uuid = fs_uuid_unsupported,
+		.write = fs_write_unsupported,
+		.ln = fs_ln_unsupported,
+		.unlink = fs_unlink_unsupported,
+		.mkdir = fs_mkdir_unsupported,
+	},
 #endif
 	{
 		.fstype = FS_TYPE_ANY,
include/erofs.h new file +19 -0
new file mode 100644
index 0000000000..79de78257f
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _EROFS_H_
+#define _EROFS_H_
+
+struct disk_partition;
+
+int erofs_opendir(const char *filename, struct fs_dir_stream **dirsp);
+int erofs_readdir(struct fs_dir_stream *dirs, struct fs_dirent **dentp);
+int erofs_probe(struct blk_desc *fs_dev_desc,
+	       struct disk_partition *fs_partition);
+int erofs_read(const char *filename, void *buf, loff_t offset,
+	      loff_t len, loff_t *actread);
+int erofs_size(const char *filename, loff_t *size);
+int erofs_exists(const char *filename);
+void erofs_close(void);
+void erofs_closedir(struct fs_dir_stream *dirs);
+int erofs_uuid(char *uuid_str);
+
+#endif /* _EROFS_H  */
include/fs.h +1 -0
index 1c79e299fd..f96afc4c89 100644
@@ -17,6 +17,7 @@ struct cmd_tbl;
 #define FS_TYPE_UBIFS	4
 #define FS_TYPE_BTRFS	5
 #define FS_TYPE_SQUASHFS 6
+#define FS_TYPE_EROFS   7
 
 struct blk_desc;
 
Signature · 1 line
2.25.1
#7 lore raw

Re: [PATCH v2 1/3] fs/erofs: add erofs filesystem support

Quoted 21 lines · Huang Jianan

From: Huang Jianan <[email protected]>

This patch mainly deals with uncompressed files.

---
 fs/Kconfig          |   1 +
 fs/Makefile         |   1 +
 fs/erofs/Kconfig    |  12 ++
 fs/erofs/Makefile   |   7 +
 fs/erofs/data.c     | 124 ++++++++++++++
 fs/erofs/erofs_fs.h | 384 ++++++++++++++++++++++++++++++++++++++++++++
 fs/erofs/fs.c       | 231 ++++++++++++++++++++++++++
 fs/erofs/internal.h | 203 +++++++++++++++++++++++
 fs/erofs/namei.c    | 238 +++++++++++++++++++++++++++
 fs/erofs/super.c    |  65 ++++++++
 fs/fs.c             |  22 +++
 include/erofs.h     |  19 +++
 include/fs.h        |   1 +
 13 files changed, 1308 insertions(+)
 create mode 100644 fs/erofs/Kconfig
Quoted 8 lines
 create mode 100644 fs/erofs/Makefile
 create mode 100644 fs/erofs/data.c
 create mode 100644 fs/erofs/erofs_fs.h
 create mode 100644 fs/erofs/fs.c
 create mode 100644 fs/erofs/internal.h
 create mode 100644 fs/erofs/namei.c
 create mode 100644 fs/erofs/super.c
 create mode 100644 include/erofs.h

Do the style problems checkpatch.pl complains about here match what's in the linux kernel? I expect at lease some of them come from using custom debug/etc macros rather than the standard logging functions. Thanks.

Signature · 1 line
Tom
#8 lore raw

Re: [PATCH v2 1/3] fs/erofs: add erofs filesystem support

Quoted 31 lines · Tom Rini
Quoted 20 lines · Huang Jianan

From: Huang Jianan <[email protected]>

This patch mainly deals with uncompressed files.

---
  fs/Kconfig          |   1 +
  fs/Makefile         |   1 +
  fs/erofs/Kconfig    |  12 ++
  fs/erofs/Makefile   |   7 +
  fs/erofs/data.c     | 124 ++++++++++++++
  fs/erofs/erofs_fs.h | 384 ++++++++++++++++++++++++++++++++++++++++++++
  fs/erofs/fs.c       | 231 ++++++++++++++++++++++++++
  fs/erofs/internal.h | 203 +++++++++++++++++++++++
  fs/erofs/namei.c    | 238 +++++++++++++++++++++++++++
  fs/erofs/super.c    |  65 ++++++++
  fs/fs.c             |  22 +++
  include/erofs.h     |  19 +++
  include/fs.h        |   1 +
  13 files changed, 1308 insertions(+)
Quoted 9 lines

create mode 100644 fs/erofs/Kconfig
create mode 100644 fs/erofs/Makefile
create mode 100644 fs/erofs/data.c
create mode 100644 fs/erofs/erofs_fs.h
create mode 100644 fs/erofs/fs.c
create mode 100644 fs/erofs/internal.h
create mode 100644 fs/erofs/namei.c
create mode 100644 fs/erofs/super.c
create mode 100644 include/erofs.h

Quoted 3 lines

Do the style problems checkpatch.pl complains about here match what's in the linux kernel? I expect at lease some of them come from using custom debug/etc macros rather than the standard logging functions. Thanks.

The code is mainly come from erofs-utils, thems it has the same problem, i will fix it ASAP.

Thanks,
Jianan

#9 lore raw

Re: [PATCH v2 1/3] fs/erofs: add erofs filesystem support

Quoted 39 lines · Huang Jianan
Quoted 32 lines · Tom Rini
Quoted 21 lines · Huang Jianan

From: Huang Jianan <[email protected]>

This patch mainly deals with uncompressed files.

---
  fs/Kconfig          |   1 +
  fs/Makefile         |   1 +
  fs/erofs/Kconfig    |  12 ++ fs/erofs/Makefile   |   7 +
  fs/erofs/data.c     | 124 ++++++++++++++ fs/erofs/erofs_fs.h | 384
++++++++++++++++++++++++++++++++++++++++++++
  fs/erofs/fs.c       | 231 ++++++++++++++++++++++++++ fs/erofs/internal.h | 203 +++++++++++++++++++++++ fs/erofs/namei.c    | 238 +++++++++++++++++++++++++++ fs/erofs/super.c    |  65 ++++++++
  fs/fs.c             |  22 +++ include/erofs.h     |  19 +++
  include/fs.h        |   1 +

  13 files changed, 1308 insertions(+)
Quoted 9 lines

  create mode 100644 fs/erofs/Kconfig
  create mode 100644 fs/erofs/Makefile
  create mode 100644 fs/erofs/data.c
  create mode 100644 fs/erofs/erofs_fs.h
  create mode 100644 fs/erofs/fs.c
  create mode 100644 fs/erofs/internal.h
  create mode 100644 fs/erofs/namei.c
  create mode 100644 fs/erofs/super.c
  create mode 100644 include/erofs.h

Quoted 3 lines

Do the style problems checkpatch.pl complains about here match what's in the linux kernel?  I expect at lease some of them come from using custom debug/etc macros rather than the standard logging functions. Thanks.

Quoted 6 lines

The code is mainly come from erofs-utils, thems it has the same problem, i will fix it ASAP.

Thanks,
Jianan

I have checked checkpatch.pl complains, some need to be fixed, and some come frome using custom macros. It seems that there are still some warnings that are inconsistent with the linux kernel, such as :

WARNING: Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible
#835: FILE: fs/erofs/fs.c:224:
+#ifdef CONFIG_LIB_UUID

WARNING: Possible switch case/default not preceded by break or fallthrough comment
#763: FILE: fs/erofs/zmap.c:489:
+       case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD:

erofs-utils is written according to the linux kernel coding style, I expect this part can be consistent in order to reduce maintenance burden and keep with the latest feature.

#10 lore raw

Re: [PATCH v2 1/3] fs/erofs: add erofs filesystem support

Quoted 61 lines · Huang Jianan
Quoted 39 lines · Huang Jianan
Quoted 32 lines · Tom Rini
Quoted 21 lines · Huang Jianan

From: Huang Jianan <[email protected]>

This patch mainly deals with uncompressed files.

---
  fs/Kconfig          |   1 +
  fs/Makefile         |   1 +
  fs/erofs/Kconfig    |  12 ++ fs/erofs/Makefile   |   7 +
  fs/erofs/data.c     | 124 ++++++++++++++ fs/erofs/erofs_fs.h | 384
++++++++++++++++++++++++++++++++++++++++++++
  fs/erofs/fs.c       | 231 ++++++++++++++++++++++++++ fs/erofs/internal.h | 203 +++++++++++++++++++++++ fs/erofs/namei.c    | 238 +++++++++++++++++++++++++++ fs/erofs/super.c    |  65 ++++++++
  fs/fs.c             |  22 +++ include/erofs.h     |  19 +++
  include/fs.h        |   1 +

  13 files changed, 1308 insertions(+)
Quoted 9 lines

  create mode 100644 fs/erofs/Kconfig
  create mode 100644 fs/erofs/Makefile
  create mode 100644 fs/erofs/data.c
  create mode 100644 fs/erofs/erofs_fs.h
  create mode 100644 fs/erofs/fs.c
  create mode 100644 fs/erofs/internal.h
  create mode 100644 fs/erofs/namei.c
  create mode 100644 fs/erofs/super.c
  create mode 100644 include/erofs.h

Quoted 3 lines

Do the style problems checkpatch.pl complains about here match what's in the linux kernel?  I expect at lease some of them come from using custom debug/etc macros rather than the standard logging functions. Thanks.

Quoted 7 lines

The code is mainly come from erofs-utils, thems it has the same problem, i
will fix it ASAP.

Thanks,
Jianan

I have checked checkpatch.pl complains, some need to be fixed, and some come frome using custom macros. It seems that there are still some warnings that are inconsistent with the linux kernel, such as :

WARNING: Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible
#835: FILE: fs/erofs/fs.c:224:
+#ifdef CONFIG_LIB_UUID

WARNING: Possible switch case/default not preceded by break or fallthrough comment
#763: FILE: fs/erofs/zmap.c:489:
+       case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD:

Quoted 4 lines

erofs-utils is written according to the linux kernel coding style, I expect this
part can be consistent in order to reduce maintenance burden and keep with the latest feature.

Yes, please fix what can be easily fixed and still kept in sync with other projects.

Signature · 1 line
Tom
#11 lore raw

Re: [PATCH v2 1/3] fs/erofs: add erofs filesystem support

Quoted 62 lines · Tom Rini
Quoted 61 lines · Huang Jianan
Quoted 39 lines · Huang Jianan
Quoted 32 lines · Tom Rini
Quoted 21 lines · Huang Jianan

From: Huang Jianan <[email protected]>

This patch mainly deals with uncompressed files.

---
  fs/Kconfig          |   1 +
  fs/Makefile         |   1 +
  fs/erofs/Kconfig    |  12 ++ fs/erofs/Makefile   |   7 +
  fs/erofs/data.c     | 124 ++++++++++++++ fs/erofs/erofs_fs.h | 384
++++++++++++++++++++++++++++++++++++++++++++
  fs/erofs/fs.c       | 231 ++++++++++++++++++++++++++ fs/erofs/internal.h | 203 +++++++++++++++++++++++ fs/erofs/namei.c    | 238 +++++++++++++++++++++++++++ fs/erofs/super.c    |  65 ++++++++
  fs/fs.c             |  22 +++ include/erofs.h     |  19 +++
  include/fs.h        |   1 +

  13 files changed, 1308 insertions(+)
Quoted 9 lines

  create mode 100644 fs/erofs/Kconfig
  create mode 100644 fs/erofs/Makefile
  create mode 100644 fs/erofs/data.c
  create mode 100644 fs/erofs/erofs_fs.h
  create mode 100644 fs/erofs/fs.c
  create mode 100644 fs/erofs/internal.h
  create mode 100644 fs/erofs/namei.c
  create mode 100644 fs/erofs/super.c
  create mode 100644 include/erofs.h

Quoted 3 lines

Do the style problems checkpatch.pl complains about here match what's in the linux kernel?  I expect at lease some of them come from using custom debug/etc macros rather than the standard logging functions. Thanks.

Quoted 7 lines

The code is mainly come from erofs-utils, thems it has the same problem, i
will fix it ASAP.

Thanks,
Jianan

I have checked checkpatch.pl complains, some need to be fixed, and some come frome using custom macros. It seems that there are still some warnings that are inconsistent with the linux kernel, such as :

WARNING: Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible
#835: FILE: fs/erofs/fs.c:224:
+#ifdef CONFIG_LIB_UUID

WARNING: Possible switch case/default not preceded by break or fallthrough comment
#763: FILE: fs/erofs/zmap.c:489:
+       case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD:

Quoted 7 lines
Quoted 4 lines

erofs-utils is written according to the linux kernel coding style, I expect this
part can be consistent in order to reduce maintenance burden and keep with the latest feature.

Yes, please fix what can be easily fixed and still kept in sync with other projects.

Agreed, erofs-utils follows linux kernel style. Maybe we could fix both together if easily fixed...

Thanks,
Gao Xiang

Quoted 3 lines
Signature · 2 lines
-- 
Tom
#12 lore raw

PATCH v2 2/3 fs/erofs: add lz4 1.8.3 decompressor

In reply to Huang Jianan

From: Huang Jianan <[email protected]>

In order to use the newest LZ4_decompress_safe_partial() which can now decode exactly the nb of bytes requested.

---
 fs/erofs/Makefile |   3 +-
 fs/erofs/lz4.c    | 534 ++++++++++++++++++++++++++++++++++++++++++++++
 fs/erofs/lz4.h    |   5 +
 3 files changed, 541 insertions(+), 1 deletion(-)
 create mode 100644 fs/erofs/lz4.c
 create mode 100644 fs/erofs/lz4.h
fs/erofs/Makefile +2 -1
index 7398ab7a36..c4fc5b794e 100644
@@ -4,4 +4,5 @@
 obj-$(CONFIG_$(SPL_)FS_EROFS) = fs.o \
 				super.o \
 				namei.o \
-				data.o
+				data.o \
+				lz4.o
fs/erofs/lz4.c new file +534 -0

534 lines not on this page · raw message

fs/erofs/lz4.h new file +5 -0
new file mode 100644
index 0000000000..0467a348e1
@@ -0,0 +1,5 @@
+/* SPDX-License-Identifier: GPL 2.0+ OR BSD-2-Clause */
+int LZ4_decompress_safe(const char *source, char *dest,
+	int compressedSize, int maxDecompressedSize);
+int LZ4_decompress_safe_partial(const char *src, char *dst,
+	int compressedSize, int targetOutputSize, int dstCapacity);
Signature · 1 line
2.25.1
#13 lore raw

Re: [PATCH v2 2/3] fs/erofs: add lz4 1.8.3 decompressor

Quoted 5 lines · Huang Jianan

From: Huang Jianan <[email protected]>

In order to use the newest LZ4_decompress_safe_partial() which can now decode exactly the nb of bytes requested.

Quoted 8 lines
---
 fs/erofs/Makefile |   3 +-
 fs/erofs/lz4.c    | 534 ++++++++++++++++++++++++++++++++++++++++++++++
 fs/erofs/lz4.h    |   5 +
 3 files changed, 541 insertions(+), 1 deletion(-)
 create mode 100644 fs/erofs/lz4.c
 create mode 100644 fs/erofs/lz4.h

Why not use the existing lz4 support, or if it needs updating for new features, update it?

Signature · 1 line
Tom
#14 lore raw

Re: [PATCH v2 2/3] fs/erofs: add lz4 1.8.3 decompressor

Quoted 15 lines · Tom Rini
Quoted 5 lines · Huang Jianan

From: Huang Jianan <[email protected]>

In order to use the newest LZ4_decompress_safe_partial() which can now decode exactly the nb of bytes requested.

Quoted 8 lines
---
  fs/erofs/Makefile |   3 +-
  fs/erofs/lz4.c    | 534 ++++++++++++++++++++++++++++++++++++++++++++++
  fs/erofs/lz4.h    |   5 +
  3 files changed, 541 insertions(+), 1 deletion(-)

create mode 100644 fs/erofs/lz4.c
create mode 100644 fs/erofs/lz4.h

Quoted 2 lines

Why not use the existing lz4 support, or if it needs updating for new features, update it?

erofs use lz4 partial decompress, this feature is fully supported after lz4 1.8.3, I will try to upgrade the existing one.

Thanks,
Jianan

#15 lore raw

PATCH v2 3/3 fs/erofs: add lz4 decompression support

In reply to Huang Jianan

From: Huang Jianan <[email protected]>

Support EROFS lz4 compressed files.

---
 fs/erofs/Makefile     |   4 +-
 fs/erofs/data.c       |  84 ++++++-
 fs/erofs/decompress.c |  74 ++++++
 fs/erofs/decompress.h |  29 +++
 fs/erofs/namei.c      |   2 +-
 fs/erofs/zmap.c       | 517 ++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 707 insertions(+), 3 deletions(-)
 create mode 100644 fs/erofs/decompress.c
 create mode 100644 fs/erofs/decompress.h
 create mode 100644 fs/erofs/zmap.c
fs/erofs/Makefile +3 -1
index c4fc5b794e..8f1f99a096 100644
@@ -5,4 +5,6 @@ obj-$(CONFIG_$(SPL_)FS_EROFS) = fs.o \
 				super.o \
 				namei.o \
 				data.o \
-				lz4.o
+				lz4.o \
+				decompress.o \
+				zmap.o
fs/erofs/data.c +83 -1

101 lines not on this page · raw message

fs/erofs/decompress.c new file +74 -0

74 lines not on this page · raw message

fs/erofs/decompress.h new file +29 -0
new file mode 100644
index 0000000000..a12e11f386
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+#ifndef __EROFS_DECOMPRESS_H
+#define __EROFS_DECOMPRESS_H
+
+#include "internal.h"
+
+enum {
+	Z_EROFS_COMPRESSION_SHIFTED = Z_EROFS_COMPRESSION_MAX,
+	Z_EROFS_COMPRESSION_RUNTIME_MAX
+};
+
+struct z_erofs_decompress_req {
+	char *in, *out;
+
+	/*
+	 * initial decompressed bytes that need to be skipped
+	 * when finally copying to output buffer
+	 */
+	unsigned int decodedskip;
+	unsigned int inputsize, decodedlength;
+
+	/* indicate the algorithm will be used for decompression */
+	unsigned int alg;
+	bool partial_decoding;
+};
+
+int z_erofs_decompress(struct z_erofs_decompress_req *rq);
+
+#endif
fs/erofs/namei.c +1 -1
index 4c5d614483..7a0fbe2bc1 100644
@@ -101,7 +101,7 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi)
 
 	vi->flags = 0;
 	if (erofs_inode_is_data_compressed(vi->datalayout))
-		return -EOPNOTSUPP;
+		z_erofs_fill_inode(vi);
 	return 0;
 bogusimode:
 	erofs_err("bogus i_mode (%o) @ nid %llu", vi->i_mode, vi->nid | 0ULL);
fs/erofs/zmap.c new file +517 -0

517 lines not on this page · raw message

Signature · 1 line
2.25.1
#16 lore raw
In reply to Huang Jianan

Hi U-Boot folks,

Quoted 7 lines · Huang Jianan

From: Huang Jianan <[email protected]>

Add erofs filesystem support.

The code is adapted from erofs-utils in order to reduce maintenance burden and keep with the latest feature.

Quoted 8 lines

Changes since v1:
- fix the inconsistency between From and SoB (Bin Meng);
- add missing license header;

Huang Jianan (3):
fs/erofs: add erofs filesystem support
fs/erofs: add lz4 1.8.3 decompressor
fs/erofs: add lz4 decompression support

Could someone take some time looking into this? I think adding erofs support to U-Boot is useful for booting with erofs. And keep sync with erofsfuse code in erofs-utils is a good strategy for latest feature.

Thanks in advance.

Thanks,
Gao Xiang

Quoted 37 lines
 fs/Kconfig            |   1 +
 fs/Makefile           |   1 +
 fs/erofs/Kconfig      |  12 +
 fs/erofs/Makefile     |  10 +
 fs/erofs/data.c       | 206 ++++++++++++++++
 fs/erofs/decompress.c |  74 ++++++
 fs/erofs/decompress.h |  29 +++
 fs/erofs/erofs_fs.h   | 384 ++++++++++++++++++++++++++++++
 fs/erofs/fs.c         | 231 ++++++++++++++++++
 fs/erofs/internal.h   | 203 ++++++++++++++++
 fs/erofs/lz4.c        | 534 ++++++++++++++++++++++++++++++++++++++++++
 fs/erofs/lz4.h        |   5 +
 fs/erofs/namei.c      | 238 +++++++++++++++++++
 fs/erofs/super.c      |  65 +++++
 fs/erofs/zmap.c       | 517 ++++++++++++++++++++++++++++++++++++++++
 fs/fs.c               |  22 ++
 include/erofs.h       |  19 ++
 include/fs.h          |   1 +
 18 files changed, 2552 insertions(+)
 create mode 100644 fs/erofs/Kconfig
 create mode 100644 fs/erofs/Makefile
 create mode 100644 fs/erofs/data.c
 create mode 100644 fs/erofs/decompress.c
 create mode 100644 fs/erofs/decompress.h
 create mode 100644 fs/erofs/erofs_fs.h
 create mode 100644 fs/erofs/fs.c
 create mode 100644 fs/erofs/internal.h
 create mode 100644 fs/erofs/lz4.c
 create mode 100644 fs/erofs/lz4.h
 create mode 100644 fs/erofs/namei.c
 create mode 100644 fs/erofs/super.c
 create mode 100644 fs/erofs/zmap.c
 create mode 100644 include/erofs.h
Signature · 1 line
2.25.1
#17 lore raw
In reply to Huang Jianan
Quoted 7 lines · Huang Jianan

From: Huang Jianan <[email protected]>

Add erofs filesystem support.

The code is adapted from erofs-utils in order to reduce maintenance burden and keep with the latest feature.

Quoted 8 lines

Changes since v1:
- fix the inconsistency between From and SoB (Bin Meng);
- add missing license header;

Huang Jianan (3):
fs/erofs: add erofs filesystem support
fs/erofs: add lz4 1.8.3 decompressor
fs/erofs: add lz4 decompression support

Aside from what I've just now sent, can you please extend the existing py/tests/ to cover basic functionality here, ensure they run on sandbox and in CI? Thanks.

Signature · 1 line
Tom
#18 lore raw

Hi Jianan,

Quoted 13 lines · Tom Rini
Quoted 11 lines · Huang Jianan

From: Huang Jianan <[email protected]>

Add erofs filesystem support.

The code is adapted from erofs-utils in order to reduce maintenance burden and keep with the latest feature.

Changes since v1:
- fix the inconsistency between From and SoB (Bin Meng);
- add missing license header;

Quoted 8 lines
Quoted 4 lines

Huang Jianan (3):
fs/erofs: add erofs filesystem support
fs/erofs: add lz4 1.8.3 decompressor
fs/erofs: add lz4 decompression support

Aside from what I've just now sent, can you please extend the existing py/tests/ to cover basic functionality here, ensure they run on sandbox and in CI? Thanks.

Any further progress on this work? At least sync it up with erofs-utils 1.4?

Thanks,
Gao Xiang

Quoted 3 lines
Signature · 2 lines
-- 
Tom
#19 lore raw
Quoted 20 lines · Gao Xiang

Hi Jianan,

Quoted 17 lines · Tom Rini
Quoted 15 lines · Huang Jianan

From: Huang Jianan <[email protected]>

Add erofs filesystem support.

The code is adapted from erofs-utils in order to reduce maintenance burden and keep with the latest feature.

Changes since v1:
- fix the inconsistency between From and SoB (Bin Meng);
- add missing license header;

Huang Jianan (3):
fs/erofs: add erofs filesystem support
fs/erofs: add lz4 1.8.3 decompressor
fs/erofs: add lz4 decompression support

Quoted 5 lines
Quoted 3 lines

Aside from what I've just now sent, can you please extend the existing py/tests/ to cover basic functionality here, ensure they run on sandbox and in CI? Thanks.

Any further progress on this work? At least sync it up with erofs-utils 1.4?

I'm still working on this, the new version will be sent soon.

Thanks,
Jianan

Quoted 6 lines

Thanks,
Gao Xiang

Quoted 2 lines
Signature · 1 line
Tom
#20 lore raw

v3 cover fs/erofs: new filesystem

In reply to Huang Jianan

Changes since v2:
- sync up with erofs-utils 1.4;
- update lib/lz4 to v1.8.3;
- add test for filesystem functions;

Changes since v1:
- fix the inconsistency between From and SoB;
- add missing license header;

Huang Jianan (5):
fs/erofs: add erofs filesystem support
lib/lz4: update LZ4 decompressor module
fs/erofs: add lz4 decompression support
fs/erofs: add filesystem commands
test/py: Add tests for the erofs

 MAINTAINERS                         |   9 +
 cmd/Kconfig                         |   6 +
 cmd/Makefile                        |   1 +
 cmd/erofs.c                         |  42 ++
 configs/sandbox_defconfig           |   1 +
 fs/Kconfig                          |   2 +
 fs/Makefile                         |   1 +
 fs/erofs/Kconfig                    |  21 +
 fs/erofs/Makefile                   |   9 +
 fs/erofs/data.c                     | 311 +++++++++++++
 fs/erofs/decompress.c               |  78 ++++
 fs/erofs/decompress.h               |  24 +
 fs/erofs/erofs_fs.h                 | 436 ++++++++++++++++++
 fs/erofs/fs.c                       | 267 +++++++++++
 fs/erofs/internal.h                 | 313 +++++++++++++
 fs/erofs/namei.c                    | 252 +++++++++++
 fs/erofs/super.c                    | 105 +++++
 fs/erofs/zmap.c                     | 601 ++++++++++++++++++++++++
 fs/fs.c                             |  22 +
 include/erofs.h                     |  19 +
 include/fs.h                        |   1 +
 include/u-boot/lz4.h                |  49 ++
 lib/lz4.c                           | 679 ++++++++++++++++++++--------
 lib/lz4_wrapper.c                   |  23 +-
 test/py/tests/test_fs/test_erofs.py | 211 +++++++++
 25 files changed, 3268 insertions(+), 215 deletions(-)
 create mode 100644 cmd/erofs.c
 create mode 100644 fs/erofs/Kconfig
 create mode 100644 fs/erofs/Makefile
 create mode 100644 fs/erofs/data.c
 create mode 100644 fs/erofs/decompress.c
 create mode 100644 fs/erofs/decompress.h
 create mode 100644 fs/erofs/erofs_fs.h
 create mode 100644 fs/erofs/fs.c
 create mode 100644 fs/erofs/internal.h
 create mode 100644 fs/erofs/namei.c
 create mode 100644 fs/erofs/super.c
 create mode 100644 fs/erofs/zmap.c
 create mode 100644 include/erofs.h
 create mode 100644 test/py/tests/test_fs/test_erofs.py
Signature · 1 line
2.25.1
#21 lore raw

PATCH v3 1/5 fs/erofs: add erofs filesystem support

This patch mainly deals with uncompressed files.

---
 MAINTAINERS         |   7 +
 fs/Kconfig          |   2 +
 fs/Makefile         |   1 +
 fs/erofs/Kconfig    |  12 ++
 fs/erofs/Makefile   |   7 +
 fs/erofs/data.c     | 223 ++++++++++++++++++++++
 fs/erofs/erofs_fs.h | 436 ++++++++++++++++++++++++++++++++++++++++++++
 fs/erofs/fs.c       | 267 +++++++++++++++++++++++++++
 fs/erofs/internal.h | 313 +++++++++++++++++++++++++++++++
 fs/erofs/namei.c    | 252 +++++++++++++++++++++++++
 fs/erofs/super.c    | 105 +++++++++++
 fs/fs.c             |  22 +++
 include/erofs.h     |  19 ++
 include/fs.h        |   1 +
 14 files changed, 1667 insertions(+)
 create mode 100644 fs/erofs/Kconfig
 create mode 100644 fs/erofs/Makefile
 create mode 100644 fs/erofs/data.c
 create mode 100644 fs/erofs/erofs_fs.h
 create mode 100644 fs/erofs/fs.c
 create mode 100644 fs/erofs/internal.h
 create mode 100644 fs/erofs/namei.c
 create mode 100644 fs/erofs/super.c
 create mode 100644 include/erofs.h
MAINTAINERS +7 -0
index dcdd99e368..571a64bf7e 100644
@@ -794,6 +794,13 @@ S:	Maintained
 F:	doc/usage/environment.rst
 F:	scripts/env2string.awk
 
+EROFS
+M:	Huang Jianan <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	fs/erofs/
+F:	include/erofs.h
+
 FASTBOOT
 S:	Orphaned
 F:	cmd/fastboot.c
fs/Kconfig +2 -0
index 620af7f044..cda9f66cc9 100644
@@ -24,4 +24,6 @@ source "fs/yaffs2/Kconfig"
 
 source "fs/squashfs/Kconfig"
 
+source "fs/erofs/Kconfig"
+
 endmenu
fs/Makefile +1 -0
index 937cbcf6e8..f05a21c9e6 100644
@@ -25,5 +25,6 @@ obj-$(CONFIG_CMD_UBIFS) += ubifs/
 obj-$(CONFIG_YAFFS2) += yaffs2/
 obj-$(CONFIG_CMD_ZFS) += zfs/
 obj-$(CONFIG_FS_SQUASHFS) += squashfs/
+obj-$(CONFIG_FS_EROFS) += erofs/
 endif
 obj-y += fs_internal.o
fs/erofs/Kconfig new file +12 -0
new file mode 100644
index 0000000000..f4b2d51a23
@@ -0,0 +1,12 @@
+config FS_EROFS
+	bool "Enable EROFS filesystem support"
+	help
+	  This provides support for reading images from EROFS filesystem.
+	  EROFS (Enhanced Read-Only File System) is a lightweight read-only
+	  file system for scenarios which need high-performance read-only
+	  requirements.
+
+	  It also provides fixed-sized output compression support, which
+	  improves storage density, keeps relatively higher compression
+	  ratios, which is more useful to achieve high performance for
+	  embedded devices with limited memory.
fs/erofs/Makefile new file +7 -0
new file mode 100644
index 0000000000..7398ab7a36
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-$(CONFIG_$(SPL_)FS_EROFS) = fs.o \
+				super.o \
+				namei.o \
+				data.o
fs/erofs/data.c new file +223 -0

223 lines not on this page · raw message

fs/erofs/erofs_fs.h new file +436 -0

436 lines not on this page · raw message

fs/erofs/fs.c new file +267 -0

267 lines not on this page · raw message

fs/erofs/internal.h new file +313 -0

313 lines not on this page · raw message

fs/erofs/namei.c new file +252 -0

252 lines not on this page · raw message

fs/erofs/super.c new file +105 -0

105 lines not on this page · raw message

fs/fs.c +22 -0
index 023f89cafe..99dac0fd79 100644
@@ -26,6 +26,7 @@
 #include <linux/math64.h>
 #include <efi_loader.h>
 #include <squashfs.h>
+#include <erofs.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -304,6 +305,27 @@ static struct fstype_info fstypes[] = {
 		.unlink = fs_unlink_unsupported,
 		.mkdir = fs_mkdir_unsupported,
 	},
+#endif
+#if IS_ENABLED(CONFIG_FS_EROFS)
+	{
+		.fstype = FS_TYPE_EROFS,
+		.name = "erofs",
+		.null_dev_desc_ok = false,
+		.probe = erofs_probe,
+		.opendir = erofs_opendir,
+		.readdir = erofs_readdir,
+		.ls = fs_ls_generic,
+		.read = erofs_read,
+		.size = erofs_size,
+		.close = erofs_close,
+		.closedir = erofs_closedir,
+		.exists = erofs_exists,
+		.uuid = fs_uuid_unsupported,
+		.write = fs_write_unsupported,
+		.ln = fs_ln_unsupported,
+		.unlink = fs_unlink_unsupported,
+		.mkdir = fs_mkdir_unsupported,
+	},
 #endif
 	{
 		.fstype = FS_TYPE_ANY,
include/erofs.h new file +19 -0
new file mode 100644
index 0000000000..1fbe82bf72
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _EROFS_H_
+#define _EROFS_H_
+
+struct disk_partition;
+
+int erofs_opendir(const char *filename, struct fs_dir_stream **dirsp);
+int erofs_readdir(struct fs_dir_stream *dirs, struct fs_dirent **dentp);
+int erofs_probe(struct blk_desc *fs_dev_desc,
+		struct disk_partition *fs_partition);
+int erofs_read(const char *filename, void *buf, loff_t offset,
+	       loff_t len, loff_t *actread);
+int erofs_size(const char *filename, loff_t *size);
+int erofs_exists(const char *filename);
+void erofs_close(void);
+void erofs_closedir(struct fs_dir_stream *dirs);
+int erofs_uuid(char *uuid_str);
+
+#endif /* _EROFS_H */
include/fs.h +1 -0
index c8df3886ac..b607b0028d 100644
@@ -17,6 +17,7 @@ struct cmd_tbl;
 #define FS_TYPE_UBIFS	4
 #define FS_TYPE_BTRFS	5
 #define FS_TYPE_SQUASHFS 6
+#define FS_TYPE_EROFS   7
 
 struct blk_desc;
 
Signature · 1 line
2.25.1
#22 lore raw

PATCH v3 2/5 lib/lz4: update LZ4 decompressor module

In reply to Huang Jianan

Update the LZ4 compression module based on LZ4 v1.8.3 in order to use the newest LZ4_decompress_safe_partial() which can now decode exactly the nb of bytes requested.

---
 include/u-boot/lz4.h |  49 ++++
 lib/lz4.c            | 679 +++++++++++++++++++++++++++++++------------
 lib/lz4_wrapper.c    |  23 +-
 3 files changed, 536 insertions(+), 215 deletions(-)
include/u-boot/lz4.h +49 -0
index e18b39a5dc..655adbfcd1 100644
@@ -21,4 +21,53 @@
  */
 int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn);
 
+/**
+ * LZ4_decompress_safe() - Decompression protected against buffer overflow
+ * @source: source address of the compressed data
+ * @dest: output buffer address of the uncompressed data
+ *	which must be already allocated
+ * @compressedSize: is the precise full size of the compressed block
+ * @maxDecompressedSize: is the size of 'dest' buffer
+ *
+ * Decompresses data from 'source' into 'dest'.
+ * If the source stream is detected malformed, the function will
+ * stop decoding and return a negative result.
+ * This function is protected against buffer overflow exploits,
+ * including malicious data packets. It never writes outside output buffer,
+ * nor reads outside input buffer.
+ *
+ * Return: number of bytes decompressed into destination buffer
+ *	(necessarily <= maxDecompressedSize)
+ *	or a negative result in case of error
+ */
+int LZ4_decompress_safe(const char *source, char *dest,
+	int compressedSize, int maxDecompressedSize);
+
+/**
+ * LZ4_decompress_safe_partial() - Decompress a block of size 'compressedSize'
+ *	at position 'source' into buffer 'dest'
+ * @source: source address of the compressed data
+ * @dest: output buffer address of the decompressed data which must be
+ *	already allocated
+ * @compressedSize: is the precise full size of the compressed block.
+ * @targetOutputSize: the decompression operation will try
+ *	to stop as soon as 'targetOutputSize' has been reached
+ * @maxDecompressedSize: is the size of destination buffer
+ *
+ * This function decompresses a compressed block of size 'compressedSize'
+ * at position 'source' into destination buffer 'dest'
+ * of size 'maxDecompressedSize'.
+ * The function tries to stop decompressing operation as soon as
+ * 'targetOutputSize' has been reached, reducing decompression time.
+ * This function never writes outside of output buffer,
+ * and never reads outside of input buffer.
+ * It is therefore protected against malicious data packets.
+ *
+ * Return: the number of bytes decoded in the destination buffer
+ *	(necessarily <= maxDecompressedSize)
+ *	or a negative result in case of error
+ *
+ */
+int LZ4_decompress_safe_partial(const char *src, char *dst,
+	int compressedSize, int targetOutputSize, int dstCapacity);
 #endif
lib/lz4.c +486 -193

711 lines not on this page · raw message

lib/lz4_wrapper.c +1 -22
index ebcb5c09a2..0d2a3655a8 100644
@@ -11,27 +11,6 @@
 #include <asm/unaligned.h>
 #include <u-boot/lz4.h>
 
-static u16 LZ4_readLE16(const void *src)
-{
-	return get_unaligned_le16(src);
-}
-static void LZ4_copy4(void *dst, const void *src)
-{
-	put_unaligned(get_unaligned((const u32 *)src), (u32 *)dst);
-}
-static void LZ4_copy8(void *dst, const void *src)
-{
-	put_unaligned(get_unaligned((const u64 *)src), (u64 *)dst);
-}
-
-typedef  uint8_t BYTE;
-typedef uint16_t U16;
-typedef uint32_t U32;
-typedef  int32_t S32;
-typedef uint64_t U64;
-
-#define FORCE_INLINE static inline __attribute__((always_inline))
-
 /* lz4.c is unaltered (except removing unrelated code) from github.com/Cyan4973/lz4. */
 #include "lz4.c"	/* #include for inlining, do not link! */
 
@@ -112,7 +91,7 @@ int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn)
 			/* constant folding essential, do not touch params! */
 			ret = LZ4_decompress_generic(in, out, block_size,
 					end - out, endOnInputSize,
-					full, 0, noDict, out, NULL, 0);
+					decode_full_block, noDict, out, NULL, 0);
 			if (ret < 0) {
 				ret = -EPROTO;	/* decompression error */
 				break;
Signature · 1 line
2.25.1
#23 lore raw

PATCH v3 3/5 fs/erofs: add lz4 decompression support

In reply to Huang Jianan

Support EROFS lz4 compressed files.

---
 fs/erofs/Kconfig      |   9 +
 fs/erofs/Makefile     |   4 +-
 fs/erofs/data.c       |  90 ++++++-
 fs/erofs/decompress.c |  78 ++++++
 fs/erofs/decompress.h |  24 ++
 fs/erofs/namei.c      |   2 +-
 fs/erofs/zmap.c       | 601 ++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 805 insertions(+), 3 deletions(-)
 create mode 100644 fs/erofs/decompress.c
 create mode 100644 fs/erofs/decompress.h
 create mode 100644 fs/erofs/zmap.c
fs/erofs/Kconfig +9 -0
index f4b2d51a23..ee4e777c5c 100644
@@ -10,3 +10,12 @@ config FS_EROFS
 	  improves storage density, keeps relatively higher compression
 	  ratios, which is more useful to achieve high performance for
 	  embedded devices with limited memory.
+
+config FS_EROFS_ZIP
+	bool "EROFS Data Compression Support"
+	depends on FS_EROFS
+	select LZ4
+	default y
+	help
+	  Enable fixed-sized output compression for EROFS.
+	  If you don't want to enable compression feature, say N.
fs/erofs/Makefile +3 -1
index 7398ab7a36..58af6a68e4 100644
@@ -4,4 +4,6 @@
 obj-$(CONFIG_$(SPL_)FS_EROFS) = fs.o \
 				super.o \
 				namei.o \
-				data.o
+				data.o \
+				decompress.o \
+				zmap.o
fs/erofs/data.c +89 -1

107 lines not on this page · raw message

fs/erofs/decompress.c new file +78 -0

78 lines not on this page · raw message

fs/erofs/decompress.h new file +24 -0
new file mode 100644
index 0000000000..81d5fb84f6
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+#ifndef __EROFS_DECOMPRESS_H
+#define __EROFS_DECOMPRESS_H
+
+#include "internal.h"
+
+struct z_erofs_decompress_req {
+	char *in, *out;
+
+	/*
+	 * initial decompressed bytes that need to be skipped
+	 * when finally copying to output buffer
+	 */
+	unsigned int decodedskip;
+	unsigned int inputsize, decodedlength;
+
+	/* indicate the algorithm will be used for decompression */
+	unsigned int alg;
+	bool partial_decoding;
+};
+
+int z_erofs_decompress(struct z_erofs_decompress_req *rq);
+
+#endif
fs/erofs/namei.c +1 -1
index f1195a09ea..d1d4757c50 100644
@@ -114,7 +114,7 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi)
 		vi->u.chunkbits = LOG_BLOCK_SIZE +
 			(vi->u.chunkformat & EROFS_CHUNK_FORMAT_BLKBITS_MASK);
 	} else if (erofs_inode_is_data_compressed(vi->datalayout))
-		return -EOPNOTSUPP;
+		z_erofs_fill_inode(vi);
 	return 0;
 bogusimode:
 	erofs_err("bogus i_mode (%o) @ nid %llu", vi->i_mode, vi->nid | 0ULL);
fs/erofs/zmap.c new file +601 -0

601 lines not on this page · raw message

Signature · 1 line
2.25.1
#24 lore raw

PATCH v3 4/5 fs/erofs: add filesystem commands

In reply to Huang Jianan

Add 'ls' and 'load' commands.

---
 MAINTAINERS  |  1 +
 cmd/Kconfig  |  6 ++++++
 cmd/Makefile |  1 +
 cmd/erofs.c  | 42 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 50 insertions(+)
 create mode 100644 cmd/erofs.c
MAINTAINERS +1 -0
index 571a64bf7e..aa417bc44f 100644
@@ -798,6 +798,7 @@ EROFS
 M:	Huang Jianan <[email protected]>
 L:	[email protected]
 S:	Maintained
+F:	cmd/erofs.c
 F:	fs/erofs/
 F:	include/erofs.h
 
cmd/Kconfig +6 -0
index 5e25e45fd2..50b8f33434 100644
@@ -2176,6 +2176,12 @@ config CMD_CRAMFS
 	     cramfsls   - lists files in a cramfs image
 	     cramfsload - loads a file from a cramfs image
 
+config CMD_EROFS
+	bool "EROFS command support"
+	select FS_EROFS
+	help
+	  Support for the EROFS fs
+
 config CMD_EXT2
 	bool "ext2 command support"
 	select FS_EXT4
cmd/Makefile +1 -0
index 166c652d98..d668b3c62d 100644
@@ -60,6 +60,7 @@ obj-$(CONFIG_CMD_EEPROM) += eeprom.o
 obj-$(CONFIG_EFI) += efi.o
 obj-$(CONFIG_CMD_EFIDEBUG) += efidebug.o
 obj-$(CONFIG_CMD_ELF) += elf.o
+obj-$(CONFIG_CMD_EROFS) += erofs.o
 obj-$(CONFIG_HUSH_PARSER) += exit.o
 obj-$(CONFIG_CMD_EXT4) += ext4.o
 obj-$(CONFIG_CMD_EXT2) += ext2.o
cmd/erofs.c new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.25.1
#25 lore raw

PATCH v3 5/5 test/py: Add tests for the erofs

In reply to Huang Jianan

Add Python scripts to test 'ls' and 'load' commands, as well as test related filesystem functions.

---
 MAINTAINERS                         |   1 +
 configs/sandbox_defconfig           |   1 +
 test/py/tests/test_fs/test_erofs.py | 211 ++++++++++++++++++++++++++++
 3 files changed, 213 insertions(+)
 create mode 100644 test/py/tests/test_fs/test_erofs.py
MAINTAINERS +1 -0
index aa417bc44f..23ffdbc488 100644
@@ -801,6 +801,7 @@ S:	Maintained
 F:	cmd/erofs.c
 F:	fs/erofs/
 F:	include/erofs.h
+F:	test/py/tests/test_fs/test_erofs.py
 
 FASTBOOT
 S:	Orphaned
configs/sandbox_defconfig +1 -0
index f85274353d..78962ab4c8 100644
@@ -105,6 +105,7 @@ CONFIG_CMD_TPM_TEST=y
 CONFIG_CMD_BTRFS=y
 CONFIG_CMD_CBFS=y
 CONFIG_CMD_CRAMFS=y
+CONFIG_CMD_EROFS=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_SQUASHFS=y
 CONFIG_CMD_MTDPARTS=y
test/py/tests/test_fs/test_erofs.py new file +211 -0

211 lines not on this page · raw message

Signature · 1 line
2.25.1
#26 lore raw

Re: [PATCH v3 5/5] test/py: Add tests for the erofs

Quoted 10 lines · Huang Jianan

Add Python scripts to test 'ls' and 'load' commands, as well as test related filesystem functions.

---
 MAINTAINERS                         |   1 +
 configs/sandbox_defconfig           |   1 +
 test/py/tests/test_fs/test_erofs.py | 211 ++++++++++++++++++++++++++++
 3 files changed, 213 insertions(+)
 create mode 100644 test/py/tests/test_fs/test_erofs.py

Please update tools/docker/Dockerfile so that we can run these in CI as well, thanks.

Signature · 1 line
Tom
#27 lore raw
In reply to Huang Jianan

Hi Tom,

Would you mind taking some time having a look at this version if it meets what's needed, so we could have a chance to be merged in the next u-boot version?

It's almost in sync with the latest erofs-utils soruce code, so it can be upgraded easily in the future together with the later erofs-utils versions.

Thanks,
Gao Xiang

Quoted 59 lines · Huang Jianan

Changes since v2:
- sync up with erofs-utils 1.4;
- update lib/lz4 to v1.8.3;
- add test for filesystem functions;

Changes since v1:
- fix the inconsistency between From and SoB;
- add missing license header;

Huang Jianan (5):
fs/erofs: add erofs filesystem support
lib/lz4: update LZ4 decompressor module
fs/erofs: add lz4 decompression support
fs/erofs: add filesystem commands
test/py: Add tests for the erofs

 MAINTAINERS                         |   9 +
 cmd/Kconfig                         |   6 +
 cmd/Makefile                        |   1 +
 cmd/erofs.c                         |  42 ++
 configs/sandbox_defconfig           |   1 +
 fs/Kconfig                          |   2 +
 fs/Makefile                         |   1 +
 fs/erofs/Kconfig                    |  21 +
 fs/erofs/Makefile                   |   9 +
 fs/erofs/data.c                     | 311 +++++++++++++
 fs/erofs/decompress.c               |  78 ++++
 fs/erofs/decompress.h               |  24 +
 fs/erofs/erofs_fs.h                 | 436 ++++++++++++++++++
 fs/erofs/fs.c                       | 267 +++++++++++
 fs/erofs/internal.h                 | 313 +++++++++++++
 fs/erofs/namei.c                    | 252 +++++++++++
 fs/erofs/super.c                    | 105 +++++
 fs/erofs/zmap.c                     | 601 ++++++++++++++++++++++++
 fs/fs.c                             |  22 +
 include/erofs.h                     |  19 +
 include/fs.h                        |   1 +
 include/u-boot/lz4.h                |  49 ++
 lib/lz4.c                           | 679 ++++++++++++++++++++--------
 lib/lz4_wrapper.c                   |  23 +-
 test/py/tests/test_fs/test_erofs.py | 211 +++++++++
 25 files changed, 3268 insertions(+), 215 deletions(-)
 create mode 100644 cmd/erofs.c
 create mode 100644 fs/erofs/Kconfig
 create mode 100644 fs/erofs/Makefile
 create mode 100644 fs/erofs/data.c
 create mode 100644 fs/erofs/decompress.c
 create mode 100644 fs/erofs/decompress.h
 create mode 100644 fs/erofs/erofs_fs.h
 create mode 100644 fs/erofs/fs.c
 create mode 100644 fs/erofs/internal.h
 create mode 100644 fs/erofs/namei.c
 create mode 100644 fs/erofs/super.c
 create mode 100644 fs/erofs/zmap.c
 create mode 100644 include/erofs.h
 create mode 100644 test/py/tests/test_fs/test_erofs.py
Signature · 1 line
2.25.1
#28 lore raw
Quoted 9 lines · Gao Xiang

Hi Tom,

Would you mind taking some time having a look at this version if it meets what's needed, so we could have a chance to be merged in the next u-boot version?

It's almost in sync with the latest erofs-utils soruce code, so it can be upgraded easily in the future together with the later erofs-utils versions.

Things seem fine, we just need to also update the Dockerfile with tools so that the tests are run.

Signature · 1 line
Tom
#29 lore raw
Quoted 8 lines · Tom Rini
Quoted 6 lines · Gao Xiang

Hi Tom,

Would you mind taking some time having a look at this version if it meets what's needed, so we could have a chance to be merged in the next u-boot version?

Quoted 6 lines
Quoted 3 lines

It's almost in sync with the latest erofs-utils soruce code, so it can be upgraded easily in the future together with the later erofs-utils versions.

Things seem fine, we just need to also update the Dockerfile with tools so that the tests are run.

Many thanks! Hopefully Jianan could fill the gap later.

Thanks,
Gao Xiang

Quoted 3 lines
Signature · 2 lines
-- 
Tom