[PATCH] erofs-utils: clear compacted_2b if compacted_4b_initial > totalidx

Gao Xiang xiang at kernel.org
Tue Dec 14 12:33:22 AEDT 2021


Keep in sync with the latest kernel
commit c40dd3ca2a45 ("erofs: clear compacted_2b if compacted_4b_initial > totalidx")

Signed-off-by: Gao Xiang <xiang at kernel.org>
---
 lib/zmap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/zmap.c b/lib/zmap.c
index 09d5d35e65ee..abc8babd6763 100644
--- a/lib/zmap.c
+++ b/lib/zmap.c
@@ -315,7 +315,8 @@ static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m,
 	if (compacted_4b_initial == 32 / 4)
 		compacted_4b_initial = 0;
 
-	if (vi->z_advise & Z_EROFS_ADVISE_COMPACTED_2B)
+	if ((vi->z_advise & Z_EROFS_ADVISE_COMPACTED_2B) &&
+	    compacted_4b_initial < totalidx)
 		compacted_2b = rounddown(totalidx - compacted_4b_initial, 16);
 	else
 		compacted_2b = 0;
-- 
2.20.1



More information about the Linux-erofs mailing list