4
4
*
5
5
* Copyright (C) 2017-2018 HUAWEI, Inc.
6
6
* https://www.huawei.com/
7
+ * Copyright (C) 2021, Alibaba Cloud
7
8
*/
8
9
#ifndef __EROFS_FS_H
9
10
#define __EROFS_FS_H
19
20
#define EROFS_FEATURE_INCOMPAT_LZ4_0PADDING 0x00000001
20
21
#define EROFS_FEATURE_INCOMPAT_COMPR_CFGS 0x00000002
21
22
#define EROFS_FEATURE_INCOMPAT_BIG_PCLUSTER 0x00000002
23
+ #define EROFS_FEATURE_INCOMPAT_CHUNKED_FILE 0x00000004
22
24
#define EROFS_ALL_FEATURE_INCOMPAT \
23
25
(EROFS_FEATURE_INCOMPAT_LZ4_0PADDING | \
24
26
EROFS_FEATURE_INCOMPAT_COMPR_CFGS | \
25
- EROFS_FEATURE_INCOMPAT_BIG_PCLUSTER)
27
+ EROFS_FEATURE_INCOMPAT_BIG_PCLUSTER | \
28
+ EROFS_FEATURE_INCOMPAT_CHUNKED_FILE)
26
29
27
30
#define EROFS_SB_EXTSLOT_SIZE 16
28
31
@@ -64,13 +67,16 @@ struct erofs_super_block {
64
67
* inode, [xattrs], last_inline_data, ... | ... | no-holed data
65
68
* 3 - inode compression D:
66
69
* inode, [xattrs], map_header, extents ... | ...
67
- * 4~7 - reserved
70
+ * 4 - inode chunk-based E:
71
+ * inode, [xattrs], chunk indexes ... | ...
72
+ * 5~7 - reserved
68
73
*/
69
74
enum {
70
75
EROFS_INODE_FLAT_PLAIN = 0 ,
71
76
EROFS_INODE_FLAT_COMPRESSION_LEGACY = 1 ,
72
77
EROFS_INODE_FLAT_INLINE = 2 ,
73
78
EROFS_INODE_FLAT_COMPRESSION = 3 ,
79
+ EROFS_INODE_CHUNK_BASED = 4 ,
74
80
EROFS_INODE_DATALAYOUT_MAX
75
81
};
76
82
@@ -90,6 +96,19 @@ static inline bool erofs_inode_is_data_compressed(unsigned int datamode)
90
96
#define EROFS_I_ALL \
91
97
((1 << (EROFS_I_DATALAYOUT_BIT + EROFS_I_DATALAYOUT_BITS)) - 1)
92
98
99
+ /* indicate chunk blkbits, thus 'chunksize = blocksize << chunk blkbits' */
100
+ #define EROFS_CHUNK_FORMAT_BLKBITS_MASK 0x001F
101
+ /* with chunk indexes or just a 4-byte blkaddr array */
102
+ #define EROFS_CHUNK_FORMAT_INDEXES 0x0020
103
+
104
+ #define EROFS_CHUNK_FORMAT_ALL \
105
+ (EROFS_CHUNK_FORMAT_BLKBITS_MASK | EROFS_CHUNK_FORMAT_INDEXES)
106
+
107
+ struct erofs_inode_chunk_info {
108
+ __le16 format ; /* chunk blkbits, etc. */
109
+ __le16 reserved ;
110
+ };
111
+
93
112
/* 32-byte reduced form of an ondisk inode */
94
113
struct erofs_inode_compact {
95
114
__le16 i_format ; /* inode format hints */
@@ -107,6 +126,9 @@ struct erofs_inode_compact {
107
126
108
127
/* for device files, used to indicate old/new device # */
109
128
__le32 rdev ;
129
+
130
+ /* for chunk-based files, it contains the summary info */
131
+ struct erofs_inode_chunk_info c ;
110
132
} i_u ;
111
133
__le32 i_ino ; /* only used for 32-bit stat compatibility */
112
134
__le16 i_uid ;
@@ -135,6 +157,9 @@ struct erofs_inode_extended {
135
157
136
158
/* for device files, used to indicate old/new device # */
137
159
__le32 rdev ;
160
+
161
+ /* for chunk-based files, it contains the summary info */
162
+ struct erofs_inode_chunk_info c ;
138
163
} i_u ;
139
164
140
165
/* only used for 32-bit stat compatibility */
@@ -204,6 +229,19 @@ static inline unsigned int erofs_xattr_entry_size(struct erofs_xattr_entry *e)
204
229
e -> e_name_len + le16_to_cpu (e -> e_value_size ));
205
230
}
206
231
232
+ /* represent a zeroed chunk (hole) */
233
+ #define EROFS_NULL_ADDR -1
234
+
235
+ /* 4-byte block address array */
236
+ #define EROFS_BLOCK_MAP_ENTRY_SIZE sizeof(__le32)
237
+
238
+ /* 8-byte inode chunk indexes */
239
+ struct erofs_inode_chunk_index {
240
+ __le16 advise ; /* always 0, don't care for now */
241
+ __le16 device_id ; /* back-end storage id, always 0 for now */
242
+ __le32 blkaddr ; /* start block address of this inode chunk */
243
+ };
244
+
207
245
/* maximum supported size of a physical compression cluster */
208
246
#define Z_EROFS_PCLUSTER_MAX_SIZE (1024 * 1024)
209
247
@@ -338,9 +376,14 @@ static inline void erofs_check_ondisk_layout_definitions(void)
338
376
BUILD_BUG_ON (sizeof (struct erofs_inode_extended ) != 64 );
339
377
BUILD_BUG_ON (sizeof (struct erofs_xattr_ibody_header ) != 12 );
340
378
BUILD_BUG_ON (sizeof (struct erofs_xattr_entry ) != 4 );
379
+ BUILD_BUG_ON (sizeof (struct erofs_inode_chunk_info ) != 4 );
380
+ BUILD_BUG_ON (sizeof (struct erofs_inode_chunk_index ) != 8 );
341
381
BUILD_BUG_ON (sizeof (struct z_erofs_map_header ) != 8 );
342
382
BUILD_BUG_ON (sizeof (struct z_erofs_vle_decompressed_index ) != 8 );
343
383
BUILD_BUG_ON (sizeof (struct erofs_dirent ) != 12 );
384
+ /* keep in sync between 2 index structures for better extendibility */
385
+ BUILD_BUG_ON (sizeof (struct erofs_inode_chunk_index ) !=
386
+ sizeof (struct z_erofs_vle_decompressed_index ));
344
387
345
388
BUILD_BUG_ON (BIT (Z_EROFS_VLE_DI_CLUSTER_TYPE_BITS ) <
346
389
Z_EROFS_VLE_CLUSTER_TYPE_MAX - 1 );
0 commit comments