@@ -82,32 +82,27 @@ struct erofs_super_block {
82
82
};
83
83
84
84
/*
85
- * erofs inode datalayout (i_format in on-disk inode):
85
+ * EROFS inode datalayout (i_format in on-disk inode):
86
86
* 0 - uncompressed flat inode without tail-packing inline data:
87
- * inode, [xattrs], ... | ... | no-holed data
88
87
* 1 - compressed inode with non-compact indexes:
89
- * inode, [xattrs], [map_header], extents ... | ...
90
88
* 2 - uncompressed flat inode with tail-packing inline data:
91
- * inode, [xattrs], tailpacking data, ... | ... | no-holed data
92
89
* 3 - compressed inode with compact indexes:
93
- * inode, [xattrs], map_header, extents ... | ...
94
90
* 4 - chunk-based inode with (optional) multi-device support:
95
- * inode, [xattrs], chunk indexes ... | ...
96
91
* 5~7 - reserved
97
92
*/
98
93
enum {
99
94
EROFS_INODE_FLAT_PLAIN = 0 ,
100
- EROFS_INODE_FLAT_COMPRESSION_LEGACY = 1 ,
95
+ EROFS_INODE_COMPRESSED_FULL = 1 ,
101
96
EROFS_INODE_FLAT_INLINE = 2 ,
102
- EROFS_INODE_FLAT_COMPRESSION = 3 ,
97
+ EROFS_INODE_COMPRESSED_COMPACT = 3 ,
103
98
EROFS_INODE_CHUNK_BASED = 4 ,
104
99
EROFS_INODE_DATALAYOUT_MAX
105
100
};
106
101
107
102
static inline bool erofs_inode_is_data_compressed (unsigned int datamode )
108
103
{
109
- return datamode == EROFS_INODE_FLAT_COMPRESSION ||
110
- datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY ;
104
+ return datamode == EROFS_INODE_COMPRESSED_COMPACT ||
105
+ datamode == EROFS_INODE_COMPRESSED_FULL ;
111
106
}
112
107
113
108
/* bit definitions of inode i_format */
@@ -128,11 +123,30 @@ static inline bool erofs_inode_is_data_compressed(unsigned int datamode)
128
123
#define EROFS_CHUNK_FORMAT_ALL \
129
124
(EROFS_CHUNK_FORMAT_BLKBITS_MASK | EROFS_CHUNK_FORMAT_INDEXES)
130
125
126
+ /* 32-byte on-disk inode */
127
+ #define EROFS_INODE_LAYOUT_COMPACT 0
128
+ /* 64-byte on-disk inode */
129
+ #define EROFS_INODE_LAYOUT_EXTENDED 1
130
+
131
131
struct erofs_inode_chunk_info {
132
132
__le16 format ; /* chunk blkbits, etc. */
133
133
__le16 reserved ;
134
134
};
135
135
136
+ union erofs_inode_i_u {
137
+ /* total compressed blocks for compressed inodes */
138
+ __le32 compressed_blocks ;
139
+
140
+ /* block address for uncompressed flat inodes */
141
+ __le32 raw_blkaddr ;
142
+
143
+ /* for device files, used to indicate old/new device # */
144
+ __le32 rdev ;
145
+
146
+ /* for chunk-based files, it contains the summary info */
147
+ struct erofs_inode_chunk_info c ;
148
+ };
149
+
136
150
/* 32-byte reduced form of an ondisk inode */
137
151
struct erofs_inode_compact {
138
152
__le16 i_format ; /* inode format hints */
@@ -143,29 +157,14 @@ struct erofs_inode_compact {
143
157
__le16 i_nlink ;
144
158
__le32 i_size ;
145
159
__le32 i_reserved ;
146
- union {
147
- /* total compressed blocks for compressed inodes */
148
- __le32 compressed_blocks ;
149
- /* block address for uncompressed flat inodes */
150
- __le32 raw_blkaddr ;
151
-
152
- /* for device files, used to indicate old/new device # */
153
- __le32 rdev ;
154
-
155
- /* for chunk-based files, it contains the summary info */
156
- struct erofs_inode_chunk_info c ;
157
- } i_u ;
158
- __le32 i_ino ; /* only used for 32-bit stat compatibility */
160
+ union erofs_inode_i_u i_u ;
161
+
162
+ __le32 i_ino ; /* only used for 32-bit stat compatibility */
159
163
__le16 i_uid ;
160
164
__le16 i_gid ;
161
165
__le32 i_reserved2 ;
162
166
};
163
167
164
- /* 32-byte on-disk inode */
165
- #define EROFS_INODE_LAYOUT_COMPACT 0
166
- /* 64-byte on-disk inode */
167
- #define EROFS_INODE_LAYOUT_EXTENDED 1
168
-
169
168
/* 64-byte complete form of an ondisk inode */
170
169
struct erofs_inode_extended {
171
170
__le16 i_format ; /* inode format hints */
@@ -175,22 +174,9 @@ struct erofs_inode_extended {
175
174
__le16 i_mode ;
176
175
__le16 i_reserved ;
177
176
__le64 i_size ;
178
- union {
179
- /* total compressed blocks for compressed inodes */
180
- __le32 compressed_blocks ;
181
- /* block address for uncompressed flat inodes */
182
- __le32 raw_blkaddr ;
183
-
184
- /* for device files, used to indicate old/new device # */
185
- __le32 rdev ;
186
-
187
- /* for chunk-based files, it contains the summary info */
188
- struct erofs_inode_chunk_info c ;
189
- } i_u ;
190
-
191
- /* only used for 32-bit stat compatibility */
192
- __le32 i_ino ;
177
+ union erofs_inode_i_u i_u ;
193
178
179
+ __le32 i_ino ; /* only used for 32-bit stat compatibility */
194
180
__le32 i_uid ;
195
181
__le32 i_gid ;
196
182
__le64 i_mtime ;
@@ -199,10 +185,6 @@ struct erofs_inode_extended {
199
185
__u8 i_reserved2 [16 ];
200
186
};
201
187
202
- #define EROFS_MAX_SHARED_XATTRS (128)
203
- /* h_shared_count between 129 ... 255 are special # */
204
- #define EROFS_SHARED_XATTR_EXTENT (255)
205
-
206
188
/*
207
189
* inline xattrs (n == i_xattr_icount):
208
190
* erofs_xattr_ibody_header(1) + (n - 1) * 4 bytes
@@ -268,6 +250,22 @@ struct erofs_inode_chunk_index {
268
250
__le32 blkaddr ; /* start block address of this inode chunk */
269
251
};
270
252
253
+ /* dirent sorts in alphabet order, thus we can do binary search */
254
+ struct erofs_dirent {
255
+ __le64 nid ; /* node number */
256
+ __le16 nameoff ; /* start offset of file name */
257
+ __u8 file_type ; /* file type */
258
+ __u8 reserved ; /* reserved */
259
+ } __packed ;
260
+
261
+ /*
262
+ * EROFS file types should match generic FT_* types and
263
+ * it seems no need to add BUILD_BUG_ONs since potential
264
+ * unmatchness will break other fses as well...
265
+ */
266
+
267
+ #define EROFS_NAME_LEN 255
268
+
271
269
/* maximum supported size of a physical compression cluster */
272
270
#define Z_EROFS_PCLUSTER_MAX_SIZE (1024 * 1024)
273
271
@@ -337,10 +335,8 @@ struct z_erofs_map_header {
337
335
__u8 h_clusterbits ;
338
336
};
339
337
340
- #define Z_EROFS_VLE_LEGACY_HEADER_PADDING 8
341
-
342
338
/*
343
- * Fixed-sized output compression on -disk logical cluster type:
339
+ * On -disk logical cluster type:
344
340
* 0 - literal (uncompressed) lcluster
345
341
* 1,3 - compressed lcluster (for HEAD lclusters)
346
342
* 2 - compressed lcluster (for NONHEAD lclusters)
@@ -364,27 +360,27 @@ struct z_erofs_map_header {
364
360
* di_u.delta[1] = distance to the next HEAD lcluster
365
361
*/
366
362
enum {
367
- Z_EROFS_VLE_CLUSTER_TYPE_PLAIN = 0 ,
368
- Z_EROFS_VLE_CLUSTER_TYPE_HEAD1 = 1 ,
369
- Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD = 2 ,
370
- Z_EROFS_VLE_CLUSTER_TYPE_HEAD2 = 3 ,
371
- Z_EROFS_VLE_CLUSTER_TYPE_MAX
363
+ Z_EROFS_LCLUSTER_TYPE_PLAIN = 0 ,
364
+ Z_EROFS_LCLUSTER_TYPE_HEAD1 = 1 ,
365
+ Z_EROFS_LCLUSTER_TYPE_NONHEAD = 2 ,
366
+ Z_EROFS_LCLUSTER_TYPE_HEAD2 = 3 ,
367
+ Z_EROFS_LCLUSTER_TYPE_MAX
372
368
};
373
369
374
- #define Z_EROFS_VLE_DI_CLUSTER_TYPE_BITS 2
375
- #define Z_EROFS_VLE_DI_CLUSTER_TYPE_BIT 0
370
+ #define Z_EROFS_LI_LCLUSTER_TYPE_BITS 2
371
+ #define Z_EROFS_LI_LCLUSTER_TYPE_BIT 0
376
372
377
373
/* (noncompact only, HEAD) This pcluster refers to partial decompressed data */
378
- #define Z_EROFS_VLE_DI_PARTIAL_REF (1 << 15)
374
+ #define Z_EROFS_LI_PARTIAL_REF (1 << 15)
379
375
380
376
/*
381
377
* D0_CBLKCNT will be marked _only_ at the 1st non-head lcluster to store the
382
378
* compressed block count of a compressed extent (in logical clusters, aka.
383
379
* block count of a pcluster).
384
380
*/
385
- #define Z_EROFS_VLE_DI_D0_CBLKCNT (1 << 11)
381
+ #define Z_EROFS_LI_D0_CBLKCNT (1 << 11)
386
382
387
- struct z_erofs_vle_decompressed_index {
383
+ struct z_erofs_lcluster_index {
388
384
__le16 di_advise ;
389
385
/* where to decompress in the head lcluster */
390
386
__le16 di_clusterofs ;
@@ -401,25 +397,8 @@ struct z_erofs_vle_decompressed_index {
401
397
} di_u ;
402
398
};
403
399
404
- #define Z_EROFS_VLE_LEGACY_INDEX_ALIGN (size ) \
405
- (round_up(size, sizeof(struct z_erofs_vle_decompressed_index)) + \
406
- sizeof(struct z_erofs_map_header) + Z_EROFS_VLE_LEGACY_HEADER_PADDING)
407
-
408
- /* dirent sorts in alphabet order, thus we can do binary search */
409
- struct erofs_dirent {
410
- __le64 nid ; /* node number */
411
- __le16 nameoff ; /* start offset of file name */
412
- __u8 file_type ; /* file type */
413
- __u8 reserved ; /* reserved */
414
- } __packed ;
415
-
416
- /*
417
- * EROFS file types should match generic FT_* types and
418
- * it seems no need to add BUILD_BUG_ONs since potential
419
- * unmatchness will break other fses as well...
420
- */
421
-
422
- #define EROFS_NAME_LEN 255
400
+ #define Z_EROFS_FULL_INDEX_ALIGN (end ) \
401
+ (ALIGN(end, 8) + sizeof(struct z_erofs_map_header) + 8)
423
402
424
403
/* check the EROFS on-disk layout strictly at compile time */
425
404
static inline void erofs_check_ondisk_layout_definitions (void )
@@ -436,15 +415,15 @@ static inline void erofs_check_ondisk_layout_definitions(void)
436
415
BUILD_BUG_ON (sizeof (struct erofs_inode_chunk_info ) != 4 );
437
416
BUILD_BUG_ON (sizeof (struct erofs_inode_chunk_index ) != 8 );
438
417
BUILD_BUG_ON (sizeof (struct z_erofs_map_header ) != 8 );
439
- BUILD_BUG_ON (sizeof (struct z_erofs_vle_decompressed_index ) != 8 );
418
+ BUILD_BUG_ON (sizeof (struct z_erofs_lcluster_index ) != 8 );
440
419
BUILD_BUG_ON (sizeof (struct erofs_dirent ) != 12 );
441
420
/* keep in sync between 2 index structures for better extendibility */
442
421
BUILD_BUG_ON (sizeof (struct erofs_inode_chunk_index ) !=
443
- sizeof (struct z_erofs_vle_decompressed_index ));
422
+ sizeof (struct z_erofs_lcluster_index ));
444
423
BUILD_BUG_ON (sizeof (struct erofs_deviceslot ) != 128 );
445
424
446
- BUILD_BUG_ON (BIT (Z_EROFS_VLE_DI_CLUSTER_TYPE_BITS ) <
447
- Z_EROFS_VLE_CLUSTER_TYPE_MAX - 1 );
425
+ BUILD_BUG_ON (BIT (Z_EROFS_LI_LCLUSTER_TYPE_BITS ) <
426
+ Z_EROFS_LCLUSTER_TYPE_MAX - 1 );
448
427
/* exclude old compiler versions like gcc 7.5.0 */
449
428
BUILD_BUG_ON (__builtin_constant_p (fmh ) ?
450
429
fmh != cpu_to_le64 (1ULL << 63 ) : 0 );
0 commit comments