erofs: fix up compacted indexes for block size < 4096
authorGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 6 Dec 2023 09:10:55 +0000 (17:10 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Feb 2024 20:14:16 +0000 (20:14 +0000)
commit3f691aa676f29586e83e6c032713554a290418c3
treeb2cb219c3d0eb502a1310ad03c313ea7d9ad0117
parent0593cfd321df9001142a9d2c58d4144917dff7ee
erofs: fix up compacted indexes for block size < 4096

[ Upstream commit 8d2517aaeea3ab8651bb517bca8f3c8664d318ea ]

Previously, the block size always equaled to PAGE_SIZE, therefore
`lclusterbits` couldn't be less than 12.

Since sub-page compressed blocks are now considered, `lobits` for
a lcluster in each pack cannot always be `lclusterbits` as before.
Otherwise, there is no enough room for the special value
`Z_EROFS_LI_D0_CBLKCNT`.

To support smaller block sizes, `lobits` for each compacted lcluster is
now calculated as:
   lobits = max(lclusterbits, ilog2(Z_EROFS_LI_D0_CBLKCNT) + 1)

Reviewed-by: Yue Hu <huyue2@coolpad.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20231206091057.87027-4-hsiangkao@linux.alibaba.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/erofs/zmap.c