diff options
author | Gao Xiang <hsiangkao@linux.alibaba.com> | 2021-09-23 02:56:07 +0800 |
---|---|---|
committer | Gao Xiang <hsiangkao@linux.alibaba.com> | 2021-09-24 09:09:13 +0800 |
commit | 03cbf7b8f7f7d4a2b447c4c072f399ef08118729 (patch) | |
tree | a6073046dd03ce7db5d1402b683b5400f8bee0d7 /include | |
parent | e9afc04087450a2711fcdbf49d5b2d076ec29e58 (diff) | |
download | erofs-utils-03cbf7b8f7f7d4a2b447c4c072f399ef08118729.tar.gz |
erofs-utils: mkfs: support chunk-based uncompressed files
mkfs support for the new chunk-based uncompressed files,
including:
* chunk-based files with 4-byte block address array;
* chunk-based files with 8-byte inode chunk indexes.
Link: https://lore.kernel.org/r/20210922185607.49909-6-hsiangkao@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/erofs/blobchunk.h | 18 | ||||
-rw-r--r-- | include/erofs/config.h | 1 | ||||
-rw-r--r-- | include/erofs/defs.h | 77 | ||||
-rw-r--r-- | include/erofs/hashtable.h | 77 | ||||
-rw-r--r-- | include/erofs/internal.h | 1 | ||||
-rw-r--r-- | include/erofs/io.h | 2 |
6 files changed, 99 insertions, 77 deletions
diff --git a/include/erofs/blobchunk.h b/include/erofs/blobchunk.h new file mode 100644 index 0000000..b418227 --- /dev/null +++ b/include/erofs/blobchunk.h @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * erofs-utils/lib/blobchunk.h + * + * Copyright (C) 2021, Alibaba Cloud + */ +#ifndef __EROFS_BLOBCHUNK_H +#define __EROFS_BLOBCHUNK_H + +#include "erofs/internal.h" + +int erofs_blob_write_chunk_indexes(struct erofs_inode *inode, erofs_off_t off); +int erofs_blob_write_chunked_file(struct erofs_inode *inode); +int erofs_blob_remap(void); +void erofs_blob_exit(void); +int erofs_blob_init(void); + +#endif diff --git a/include/erofs/config.h b/include/erofs/config.h index d5d9b5a..574dd52 100644 --- a/include/erofs/config.h +++ b/include/erofs/config.h @@ -42,6 +42,7 @@ struct erofs_configure { bool c_random_pclusterblks; #endif char c_timeinherit; + char c_chunkbits; bool c_noinline_data; #ifdef HAVE_LIBSELINUX diff --git a/include/erofs/defs.h b/include/erofs/defs.h index 6e0a777..96bbb65 100644 --- a/include/erofs/defs.h +++ b/include/erofs/defs.h @@ -175,6 +175,83 @@ static inline u32 get_unaligned_le32(const u8 *p) return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24; } +/** + * ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value + * @n - parameter + * + * constant-capable log of base 2 calculation + * - this can be used to initialise global variables from constant data, hence + * the massive ternary operator construction + * + * selects the appropriately-sized optimised version depending on sizeof(n) + */ +#define ilog2(n) \ +( \ + (n) & (1ULL << 63) ? 63 : \ + (n) & (1ULL << 62) ? 62 : \ + (n) & (1ULL << 61) ? 61 : \ + (n) & (1ULL << 60) ? 60 : \ + (n) & (1ULL << 59) ? 59 : \ + (n) & (1ULL << 58) ? 58 : \ + (n) & (1ULL << 57) ? 57 : \ + (n) & (1ULL << 56) ? 56 : \ + (n) & (1ULL << 55) ? 55 : \ + (n) & (1ULL << 54) ? 54 : \ + (n) & (1ULL << 53) ? 53 : \ + (n) & (1ULL << 52) ? 52 : \ + (n) & (1ULL << 51) ? 51 : \ + (n) & (1ULL << 50) ? 50 : \ + (n) & (1ULL << 49) ? 49 : \ + (n) & (1ULL << 48) ? 48 : \ + (n) & (1ULL << 47) ? 47 : \ + (n) & (1ULL << 46) ? 46 : \ + (n) & (1ULL << 45) ? 45 : \ + (n) & (1ULL << 44) ? 44 : \ + (n) & (1ULL << 43) ? 43 : \ + (n) & (1ULL << 42) ? 42 : \ + (n) & (1ULL << 41) ? 41 : \ + (n) & (1ULL << 40) ? 40 : \ + (n) & (1ULL << 39) ? 39 : \ + (n) & (1ULL << 38) ? 38 : \ + (n) & (1ULL << 37) ? 37 : \ + (n) & (1ULL << 36) ? 36 : \ + (n) & (1ULL << 35) ? 35 : \ + (n) & (1ULL << 34) ? 34 : \ + (n) & (1ULL << 33) ? 33 : \ + (n) & (1ULL << 32) ? 32 : \ + (n) & (1ULL << 31) ? 31 : \ + (n) & (1ULL << 30) ? 30 : \ + (n) & (1ULL << 29) ? 29 : \ + (n) & (1ULL << 28) ? 28 : \ + (n) & (1ULL << 27) ? 27 : \ + (n) & (1ULL << 26) ? 26 : \ + (n) & (1ULL << 25) ? 25 : \ + (n) & (1ULL << 24) ? 24 : \ + (n) & (1ULL << 23) ? 23 : \ + (n) & (1ULL << 22) ? 22 : \ + (n) & (1ULL << 21) ? 21 : \ + (n) & (1ULL << 20) ? 20 : \ + (n) & (1ULL << 19) ? 19 : \ + (n) & (1ULL << 18) ? 18 : \ + (n) & (1ULL << 17) ? 17 : \ + (n) & (1ULL << 16) ? 16 : \ + (n) & (1ULL << 15) ? 15 : \ + (n) & (1ULL << 14) ? 14 : \ + (n) & (1ULL << 13) ? 13 : \ + (n) & (1ULL << 12) ? 12 : \ + (n) & (1ULL << 11) ? 11 : \ + (n) & (1ULL << 10) ? 10 : \ + (n) & (1ULL << 9) ? 9 : \ + (n) & (1ULL << 8) ? 8 : \ + (n) & (1ULL << 7) ? 7 : \ + (n) & (1ULL << 6) ? 6 : \ + (n) & (1ULL << 5) ? 5 : \ + (n) & (1ULL << 4) ? 4 : \ + (n) & (1ULL << 3) ? 3 : \ + (n) & (1ULL << 2) ? 2 : \ + (n) & (1ULL << 1) ? 1 : 0 \ +) + #ifndef __always_inline #define __always_inline inline #endif diff --git a/include/erofs/hashtable.h b/include/erofs/hashtable.h index a71cb00..90eb84e 100644 --- a/include/erofs/hashtable.h +++ b/include/erofs/hashtable.h @@ -262,83 +262,6 @@ static __always_inline u32 hash_64(u64 val, unsigned int bits) #endif } -/** - * ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value - * @n - parameter - * - * constant-capable log of base 2 calculation - * - this can be used to initialise global variables from constant data, hence - * the massive ternary operator construction - * - * selects the appropriately-sized optimised version depending on sizeof(n) - */ -#define ilog2(n) \ -( \ - (n) & (1ULL << 63) ? 63 : \ - (n) & (1ULL << 62) ? 62 : \ - (n) & (1ULL << 61) ? 61 : \ - (n) & (1ULL << 60) ? 60 : \ - (n) & (1ULL << 59) ? 59 : \ - (n) & (1ULL << 58) ? 58 : \ - (n) & (1ULL << 57) ? 57 : \ - (n) & (1ULL << 56) ? 56 : \ - (n) & (1ULL << 55) ? 55 : \ - (n) & (1ULL << 54) ? 54 : \ - (n) & (1ULL << 53) ? 53 : \ - (n) & (1ULL << 52) ? 52 : \ - (n) & (1ULL << 51) ? 51 : \ - (n) & (1ULL << 50) ? 50 : \ - (n) & (1ULL << 49) ? 49 : \ - (n) & (1ULL << 48) ? 48 : \ - (n) & (1ULL << 47) ? 47 : \ - (n) & (1ULL << 46) ? 46 : \ - (n) & (1ULL << 45) ? 45 : \ - (n) & (1ULL << 44) ? 44 : \ - (n) & (1ULL << 43) ? 43 : \ - (n) & (1ULL << 42) ? 42 : \ - (n) & (1ULL << 41) ? 41 : \ - (n) & (1ULL << 40) ? 40 : \ - (n) & (1ULL << 39) ? 39 : \ - (n) & (1ULL << 38) ? 38 : \ - (n) & (1ULL << 37) ? 37 : \ - (n) & (1ULL << 36) ? 36 : \ - (n) & (1ULL << 35) ? 35 : \ - (n) & (1ULL << 34) ? 34 : \ - (n) & (1ULL << 33) ? 33 : \ - (n) & (1ULL << 32) ? 32 : \ - (n) & (1ULL << 31) ? 31 : \ - (n) & (1ULL << 30) ? 30 : \ - (n) & (1ULL << 29) ? 29 : \ - (n) & (1ULL << 28) ? 28 : \ - (n) & (1ULL << 27) ? 27 : \ - (n) & (1ULL << 26) ? 26 : \ - (n) & (1ULL << 25) ? 25 : \ - (n) & (1ULL << 24) ? 24 : \ - (n) & (1ULL << 23) ? 23 : \ - (n) & (1ULL << 22) ? 22 : \ - (n) & (1ULL << 21) ? 21 : \ - (n) & (1ULL << 20) ? 20 : \ - (n) & (1ULL << 19) ? 19 : \ - (n) & (1ULL << 18) ? 18 : \ - (n) & (1ULL << 17) ? 17 : \ - (n) & (1ULL << 16) ? 16 : \ - (n) & (1ULL << 15) ? 15 : \ - (n) & (1ULL << 14) ? 14 : \ - (n) & (1ULL << 13) ? 13 : \ - (n) & (1ULL << 12) ? 12 : \ - (n) & (1ULL << 11) ? 11 : \ - (n) & (1ULL << 10) ? 10 : \ - (n) & (1ULL << 9) ? 9 : \ - (n) & (1ULL << 8) ? 8 : \ - (n) & (1ULL << 7) ? 7 : \ - (n) & (1ULL << 6) ? 6 : \ - (n) & (1ULL << 5) ? 5 : \ - (n) & (1ULL << 4) ? 4 : \ - (n) & (1ULL << 3) ? 3 : \ - (n) & (1ULL << 2) ? 2 : \ - (n) & (1ULL << 1) ? 1 : 0 \ -) - #define DEFINE_HASHTABLE(name, bits) \ struct hlist_head name[1 << (bits)] = \ { [0 ... ((1 << (bits)) - 1)] = HLIST_HEAD_INIT } diff --git a/include/erofs/internal.h b/include/erofs/internal.h index 8621f34..8b154ed 100644 --- a/include/erofs/internal.h +++ b/include/erofs/internal.h @@ -165,6 +165,7 @@ struct erofs_inode { union { void *compressmeta; + void *chunkindexes; struct { uint16_t z_advise; uint8_t z_algorithmtype[2]; diff --git a/include/erofs/io.h b/include/erofs/io.h index 2597bf4..2597c5c 100644 --- a/include/erofs/io.h +++ b/include/erofs/io.h @@ -25,6 +25,8 @@ int dev_fsync(void); int dev_resize(erofs_blk_t nblocks); u64 dev_length(void); +extern int erofs_devfd; + int erofs_copy_file_range(int fd_in, erofs_off_t *off_in, int fd_out, erofs_off_t *off_out, size_t length); |