Gao Xiang [Thu, 19 Oct 2023 22:45:01 +0000 (06:45 +0800)]
erofs-utils: release 1.7.1
Signed-off-by: Gao Xiang <xiang@kernel.org>
Gao Xiang [Thu, 19 Oct 2023 22:43:28 +0000 (06:43 +0800)]
erofs-utils: fix reference leak in erofs_mkfs_build_tree_from_path()
commit
8cbc205185a1 ("erofs-utils: mkfs: fix corrupted directories
with hardlinks") introduced a reference leak although it has no real
impact to users. Fix it now.
Signed-off-by: Gao Xiang <xiang@kernel.org>
Link: https://lore.kernel.org/r/20231019224328.26015-1-xiang@kernel.org
Gao Xiang [Tue, 17 Oct 2023 14:44:20 +0000 (22:44 +0800)]
erofs-utils: mkfs: fix corrupted directories with hardlinks
An inode with hard links may belong to several directories. It's
invalid to update `subdirs_queued` for hard-link inodes since it
only records one of the parent directories.
References: https://github.com/NixOS/nixpkgs/issues/261394
Fixes: 21d84349e79a ("erofs-utils: rearrange on-disk metadata")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20231017144420.289469-1-hsiangkao@linux.alibaba.com
Erik Sjölund [Mon, 2 Oct 2023 17:36:08 +0000 (19:36 +0200)]
erofs-utils: errno shouldn't set to a negative value in lib/tar.c
`errno` should be set to a non-negative value here.
Link: https://lore.kernel.org/r/CAB+1q0Q3+7s1Lt8uW6DWZ7vfjhEKhG7O7MAQhCuH-C10cr9F4g@mail.gmail.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Sandeep Dhavale [Thu, 5 Oct 2023 22:40:08 +0000 (15:40 -0700)]
erofs-utils: Fix cross compile with autoconf
AC_RUN_IFELSE expects the action if cross compiling. If not provided
cross compilation fails with error "configure: error: cannot run test
program while cross compiling".
Use 4096 as the buest guess PAGESIZE if cross compiling as it is still
the most common page size.
Reported-in: https://lore.kernel.org/all/
0101018aec71b531-
0a354b1a-0b70-47a1-8efc-
fea8c439304c-000000@us-west-2.amazonses.com/
Fixes: 8ee2e591dfd6 ("erofs-utils: support detecting maximum block size")
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20231005224008.817830-1-dhavale@google.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Gao Xiang [Thu, 21 Sep 2023 03:30:00 +0000 (11:30 +0800)]
erofs-utils: release 1.7
Signed-off-by: Gao Xiang <xiang@kernel.org>
Gao Xiang [Thu, 21 Sep 2023 03:24:17 +0000 (11:24 +0800)]
erofs-utils: fix the previous pcluster CBLKCNT missing for big pcluster dedupe
Similar to
876bec09e48a ("erofs-utils: lib: fix missing CBLKCNT for
big pcluster dedupe"), the previous CBLKCNT cannot be dropped due to
the extent shortening process.
It may cause data corruption on specific data patterns only if both
big pcluster and dedupe features are enabled.
Link: https://lore.kernel.org/r/20230921032417.82739-1-hsiangkao@linux.alibaba.com
Fixes: f3f9a2ce3137 ("erofs-utils: mkfs: introduce global compressed data deduplication")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Gao Xiang [Wed, 20 Sep 2023 20:03:13 +0000 (04:03 +0800)]
erofs-utils: fix build error when `-Waddress-of-temporary` is on
Actually, it's false positive and only used for build assertion.
Reported-by: Kelvin Zhang <zhangkelvin@google.com>
Signed-off-by: Gao Xiang <xiang@kernel.org>
Link: https://lore.kernel.org/r/20230920200314.9193-1-hsiangkao@aol.com
Gao Xiang [Wed, 20 Sep 2023 19:02:20 +0000 (03:02 +0800)]
erofs-utils: mkfs: limit total shared xattrs of a single inode
Don't output more than 255 shared xattrs for a single inode due to the
EROFS on-disk format limitation.
Fixes: 116ac0a254fc ("erofs-utils: introduce shared xattr support")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230920190220.1837650-1-hsiangkao@linux.alibaba.com
Gao Xiang [Wed, 20 Sep 2023 16:41:28 +0000 (00:41 +0800)]
erofs-utils: manpages: update new options of mkfs.erofs
-b block-size
-E ^xattr-name-filter
--gzip
--tar=[fi]
--xattr-prefix=X
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230920164128.1637554-1-hsiangkao@linux.alibaba.com
Gao Xiang [Wed, 20 Sep 2023 05:12:23 +0000 (13:12 +0800)]
erofs-utils: lib: fix --force-{g,u}id support for tarerofs
Temporarily move the common part into __erofs_fill_inode() for tarerofs.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230920051223.657008-1-hsiangkao@linux.alibaba.com
Gao Xiang [Wed, 20 Sep 2023 03:51:41 +0000 (11:51 +0800)]
erofs-utils: mkfs: support exporting GNU tar archive labels
GNU tar volume labels (by using `-V`) will be applied to EROFS.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230920035141.533474-1-hsiangkao@linux.alibaba.com
Sandeep Dhavale [Tue, 19 Sep 2023 21:02:20 +0000 (14:02 -0700)]
erofs-utils: lib: Restore memory address before free()
We move `idx` pointer as we iterate through for loop based on `count`. If
we error out from the loop, use the original pointer of allocated memory
when calling free().
Fixes: 39147b48b76d ("erofs-utils: lib: add erofs_rebuild_load_tree() helper")
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20230919210220.3657736-1-dhavale@google.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Gao Xiang [Tue, 19 Sep 2023 18:59:47 +0000 (02:59 +0800)]
erofs-utils: mkfs: support tgz streams for tarerofs
Introduce iostream to wrap up the input tarball stream for tarerofs.
Besides, add builtin tgz support if zlib is linked to mkfs.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230919185947.3996843-1-hsiangkao@linux.alibaba.com
Gao Xiang [Fri, 15 Sep 2023 08:26:19 +0000 (16:26 +0800)]
erofs-utils: mkfs: pop up most recently used dentries for tarerofs
Each tar header keeps the full file path. It's useful to move most
recently used intermediate dirs to list heads.
User time of tarerofs index mode can be reduced by 19%.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230915082619.3533530-1-hsiangkao@linux.alibaba.com
Gao Xiang [Wed, 20 Sep 2023 03:46:55 +0000 (11:46 +0800)]
erofs-utils: lib: introduce diskbuf
Previously, each tar data file will be kept as a temporary file before
landing to the target image since the input stream may be non-seekable.
It's somewhat ineffective. Let's introduce a new diskbuf approach to
manage those buffers. Laterly, each stream can be redirected to blob
files for external reference.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230920034655.38381-1-xiang@kernel.org
Jingbo Xu [Fri, 15 Sep 2023 11:53:33 +0000 (19:53 +0800)]
erofs-utils: mkfs: support flatdev for multi-blob images
Since kernel commit
8b465fecc35a ("erofs: support flattened block device
for multi-blob images"), the flatdev feature has been introduced to
support mounting multi-blobs container image as a single block device.
To enable this feature, the mapped_blkaddr of each device slot needs to
be set properly to the offset of the device in the flat address space.
The uuid of the source image is used as the corresponding device tag
in rebuild mode.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230915115333.17599-1-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Wed, 13 Sep 2023 12:03:03 +0000 (20:03 +0800)]
erofs-utils: mkfs: add `--ovlfs-strip` option
Add `--ovlfs-strip=[0|1]` option for tarfs and rebuild mode for now
in order to control whether some overlayfs related stuffs (e.g.
whiteout files, OVL_XATTR_OPAQUE and OVL_XATTR_ORIGIN xattrs) are
finally stripped.
This option is disabled by default for mkfs, that is, the overlayfs
related stuffs described above are kept in the image by default.
Specify `--ovlfs-strip=1` explicitly to strip these stuffs.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230913120304.15741-9-jefflexu@linux.alibaba.com
Jingbo Xu [Wed, 13 Sep 2023 12:03:02 +0000 (20:03 +0800)]
erofs-utils: mkfs: introduce rebuild mode
Introduce a new EXPERIMENTAL rebuild mode, which can be used to
generate a meta-only multidev manifest image with an overlayfs-like
merged tree from multiple specific EROFS images either of
tarerofs index mode (--tar=i):
mkfs.erofs --tar=i --aufs layer0.erofs layer0.tar
...
mkfs.erofs --tar=i --aufs layerN.erofs layerN-1.tar
or mkfs.erofs uncompressed mode without inline data:
mkfs.erofs --tar=f -Enoinline_data --aufs layer0.erofs layer0.tar
...
mkfs.erofs --tar=f -Enoinline_data --aufs layerN-1.erofs layerN-1.tar
To merge these layers, just type:
mkfs.erofs merged.erofs layer0.erofs ... layerN-1.erofs
It doesn't support compression and/or flat inline datalayout yet.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230913120304.15741-8-jefflexu@linux.alibaba.com
Jingbo Xu [Wed, 13 Sep 2023 12:03:01 +0000 (20:03 +0800)]
erofs-utils: lib: add erofs_rebuild_load_tree() helper
Add erofs_rebuild_load_tree() helper to load the inode tree from a
given erofs image, and make it merged acting as an overlayfs-like
model.
Since the content of the symlink file needs to be read when loading
tree, let's add a dependency on zlib_LIBS for mkfs.erofs.
Also rename tarerofs_dump_tree() to erofs_rebuild_dump_tree() since
it is also called in the rebuild mode.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230913120304.15741-7-jefflexu@linux.alibaba.com
Jingbo Xu [Wed, 13 Sep 2023 12:03:00 +0000 (20:03 +0800)]
erofs-utils: lib: add erofs_rebuild_get_dentry() helper
Rename tarerofs_get_dentry() to erofs_rebuild_get_dentry() and
move it into lib/rebuild.c.
No logic changes.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230913120304.15741-6-jefflexu@linux.alibaba.com
Jingbo Xu [Wed, 13 Sep 2023 12:02:59 +0000 (20:02 +0800)]
erofs-utils: lib: add erofs_insert_ihash() helper
Add erofs_insert_ihash() helper inserting inode into inode hash table.
Also add prototypes of erofs_iget() and erofs_iget_by_nid() in the
header file.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230913120304.15741-5-jefflexu@linux.alibaba.com
Jingbo Xu [Wed, 13 Sep 2023 12:02:58 +0000 (20:02 +0800)]
erofs-utils: lib: add erofs_read_xattrs_from_disk() helper
Add erofs_read_xattrs_from_disk() helper to reading extended
attributes from disk.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230913120304.15741-4-jefflexu@linux.alibaba.com
Jingbo Xu [Wed, 13 Sep 2023 12:02:57 +0000 (20:02 +0800)]
erofs-utils: lib: make erofs_get_unhashed_chunk() global
... so that it could be called from outside blobchunk.c later.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230913120304.15741-3-jefflexu@linux.alibaba.com
Jingbo Xu [Wed, 13 Sep 2023 12:02:56 +0000 (20:02 +0800)]
erofs-utils: lib: add list_splice_tail() helper
Add list_splice_tail() helper.
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230913120304.15741-2-jefflexu@linux.alibaba.com
Gao Xiang [Thu, 14 Sep 2023 09:39:05 +0000 (17:39 +0800)]
erofs-utils: avoid flushing the image file on closing
Traditionally, truncating to small sizes will trigger some
flush-on-close semantics to avoid the notorious NULL files.
I'm not sure if it's our use case since:
1) we're creating new image files instead of reusing old ones;
2) it kills end-to-end performance in practice;
3) other programs like GNU TAR doesn't work as this too for
such meaningless comparsion;
Let's work around it now.
Link: https://lore.kernel.org/r/20230914093905.1600316-1-hsiangkao@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Gao Xiang [Thu, 14 Sep 2023 06:12:10 +0000 (14:12 +0800)]
erofs-utils: lib: avoid unnecessary modulo in cache.c
Previously, EROFS_BLKSIZ was a constant so it doesn't matter to use %
operator. Let's convert the remaining ones now.
Link: https://lore.kernel.org/r/20230914061210.1296457-1-hsiangkao@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Wed, 13 Sep 2023 03:18:04 +0000 (11:18 +0800)]
erofs-utils: lib: refactor extended attribute name prefixes
Previously, the extended attribute name in `struct xattr_item` was
actually the part with the matched prefix stripped, which makes it
clumsy to strip or delete a specific attribute from one file.
To fix this, make the complete attribute name stored in xattr_item.
One thing worth noting is that the attribute name in xattr_item has a
trailing '\0' for ease of name comparison, while the trailing '\0' will
get stripped when writing to on-disk erofs_xattr_entry.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230913031804.84819-1-jefflexu@linux.alibaba.com
Sandeep Dhavale [Wed, 13 Sep 2023 22:11:04 +0000 (15:11 -0700)]
erofs-utils: lib: tar: Initialize the variable to avoid using garbage value
The value in variable 'e' is checked without initializing and can
wrongly signify end of tar 2 empty blocks.
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20230913221104.429825-8-dhavale@google.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Sandeep Dhavale [Wed, 13 Sep 2023 22:11:03 +0000 (15:11 -0700)]
erofs-utils: lib: Remove redundant assignment
The intended assignment is already part of the next for loop
initialization.
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20230913221104.429825-7-dhavale@google.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Sandeep Dhavale [Wed, 13 Sep 2023 22:11:02 +0000 (15:11 -0700)]
erofs-utils: lib: Fix the memory leak in error path
If call to inflateInit2() fails, release the memory allocated for buff
before returning.
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20230913221104.429825-6-dhavale@google.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Sandeep Dhavale [Wed, 13 Sep 2023 22:11:01 +0000 (15:11 -0700)]
erofs-utils: lib: Check for error from z_erofs_pack_file_from_fd()
If z_erofs_pack_file_from_fd() fails, take the error path to free up the
allocated resources.
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20230913221104.429825-5-dhavale@google.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Sandeep Dhavale [Wed, 13 Sep 2023 22:11:00 +0000 (15:11 -0700)]
erofs-utils: lib: Fix memory leak if __erofs_battach() fails
Need to free allocated buffer_head bh if __erofs_battach() fails.
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20230913221104.429825-4-dhavale@google.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Sandeep Dhavale [Wed, 13 Sep 2023 22:10:59 +0000 (15:10 -0700)]
erofs-utils: lib: Remove redundant line to get padding
padding is only used in the next if() block. Remove the redundant call.
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20230913221104.429825-3-dhavale@google.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Sandeep Dhavale [Wed, 13 Sep 2023 22:10:58 +0000 (15:10 -0700)]
erofs-utils: fsck: Fix potential memory leak in error path
Free the memory allocated for 'entry' if strdup() fails.
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20230913221104.429825-2-dhavale@google.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Sandeep Dhavale [Tue, 12 Sep 2023 22:12:04 +0000 (15:12 -0700)]
erofs-utils: fsck: fix support for 16k block size
This basically follows the fix in kernel commit
001b8ccd0650 ("erofs:
fix compact 4B support for 16k block size").
Without this patch fsck on images with 16k block size reports corruption
which is not correct.
Fixes: 76b822726ff8 ("erofs-utils: introduce compacted compression indexes")
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20230912221204.52184-1-dhavale@google.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Gao Xiang [Tue, 12 Sep 2023 11:50:59 +0000 (19:50 +0800)]
erofs-utils: mkfs: print filesystem summaries after success
Users may be interested in some details of the generated image.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230912115059.1997278-1-hsiangkao@linux.alibaba.com
Jingbo Xu [Tue, 12 Sep 2023 13:51:33 +0000 (21:51 +0800)]
erofs-utils: lib: fix memory leaks in error paths of erofs_build_shared_xattrs_from_path()
Free the allocated sorted_n[] buffer when some error occurs.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230912135134.21307-1-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Yifan Zhao [Sat, 9 Sep 2023 12:36:50 +0000 (20:36 +0800)]
erofs-utils: mkfs: error out if an extended option is unknown
Currently mkfs will ignore any unknown extended option, which keeps
silent if a mistyped option is given. Erroring out in this case
allows users to catch their input mistakes more easily.
Link: https://lore.kernel.org/r/20230909123650.2184838-1-zhaoyifan@sjtu.edu.cn
Signed-off-by: Yifan Zhao <zhaoyifan@sjtu.edu.cn>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Gao Xiang [Mon, 11 Sep 2023 07:18:19 +0000 (15:18 +0800)]
erofs-utils: mkfs: add ^{inline_data,ztailpacking,dedupe} options
Later, some preset configurations will be added, which could enable
some of these features by default.
Let's add a way to turn each individual off too.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230911071819.3714867-1-hsiangkao@linux.alibaba.com
Gao Xiang [Tue, 12 Sep 2023 03:27:01 +0000 (11:27 +0800)]
erofs-utils: lib: suppress a false-positive warning in kite-deflate
`gcc (Debian 13.2.0-2) 13.2.0` gives the following report:
kite_deflate.c: In function 'kite_deflate_writeblock':
kite_deflate.c:428:57: warning: 'distLevels' may be used uninitialized
[-Wmaybe-uninitialized]
428 | fixed ? 5 :
distLevels[distSlot]);
| ^
kite_deflate.c:393:34: note: 'distLevels' was declared here
393 | const u8 *litLenLevels, *distLevels;
Actually, `distLevels` won't be used in the static-huffman mode.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230912032701.8288-1-hsiangkao@linux.alibaba.com
Gao Xiang [Sat, 9 Sep 2023 16:32:32 +0000 (00:32 +0800)]
erofs-utils: lib: always fix up xattr_isize even w/o xattrs
Don't assume xattr_isize is 0 before since it's not true for the
upcoming rebuild mode.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230909163240.42057-6-hsiangkao@linux.alibaba.com
Jingbo Xu [Sat, 9 Sep 2023 16:32:31 +0000 (00:32 +0800)]
erofs-utils: lib: set OVL_XATTR_ORIGIN for directories with whiteouts
Whiteouts are exposed in the overlayfs mount if these are from some
non-merged directory without OVL_XATTR_ORIGIN set on the directory.
To fix this, tag OVL_XATTR_ORIGIN (with empty value) on the parent
directory of whiteouts.
Fixes: 95d315fd7958 ("erofs-utils: introduce tarerofs")
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230909163240.42057-5-hsiangkao@linux.alibaba.com
Jingbo Xu [Sat, 9 Sep 2023 16:32:30 +0000 (00:32 +0800)]
erofs-utils: lib: add erofs_inode_is_whiteout() helper
Add erofs_inode_is_whiteout() helper to check if a given inode is
a whiteout.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230909163240.42057-4-hsiangkao@linux.alibaba.com
Gao Xiang [Sat, 9 Sep 2023 16:32:29 +0000 (00:32 +0800)]
erofs-utils: lib: avoid exporting non-EROFS xattrs
Move all non-EROFS xattr macros to xattr.c and introduce
erofs_set_opaque_xattr() helper to hide all these details.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230909163240.42057-3-hsiangkao@linux.alibaba.com
Jingbo Xu [Sat, 9 Sep 2023 16:32:28 +0000 (00:32 +0800)]
erofs-utils: lib: remove unneeded NULL checks
get_xattritem() will in no way return NULL. Use DBG_BUGONs instead.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230909163240.42057-2-hsiangkao@linux.alibaba.com
Gao Xiang [Sun, 10 Sep 2023 11:57:44 +0000 (19:57 +0800)]
erofs-utils: get rid of useless (l)stat64 for MacOS
They break the MacOS build [1] and actually have no use anymore after
commit
7715b294087e ("erofs-utils: configure: Use 64bit off_t").
[1] https://github.com/erofs/erofsnightly/actions/runs/
6134394959/job/
16647166641
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230910115744.83819-1-hsiangkao@linux.alibaba.com
Gao Xiang [Thu, 7 Sep 2023 03:19:53 +0000 (11:19 +0800)]
erofs-utils: lib: fix an overflow issue of unmapped extents
`fuzz_erofsfsck` reports an issue [1] that:
$ fsck/fuzz_erofsfsck t2/erofsfsck_libfuzzer_jUknVp
==430136==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffe44a8de02 at pc 0x55932ea3640c bp 0x7ffe44a8b990 sp 0x7ffe44a8b160
WRITE of size
201338902 at 0x7ffe44a8de02 thread T0
#0 0x55932ea3640b in __asan_memset (/root/erofs-utils/fsck/fuzz_erofsfsck+0xf340b) (BuildId:
0bba6c9ddccb99f520b59bca08a3991a456f7cd4)
#1 0x55932ea8a8e2 in z_erofs_read_data /root/erofs-utils/lib/data.c:335:4
#2 0x55932ea8b136 in erofs_pread /root/erofs-utils/lib/data.c:369:10
Here the size should be `length - skip`, otherwise it could cause
the destination buffer overflow.
[1] https://github.com/erofs/erofsnightly/actions/runs/
6104429691/job/
16566461154
Fixes: 6c20a6afd871 ("erofs-utils: fuse: fix random readlink error")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230907031953.14356-1-hsiangkao@linux.alibaba.com
Gao Xiang [Tue, 5 Sep 2023 04:38:40 +0000 (12:38 +0800)]
erofs-utils: mkfs: don't warn dedupe and fragments features anymore
Keep in sync with kernel commit
5ec693ca70dd ("erofs: don't warn
dedupe and fragments features anymore").
Except that erofs.mkfs is still single-threaded as a limitation for
backup use cases.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230905043840.61616-1-hsiangkao@linux.alibaba.com
Guo Xuenan [Tue, 5 Sep 2023 02:32:07 +0000 (10:32 +0800)]
erofs-utils: fsck: refuse illegel filename
In some crafted erofs images, fsck.erofs may write outside the
destination directory, which may be used to do some dangerous things.
This commit fixes by checking all directory entry names with a '/'
character when fscking. Squashfs also met the same situation [1],
and have already fixed it here [2].
[1] https://github.com/plougher/squashfs-tools/issues/72
[2] https://github.com/plougher/squashfs-tools/commit/
79b5a555058eef4e1e7ff220c344d39f8cd09646
Fixes: 412c8f908132 ("erofs-utils: fsck: add --extract=X support to extract to path X")
Reviewed-by: Guo Xuenan <guoxuenan@huawei.com>
Signed-off-by: Guo Xuenan <guoxuenan@huawei.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230905023207.70314-1-hsiangkao@linux.alibaba.com
Gao Xiang [Fri, 1 Sep 2023 15:59:32 +0000 (23:59 +0800)]
erofs-utils: bail out properly if erofs_iget_from_path(root) fails
Or "Segmentation fault" can happen if errors are passed into
erofs_igrab().
Fixes: 21d84349e79a ("erofs-utils: rearrange on-disk metadata")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230901155932.105830-1-hsiangkao@linux.alibaba.com
Gao Xiang [Fri, 1 Sep 2023 03:16:34 +0000 (11:16 +0800)]
erofs-utils: lib: fix `last_mapped_block` in erofs_bflush()
Currently, calling erofs_bflush() multiple times is broken due to
outdated `last_mapped_block`.
Fixes: 82dee4501c5a ("erofs-utils: mkfs: enable xattr name filter feature by default")
Fixes: 185b0bcdef4b ("erofs-utils: optimize buffer allocation logic")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230901031634.115999-1-hsiangkao@linux.alibaba.com
Gao Xiang [Fri, 1 Sep 2023 07:26:42 +0000 (15:26 +0800)]
erofs-utils: lib: support importing xattrs from tarerofs
`SCHILY.xattr.attr` indicates a POSIX.1-2001 coded version of the
Linux extended attributes. Let's dump such xattrs to erofs images.
In addition, `LIBARCHIVE.xattr` is also supported, which uses
URL-Encoding instead of the binary form.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Tested-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230901072642.68200-1-hsiangkao@linux.alibaba.com
Sandeep Dhavale [Wed, 30 Aug 2023 23:16:06 +0000 (16:16 -0700)]
erofs-utils: Set mkfs default blocksize based on current platform
Set mkfs default blocksize to current platform pagesize.
This means mkfs with default options will work on current
platform. If we are building image for a platform for a different
blocksize, we can override default with -b option up to
EROFS_MAX_BLOCK_SIZE.
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20230830231606.3783734-2-dhavale@google.com
[ Gao Xiang: compare with EROFS_MAX_BLOCK_SIZE for safety. ]
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Sandeep Dhavale [Wed, 30 Aug 2023 23:16:05 +0000 (16:16 -0700)]
erofs-utils: Relax the hardchecks on the blocksize
As erofs-utils supports different block sizes upto
EROFS_MAX_BLOCK_SIZE, relax the checks so same tools
can be used to create images for platforms where
page size can be greater than 4096.
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20230830231606.3783734-1-dhavale@google.com
[ Gao Xiang: refine the warning message. ]
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Gao Xiang [Thu, 31 Aug 2023 10:29:49 +0000 (18:29 +0800)]
erofs-utils: mkfs: enable xattr name filter feature by default
Turn it on by default since it's a compatible feature. Instead,
it can be disabled explicitly with "-E^xattr-name-filter".
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230831102949.119605-1-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Tue, 29 Aug 2023 14:55:04 +0000 (22:55 +0800)]
erofs-utils: mkfs,dump: introduce xattr name filter feature
Introduce "-Exattr-name-filter" option to enable the xattr name bloom
filter feature.
Also support listing this feature in dump.erofs.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230829145504.93567-4-jefflexu@linux.alibaba.com
[ Gao Xiang: update the commit subject. ]
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Tue, 29 Aug 2023 14:55:03 +0000 (22:55 +0800)]
erofs-utils: update on-disk format for xattr name filter
Let's keep in sync with kernel commit
3f339920175c ("erofs: update
on-disk format for xattr name filter").
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230829145504.93567-3-jefflexu@linux.alibaba.com
[ Gao Xiang: truncate the commit message. ]
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Tue, 29 Aug 2023 14:55:02 +0000 (22:55 +0800)]
erofs-utils: add xxh32 library
Add xxh32 library which could be used by following xattr bloom filter
feature.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230829145504.93567-2-jefflexu@linux.alibaba.com
[ Gao Xiang: use `BSD-2-Clause OR GPL-2.0+` for "erofs/xxhash.h". ]
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Wed, 23 Aug 2023 07:15:09 +0000 (15:15 +0800)]
erofs-utils: lib: keep erofs_init_devices in sync with kernel
Keep erofs_init_devices() in sync with kernel erofs_scan_devices()[1],
which scans the devtable (if any) automatically if sbi->extra_devices is
not explicitly specified.
Also fix the missing le32_to_cpu() when parsing the device slot. Read
and cache the number of blocks of each device for later use.
[1] https://git.kernel.org/torvalds/c/
ba73eadd23d1
Fixes: 0ce853a01123 ("erofs-utils: fuse: add multiple device support")
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230823071517.12303-3-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Wed, 23 Aug 2023 07:15:08 +0000 (15:15 +0800)]
erofs-utils: lib: fix dirent type of whiteout in tarerofs
Set the correct dirent type for whiteout.
Fixes: 95d315fd7958 ("erofs-utils: introduce tarerofs")
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230823071517.12303-2-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Gao Xiang [Mon, 21 Aug 2023 09:39:29 +0000 (17:39 +0800)]
erofs-utils: sbi->devs should be cleared after freed
Otherwise, it could cause double-free if sbi reuses
when fuzzing [1].
[1] https://github.com/erofs/erofsnightly/actions/runs/
5921003885/job/
16053013007
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230821093929.17146-1-hsiangkao@linux.alibaba.com
Jingbo Xu [Wed, 16 Aug 2023 02:13:40 +0000 (10:13 +0800)]
erofs-utils: lib: keep self maintained devname
Keep self allocated and maintained devname in erofs_sb_info.
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230816021347.126886-6-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Wed, 16 Aug 2023 02:13:38 +0000 (10:13 +0800)]
erofs-utils: lib: read i_ino in erofs_read_inode_from_disk()
i_ino[0] is a unique inode serial number in the erofs filesystem to
count inodes one by one, while i_ino[1] is a unique number identifying
the source inode in the source directory, which is usually derived from
st->st_ino.
Read on-disk ino and store it in i_ino[0] given the above background.
Fixes: 5e35b75ad499 ("erofs-utils: introduce fuse implementation")
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230816021347.126886-4-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Wed, 16 Aug 2023 02:13:36 +0000 (10:13 +0800)]
erofs-utils: fix overriding of i_rdev for special device
In tarerofs index mode, tarerofs_write_chunk_indexes() is still called
even for files with i_size 0, and inode->u.chunkformat is initialized
accordingly. This will make the previously set inode->u.i_rdev be
overridden as u.chunkformat and u.i_rdev are reused in one union.
To tidy up the code of writing file, extract two helpers for index and
non-index modes. Also fix the missing erofs_iput() when
tarerofs_write_chunkes() fails.
Fixes: 95d315fd7958 ("erofs-utils: introduce tarerofs")
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230816021347.126886-2-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Thu, 17 Aug 2023 07:14:55 +0000 (15:14 +0800)]
erofs-utils: support long xattr name prefixes for erofsfuse
Make erofs_listxattr() and erofs_getxattr() routine support long xattr
name prefixes.
Although the on-disk format allows long xattr name prefixes to be placed
in the meta inode or packed inode, currently mkfs.erofs will place them
in packed inode by default. Thus let's also read long xattr name prefixes
from packed inode by default.
Since we need to read the content of the packed inode from disk when
loading long xattr name prefixes, add dependency on zlib_LIBS for
mkfs.erofs to resolve the compiling dependency.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230817071455.12040-4-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Thu, 17 Aug 2023 07:14:54 +0000 (15:14 +0800)]
erofs-utils: add erofs_read_metadata() helper
Add erofs_read_metadata() helper reading variable-sized metadata from
inode specified by @nid. Read from meta inode if @nid is 0.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230817071455.12040-3-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Thu, 17 Aug 2023 07:14:53 +0000 (15:14 +0800)]
erofs-utils: lib: add match_base_prefix() helper
Since the introduction of long xattr name prefix, match_prefix() will
search among the long xattr name prefixes first and return the matched
prefix, while erofs_getxattr() expects a base prefix even when the
queried xattr name matches a long prefix.
Thus introduce match_base_prefix() helper to do this.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230817071455.12040-2-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Wed, 16 Aug 2023 03:49:38 +0000 (11:49 +0800)]
erofs-utils: lib: fix potential out-of-bound in xattr_entrylist()
Check the index before accessing array to avoid the potential
out-of-bound access.
Fixes: c47df5aa2d16 ("erofs-utils: fuse: introduce xattr support")
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230816034941.126866-2-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Yue Hu [Tue, 15 Aug 2023 10:24:05 +0000 (18:24 +0800)]
AOSP: erofs-utils: add missing sbi argument to erofs_blknr in block list
Commit
fc30780ebf90 ("erofs-utils: lib: avoid global sbi dependencies
(take 1)") updated the macro erofs_blknr by adding sbi argument.
Fixes: fc30780ebf90 ("erofs-utils: lib: avoid global sbi dependencies (take 1)")
Signed-off-by: Yue Hu <huyue2@coolpad.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230815102405.19486-1-zbestahu@gmail.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Thu, 10 Aug 2023 06:46:33 +0000 (14:46 +0800)]
erofs-utils: lib: remove prototypes of removed functions
Remove prototypes of those that have been deleted.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230810064633.56218-2-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Thu, 10 Aug 2023 06:46:32 +0000 (14:46 +0800)]
erofs-utils: mkfs: fix double write of long xattr name prefixes
Fix double write of long xattr name prefixes in non-tarerofs mode.
Besides fix the compiling error of tar.h. Include "internal.h" to
introduce prototypes of `struct erofs_inode` and `struct erofs_sb_info`.
Fixes: 95d315fd7958 ("erofs-utils: introduce tarerofs")
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230810064633.56218-1-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Guo Xuenan [Tue, 8 Aug 2023 09:23:35 +0000 (17:23 +0800)]
erofs-utils: dump: print more superblock fields
Let's print compression algorithms and sb_extslots as well as update
feature information for dump.erofs.
The proposed superblock dump is shown as below:
Filesystem magic number: 0xE0F5E1E2
Filesystem blocks: 4624
Filesystem inode metadata start block: 0
Filesystem shared xattr metadata start block: 0
Filesystem root nid: 37
Filesystem compr_algs: lz4, lzma
Filesystem sb_extslots: 0
Filesystem inode count: 6131
Filesystem created: Wed Jun 7 17:15:44 2023
Filesystem features: sb_csum mtime 0padding compr_cfgs big_pcluster
Filesystem UUID: not available
Signed-off-by: Guo Xuenan <guoxuenan@huawei.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230808092335.111834-2-hsiangkao@linux.alibaba.com
Gao Xiang [Tue, 8 Aug 2023 09:23:34 +0000 (17:23 +0800)]
erofs-utils: lib: add a way to request supported algorithms
dump.erofs needs to print supported algorithms instead of available
compressors.
In addition, clean up erofs_get_compress_algorithm_id() too.
Tested-by: Guo Xuenan <guoxuenan@huawei.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230808092335.111834-1-hsiangkao@linux.alibaba.com
Gao Xiang [Thu, 3 Aug 2023 05:00:31 +0000 (13:00 +0800)]
erofs-utils: dump: use a new subdir context for erofs_get_pathname()
It's absolutely unsafe to reuse struct erofs_dir_context. Also,
we'd like to refactor erofs_get_pathname() in the future.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230803050031.130026-1-hsiangkao@linux.alibaba.com
Gao Xiang [Tue, 1 Aug 2023 13:27:55 +0000 (21:27 +0800)]
erofs-utils: generate preallocated extents for tarerofs
It is also useful to fill data blocks from tarballs at runtime in
order to implement image lazy pulling.
Let's generate an additional mapfile for such use cases:
mkfs.erofs --tar=0,MAPFILE IMAGE TARBALL
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230801132755.23997-1-hsiangkao@linux.alibaba.com
Jingbo Xu [Thu, 27 Jul 2023 04:57:05 +0000 (12:57 +0800)]
erofs-utils: lib: initialize i_nlink to 2 in erofs_init_empty_dir()
Set dir->i_nlink to 2 since "." and ".." are allocated.
Also, tarerofs_init_empty_dir() is removed then.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230727045712.45226-2-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Gao Xiang [Mon, 24 Jul 2023 17:06:46 +0000 (01:06 +0800)]
erofs-utils: lib: merge consecutive chunks if possible
Since EROFS chunk size can be configured on a per-file basis,
let's generate indexes with the best chunk size.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230724170646.22281-3-hsiangkao@linux.alibaba.com
Gao Xiang [Mon, 24 Jul 2023 17:06:45 +0000 (01:06 +0800)]
erofs-utils: lib: tidy up erofs_blob_getchunk()
Mainly get rid of memory allocation on each chunk.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230724170646.22281-2-hsiangkao@linux.alibaba.com
Gao Xiang [Mon, 24 Jul 2023 17:06:44 +0000 (01:06 +0800)]
erofs-utils: lib: fix improper alignment for chunked sparse files
File position should be fixed to aligned with the chunk boundary.
Otherwise, incorrect data could be read.
Fixes: 7c49e8b195ad ("erofs-utils: support chunk-based sparse files")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230724170646.22281-1-hsiangkao@linux.alibaba.com
Gao Xiang [Fri, 21 Jul 2023 05:07:55 +0000 (13:07 +0800)]
AOSP: erofs-utils: mkfs: fix block list support for chunked files
chunksize may not always equal to blocksize (e.g. 4KiB). Also it can
lead to unexpected behaviors when the consecutive chunk merging is
implemented later since the chunksize is also on a per-file basis.
Fixes: d9a01943f8c5 ("AOSP: erofs-utils: mkfs: add block list support for chunked files")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230721050755.82122-1-hsiangkao@linux.alibaba.com
Jingbo Xu [Thu, 20 Jul 2023 07:31:04 +0000 (15:31 +0800)]
erofs-utils: lib: avoid global sbi dependencies (take 1)
Later mkfs is going to be able to convert multiple erofs images into
one merged erofs image, in which case there are multiple device
contexts and sbi instances.
In preparation for that, remove global device context and sbi if
possible except the buffer cache implementation, as there's still only
one erofs output image.
The device context is now folded into sbi. Global sbi still exists
but it is only used by binaries directly, e.g. mkfs/dump/fsck.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230720073104.116439-1-hsiangkao@linux.alibaba.com
Li Yiyan [Tue, 25 Jul 2023 08:50:20 +0000 (16:50 +0800)]
erofs-utils: fix compilation error due to const static init
gcc-7 and earlier versions fail to infer the initial value of a
const global variable from another const global variable. Therefore,
compiling with gcc-7 and below will result in failure. In fact, for
global const variables, using macros is a better choice.
Signed-off-by: Li Yiyan <lyy0627@sjtu.edu.cn>
Link: https://lore.kernel.org/r/20230725085020.904884-1-lyy0627@sjtu.edu.cn
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Wed, 19 Jul 2023 07:33:18 +0000 (15:33 +0800)]
erofs-utils: simplify iloc()
Let's follow kernel commit
b780d3fc6107 ("erofs: simplify iloc()") by
passing in inodes directly to clean up all callers. Also rename iloc()
as erofs_iloc().
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230719073319.27996-2-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Tue, 18 Jul 2023 05:21:00 +0000 (13:21 +0800)]
erofs-utils: lib: inline vle_compressmeta_capacity()
The helper is not quite useful.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230718052101.124039-4-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Gao Xiang [Mon, 17 Jul 2023 07:35:31 +0000 (15:35 +0800)]
erofs-utils: lib: support GNUTYPE_LONGNAME for tarerofs
The 'L' entry is present in a header for a series of 1 or more 512-byte
tar blocks that hold just the filename for a file or directory with a
name over 100 chars.
Following that series is another header block, in the traditional form:
A header with type '0' (regular file) or '5' (directory), followed by
the appropriate number of data blocks with the entry data.
In the header for this series, the name will be truncated to the 1st 100
characters of the actual name.
Tested-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230717073531.43203-1-hsiangkao@linux.alibaba.com
Gao Xiang [Fri, 14 Jul 2023 06:58:51 +0000 (14:58 +0800)]
erofs-utils: introduce tarerofs
Let's try to add a new mode "tarerofs" for mkfs.erofs.
It mainly aims at two use cases:
- Convert a tarball (or later tarballs with a merged view) into
a full EROFS image [--tar=f];
- Generate an EROFS manifest image to reuse tar data [--tar=i],
which also enables EROFS 512-byte blocks.
The second use case is mainly prepared for OCI direct mount without
OCI blob unpacking. This also adds another `--aufs` option to
transform aufs special files into overlayfs metadata.
[ Note that `--tar=f` generates lots of temporary files for now which
can impact performance since the original tar stream(s) may be
non-seekable. ]
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230714065851.70583-1-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Gao Xiang [Mon, 10 Jul 2023 11:02:51 +0000 (19:02 +0800)]
erofs-utils: mkfs: add libdeflate compressor support
Eric suggests a "binary search + heuristics" way by using the
current libdeflate APIs to generate fixed-sized output DEFLATE streams.
Compared to the previous built-in one, it will generate smaller images
(which is expected since the built-in one is roughly just the original
zlib replacement), yet the total compression time might be amplified a
lot especially if some larger pclusters are used by users compared to
the built-in one.
For example:
$ time mkfs.erofs -zdeflate,9 -C65536 enwik8.z enwik8
real 0m9.559s
user 0m9.453s
sys 0m0.069s
$ time mkfs.erofs -zlibdeflate,9 -C65536 enwik8.libdeflate.9.z enwik8
real 0m50.184s
user 0m50.082s
sys 0m0.074s
$ mkfs/mkfs.erofs -zlibdeflate,6 -C65536 enwik8.libdeflate.6.z enwik8
real 0m23.428s
user 0m23.329s
sys 0m0.067s
37175296 enwik8.libdeflate.6.z
37142528 enwik8.z
36835328 enwik8.libdeflate.9.z
Anyway, let's use the current APIs for users who needs smaller image
sizes for now. Besides, EROFS also supports multiple per-file
algorithms in one image, so it can be used for specific files as well.
Suggested-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230710110251.89464-5-hsiangkao@linux.alibaba.com
Gao Xiang [Mon, 10 Jul 2023 11:02:50 +0000 (19:02 +0800)]
erofs-utils: mkfs: add DEFLATE algorithm support
This patch adds DEFLATE compression algorithm support to erofs-utils
compression framework.
Note that windowbits (which indicates dictionary size) is recorded in
the on-disk compression configuration. Since some accelerators (e.g.
Intel IAA) don't have enough on-chip memory, compressed data generated
with large windowbits (e.g. > 12 for the IAA accelerator) doesn't seem
to be worked properly on those.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230710110251.89464-4-hsiangkao@linux.alibaba.com
Gao Xiang [Wed, 12 Jul 2023 23:51:43 +0000 (07:51 +0800)]
erofs-utils: fuse,fsck: add DEFLATE algorithm support
This patch adds DEFLATE compression algorithm support to erofsfuse
by using zlib (by default) and libdeflate. libdeflate will be used
instead of zlib if libdeflate is enabled.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230712235143.10125-1-hsiangkao@linux.alibaba.com
Gao Xiang [Mon, 10 Jul 2023 11:02:48 +0000 (19:02 +0800)]
erofs-utils: add a built-in DEFLATE compressor
As Apple documentation written "If you require interoperability with
non-Apple devices, use COMPRESSION_ZLIB. [1]", DEFLATE is a popular
generic-purpose compression algorithm for a quite long time (many
advanced formats like zlib, gzip, zip, png are all based on that),
which is made of LZ77 as well as Huffman coding, fully documented as
RFC1951 [2] and quite easy to understand, implement.
There are several hardware on-market DEFLATE accelerators as well,
such as (s390) DFLTCC, (Intel) IAA/QAT, (HiSilicon) ZIP accelerator,
etc. Therefore, it's useful to support DEFLATE compression in order
to use these for async I/Os and get benefits from these.
Since there is _no fixed-sized output DEFLATE compression appoach_
available in public (fitblk is somewhat ineffective) and the original
zlib is quite slowly developping, let's work out one for our use cases.
Fortunately, it's only less than 1.5kLOC with lazy matching to just
match the full zlib abilities. Besides, near-optimal block splitting
(based on price function) doesn't support since it's no rush to us.
In the future, there might be more built-in optimizers landed to
fulfill our needs even further (especially for other popular algorithms
without native fixed-sized output support). In addition, I'd be quite
happy to see more popular encoders to support native fixed-sized output
compression too.
[1] https://developer.apple.com/documentation/compression/compression_algorithm
[2] https://datatracker.ietf.org/doc/html/rfc1951
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230710110251.89464-2-hsiangkao@linux.alibaba.com
Gao Xiang [Thu, 13 Jul 2023 11:10:46 +0000 (19:10 +0800)]
erofs-utils: add github issue/pull-request templates
EROFS Development is currently on the mailing list _only_.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230713111046.62793-1-hsiangkao@linux.alibaba.com
Jingbo Xu [Tue, 11 Jul 2023 06:12:39 +0000 (14:12 +0800)]
erofs-utils: add ERR_CAST macro
Add ERR_CAST macro to prepare for the upcoming tarerofs feature.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230711061240.23662-1-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Yue Hu [Tue, 11 Jul 2023 03:25:08 +0000 (11:25 +0800)]
erofs-utils: lib: fix small compressed files inlining
Keep in sync with kernel commit
24331050a3e6 ("erofs: fix small
compressed files inlining") to avoid corruption due to m_llen > m_plen
for uncompressed pclusters.
Fixes: 41790d24329d ("erofs-utils: validate the extent length for uncompressed pclusters")
Signed-off-by: Yue Hu <huyue2@coolpad.com>
Link: https://lore.kernel.org/r/20230711032508.6892-1-zbestahu@gmail.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Gao Xiang [Sun, 9 Jul 2023 18:25:08 +0000 (02:25 +0800)]
erofs-utils: switch to effective unaligned access
In order to prepare for LZ77 matchfinder. Note that erofs_memcmp2()
is still not quite effective.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230709182511.96954-2-hsiangkao@linux.alibaba.com
Norbert Lange [Mon, 3 Jul 2023 21:58:03 +0000 (23:58 +0200)]
erofs-utils: Provide identical functionality without libuuid
The motivation is to have standalone (statically linked) erofs binaries
for simple initrd images, that are nevertheless able to (re)create
erofs images with a given UUID.
For this reason a few of libuuid functions have implementations added
directly in erofs-utils.
A header liberofs_uuid.h provides the new functions, which are
always available. A further sideeffect is that code can be simplified
which calls into this functionality.
The uuid_unparse function replacement is always a private
implementation and split into its own file, this further restricts
the (optional) dependency on libuuid only to the erofs-mkfs tool.
Signed-off-by: Norbert Lange <nolange79@gmail.com>
Link: https://lore.kernel.org/r/20230703215803.4476-1-nolange79@gmail.com
[ Gao Xiang: a getrandom() fix since it was added in glibc 2.25. ]
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Huang Jianan [Mon, 3 Jul 2023 09:35:31 +0000 (17:35 +0800)]
erofs-utils: update my email address in AUTHORS
Update the invalid email address.
Signed-off-by: Huang Jianan <jnhuang95@gmail.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230703093531.22832-1-jnhuang95@gmail.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Yue Hu [Wed, 28 Jun 2023 02:25:58 +0000 (10:25 +0800)]
erofs-utils: fsck: add support for extracting hard links
Currently hard links can't be extracted correctly, let's support it now.
Signed-off-by: Yue Hu <huyue2@coolpad.com>
Fixes: 412c8f908132 ("erofs-utils: fsck: add --extract=X support to extract to path X")
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230628022558.6198-1-zbestahu@gmail.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Yifan Zhao [Sun, 25 Jun 2023 08:08:19 +0000 (16:08 +0800)]
erofs-utils: lib: fallback for copy_file_range
If tmpfs is used for /tmp and blob device is not specified, we need to
copy data between two different file systems during mkfs, which is not
supported by the copy_file_range() syscall. In this case, let's give it
a second chance by fallback to __erofs_copy_file_range().
Link: https://lore.kernel.org/r/20230625080819.44502-1-zhaoyifan@sjtu.edu.cn
Fixes: e9afc0408745 ("erofs-utils: introduce copy_file_range")
Fixes: 03cbf7b8f7f7 ("erofs-utils: mkfs: support chunk-based uncompressed files")
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Yifan Zhao <zhaoyifan@sjtu.edu.cn>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Jingbo Xu [Fri, 9 Jun 2023 09:02:25 +0000 (17:02 +0800)]
erofs-utils: mkfs: twist calculation of shared_xattr_id
The on-disk format specifies that share xattr can be addressed by:
xattr offset = xattr_blkaddr * block_size + 4 * shared_xattr_id
That is, the shared_xattr_id is calculated from the xattr offset
(starting from xattr_blkaddr) divided by 4. Make this semantics
explicitly by calculating the divisor from 'sizeof(__le32)'.
It has no logic change.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230609090225.91890-1-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>