linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] erofs: fix compacted_{4b_initial, 2b} when compacted_4b_initial > totalidx
@ 2021-09-13  7:24 Yue Hu
  2021-09-13  8:48 ` Gao Xiang
  0 siblings, 1 reply; 7+ messages in thread
From: Yue Hu @ 2021-09-13  7:24 UTC (permalink / raw)
  To: xiang, chao; +Cc: huyue2, linux-erofs, linux-kernel, zhangwen, zbestahu

From: Yue Hu <huyue2@yulong.com>

mkfs.erofs will treat compacted_4b_initial & compacted_2b as 0 if
compacted_4b_initial > totalidx, kernel should be aligned with it
accordingly.

Signed-off-by: Yue Hu <huyue2@yulong.com>
---
 fs/erofs/zmap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
index 9fb98d8..4f941b6 100644
--- a/fs/erofs/zmap.c
+++ b/fs/erofs/zmap.c
@@ -369,7 +369,10 @@ 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 (compacted_4b_initial > totalidx) {
+		compacted_4b_initial = 0;
+		compacted_2b = 0;
+	} else if (vi->z_advise & Z_EROFS_ADVISE_COMPACTED_2B)
 		compacted_2b = rounddown(totalidx - compacted_4b_initial, 16);
 	else
 		compacted_2b = 0;
-- 
1.9.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-09-13 12:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13  7:24 [PATCH] erofs: fix compacted_{4b_initial, 2b} when compacted_4b_initial > totalidx Yue Hu
2021-09-13  8:48 ` Gao Xiang
2021-09-13  9:00   ` Yue Hu
2021-09-13  9:11     ` Gao Xiang
2021-09-13 10:58       ` Yue Hu
2021-09-13 11:19         ` Gao Xiang
2021-09-13 12:22           ` Yue Hu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).