Skip to content

Commit 001b8cc

Browse files
committed
erofs: fix compact 4B support for 16k block size
In compact 4B, two adjacent lclusters are packed together as a unit to form on-disk indexes for effective random access, as below: (amortized = 4, vcnt = 2) _____________________________________________ |___@_____ encoded bits __________|_ blkaddr _| 0 . amortized * vcnt = 8 . . . . amortized * vcnt - 4 = 4 . . .____________________________. |_type (2 bits)_|_clusterofs_| Therefore, encoded bits for each pack are 32 bits (4 bytes). IOWs, since each lcluster can get 16 bits for its type and clusterofs, the maximum supported lclustersize for compact 4B format is 16k (14 bits). Fix this to enable compact 4B format for 16k lclusters (blocks), which is tested on an arm64 server with 16k page size. Fixes: 152a333 ("staging: erofs: add compacted compression indexes support") Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> Link: https://lore.kernel.org/r/20230601112341.56960-1-hsiangkao@linux.alibaba.com
1 parent 9c39ec0 commit 001b8cc

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

fs/erofs/zmap.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,
129129
u8 *in, type;
130130
bool big_pcluster;
131131

132-
if (1 << amortizedshift == 4)
132+
if (1 << amortizedshift == 4 && lclusterbits <= 14)
133133
vcnt = 2;
134134
else if (1 << amortizedshift == 2 && lclusterbits == 12)
135135
vcnt = 16;
@@ -231,17 +231,13 @@ static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m,
231231
{
232232
struct inode *const inode = m->inode;
233233
struct erofs_inode *const vi = EROFS_I(inode);
234-
const unsigned int lclusterbits = vi->z_logical_clusterbits;
235234
const erofs_off_t ebase = sizeof(struct z_erofs_map_header) +
236235
ALIGN(erofs_iloc(inode) + vi->inode_isize + vi->xattr_isize, 8);
237236
unsigned int totalidx = erofs_iblks(inode);
238237
unsigned int compacted_4b_initial, compacted_2b;
239238
unsigned int amortizedshift;
240239
erofs_off_t pos;
241240

242-
if (lclusterbits != 12)
243-
return -EOPNOTSUPP;
244-
245241
if (lcn >= totalidx)
246242
return -EINVAL;
247243

0 commit comments

Comments
 (0)