Practical Limit on EROFS lcluster size
Kelvin Zhang
zhangkelvin at google.com
Tue Dec 21 00:45:42 AEDT 2021
Hi Gao,
I was playing with large pcluster sizes recently, I noticed a
quirk about EROFS. In summary, logical cluster size has a practical
limit of 8MB. Here's why:
Looking at https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git/tree/lib/compress.c?h=experimental&id=564adb0a852b38a1790db20516862fc31bca314d#n92
, line 92, we see the following code:
if (d0 == 1 && erofs_sb_has_big_pcluster()) {
type = Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD;
di.di_u.delta[0] = cpu_to_le16(ctx->compressedblks |
Z_EROFS_VLE_DI_D0_CBLKCNT); // This line
di.di_u.delta[1] = cpu_to_le16(d1);
} else if (d0) {
type = Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD;
di.di_u.delta[0] = cpu_to_le16(d0); // and this line
di.di_u.delta[1] = cpu_to_le16(d1);
}
When a compressed index has type NOHEAD, delta[0] stores d0(distance
to head block). But The 11th bit of d0 is also used as a flag bit to
indicate that d0 stores the pcluster size. This means d0 cannot exceed
Z_EROFS_VLE_DI_D0_CBLKCNT(2048), or else the parser will incorrectly
interpret d0 as pcluster size, rather than distance to head block.
Is this an intentional design choice? It's not necessarily bad,
but it's something I think is worth documenting in code.
--
Sincerely,
Kelvin Zhang
More information about the Linux-erofs
mailing list