Skip to contentSkip to conversation

erofs: fix compacted_2b if compacted_4b_initial > totalidx

PATCH In review Yue Hu 4 participants 7 messages Sep 14, 2021 – Sep 23, 2021 EROFS file system

lore
Share & tools
lore

Yue Hu

author reviewer
#0 lore raw

PATCH 1/1 erofs: fix compacted_2b if compacted_4b_initial > totalidx

From: Yue Hu <[email protected]>

Currently, the whole indexes will only be compacted 4B if compacted_4b_initial > totalidx. So, the calculated compacted_2b is worthless for that case. It may waste CPU resources.

No need to update compacted_4b_initial as mkfs since it's used to fulfill the alignment of the 1st compacted_2b pack and would handle the case above.

We also need to clarify compacted_4b_end here. It's used for the last lclusters which aren't fitted in the previous compacted_2b packs.

Some messages are from Xiang.

---
 fs/erofs/zmap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/erofs/zmap.c +2 -1
index 9fb98d8..aeed404 100644
@@ -369,7 +369,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;
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Yue Hu

From: Yue Hu <[email protected]>

Currently, the whole indexes will only be compacted 4B if compacted_4b_initial > totalidx. So, the calculated compacted_2b is worthless for that case. It may waste CPU resources.

No need to update compacted_4b_initial as mkfs since it's used to fulfill the alignment of the 1st compacted_2b pack and would handle the case above.

Quoted 7 lines

We also need to clarify compacted_4b_end here. It's used for the last lclusters which aren't fitted in the previous compacted_2b packs.

Some messages are from Xiang.

Looks good to me,

(although I think the subject title would be better changed into
"clear compacted_2b if compacted_4b_initial > totalidx" since 'fix'-likewise words could trigger some AI bot for stable kernel backporting..)

Thanks,
Gao Xiang

Quoted 20 lines
---
 fs/erofs/zmap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/erofs/zmap.c +2 -1
index 9fb98d8..aeed404 100644
@@ -369,7 +369,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;
Signature · 1 line
1.9.1
author reviewer
#2 lore raw
Quoted 17 lines · On Tue, 14 Sep 2021 12:37:14 +0800 Gao Xiang <[email protected]>…
Quoted 16 lines · Yue Hu

From: Yue Hu <[email protected]>

Currently, the whole indexes will only be compacted 4B if compacted_4b_initial > totalidx. So, the calculated compacted_2b is worthless for that case. It may waste CPU resources.

No need to update compacted_4b_initial as mkfs since it's used to fulfill the alignment of the 1st compacted_2b pack and would handle the case above.

We also need to clarify compacted_4b_end here. It's used for the last lclusters which aren't fitted in the previous compacted_2b packs.

Some messages are from Xiang.

Quoted 7 lines
Quoted 1 line

Looks good to me,

(although I think the subject title would be better changed into
"clear compacted_2b if compacted_4b_initial > totalidx"

Yeah, 'clear' is much better for this change.

Thanks.

Quoted 26 lines

since 'fix'-likewise words could trigger some AI bot for stable kernel backporting..)

Thanks,
Gao Xiang

Quoted 20 lines
---
 fs/erofs/zmap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/erofs/zmap.c +2 -1
index 9fb98d8..aeed404 100644
@@ -369,7 +369,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;
Signature · 1 line
1.9.1  
#3 lore raw
Quoted 22 lines · Yue Hu
Quoted 19 lines · On Tue, 14 Sep 2021 12:37:14 +0800 Gao Xiang <[email protected]>…
Quoted 17 lines · Yue Hu

From: Yue Hu <[email protected]>

Currently, the whole indexes will only be compacted 4B if compacted_4b_initial > totalidx. So, the calculated compacted_2b is worthless for that case. It may waste CPU resources.

No need to update compacted_4b_initial as mkfs since it's used to fulfill the alignment of the 1st compacted_2b pack and would handle the case above.

We also need to clarify compacted_4b_end here. It's used for the last lclusters which aren't fitted in the previous compacted_2b packs.

Some messages are from Xiang.

Quoted 7 lines
Quoted 5 lines

Looks good to me,

(although I think the subject title would be better changed into
"clear compacted_2b if compacted_4b_initial > totalidx"

Yeah, 'clear' is much better for this change.

Ok, I will update this when later applying.

Thanks,
Gao Xiang

Quoted 29 lines

Thanks.

Quoted 26 lines

since 'fix'-likewise words could trigger some AI bot for stable kernel backporting..)

Thanks,
Gao Xiang

Quoted 20 lines
---
 fs/erofs/zmap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/erofs/zmap.c +2 -1
index 9fb98d8..aeed404 100644
@@ -369,7 +369,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;
Signature · 1 line
1.9.1  
#4 lore raw
In reply to Yue Hu
Quoted 50 lines · Yue Hu
Quoted 17 lines · On Tue, 14 Sep 2021 12:37:14 +0800 Gao Xiang <[email protected]>…
Quoted 16 lines · Yue Hu

From: Yue Hu <[email protected]>

Currently, the whole indexes will only be compacted 4B if compacted_4b_initial > totalidx. So, the calculated compacted_2b is worthless for that case. It may waste CPU resources.

No need to update compacted_4b_initial as mkfs since it's used to fulfill the alignment of the 1st compacted_2b pack and would handle the case above.

We also need to clarify compacted_4b_end here. It's used for the last lclusters which aren't fitted in the previous compacted_2b packs.

Some messages are from Xiang.

Quoted 7 lines
Quoted 1 line

Looks good to me,

(although I think the subject title would be better changed into
"clear compacted_2b if compacted_4b_initial > totalidx"

Yeah, 'clear' is much better for this change.

Thanks.

Quoted 18 lines

since 'fix'-likewise words could trigger some AI bot for stable kernel backporting..)

Thanks,
Gao Xiang

Quoted 12 lines
---
 fs/erofs/zmap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/erofs/zmap.c +0 -0
index 9fb98d8..aeed404 100644
@@ -369,7 +369,8 @@ static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m,
 	if (compacted_4b_initial == 32 / 4)
 		compacted_4b_initial = 0;
 
Quoted 3 lines
Quoted 3 lines

fs/erofs/zmap.c static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m, · line 373

Quoted 3 lines
fs/erofs/zmap.c +2 -1
-	if (vi->z_advise & Z_EROFS_ADVISE_COMPACTED_2B)
+	if ((vi->z_advise & Z_EROFS_ADVISE_COMPACTED_2B) &&
+	    compacted_4b_initial <= totalidx) {

btw, I've fixed up the build error due to redundant brace '{' when applying...

Thanks,
Gao Xiang

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
fs/erofs/zmap.c +0 -0
 		compacted_2b = rounddown(totalidx - compacted_4b_initial, 16);
 	else
 		compacted_2b = 0;
Signature · 1 line
1.9.1  
#5 lore raw
Quoted 51 lines · On Thu, 23 Sep 2021 19:49:42 +0800 Gao Xiang <[email protected]>…
Quoted 50 lines · Yue Hu
Quoted 17 lines · On Tue, 14 Sep 2021 12:37:14 +0800 Gao Xiang <[email protected]>…
Quoted 16 lines · Yue Hu

From: Yue Hu <[email protected]>

Currently, the whole indexes will only be compacted 4B if compacted_4b_initial > totalidx. So, the calculated compacted_2b is worthless for that case. It may waste CPU resources.

No need to update compacted_4b_initial as mkfs since it's used to fulfill the alignment of the 1st compacted_2b pack and would handle the case above.

We also need to clarify compacted_4b_end here. It's used for the last lclusters which aren't fitted in the previous compacted_2b packs.

Some messages are from Xiang.

Quoted 7 lines
Quoted 1 line

Looks good to me,

(although I think the subject title would be better changed into
"clear compacted_2b if compacted_4b_initial > totalidx"

Yeah, 'clear' is much better for this change.

Thanks.

Quoted 18 lines

since 'fix'-likewise words could trigger some AI bot for stable kernel backporting..)

Thanks,
Gao Xiang

Quoted 12 lines
---
 fs/erofs/zmap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/erofs/zmap.c +0 -0
index 9fb98d8..aeed404 100644
@@ -369,7 +369,8 @@ static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m,
 	if (compacted_4b_initial == 32 / 4)
 		compacted_4b_initial = 0;
 
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

fs/erofs/zmap.c static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m, · line 373

Quoted 3 lines
fs/erofs/zmap.c +2 -1
-	if (vi->z_advise & Z_EROFS_ADVISE_COMPACTED_2B)
+	if ((vi->z_advise & Z_EROFS_ADVISE_COMPACTED_2B) &&
+	    compacted_4b_initial <= totalidx) {  

btw, I've fixed up the build error due to redundant brace '{' when

Thanks.

Quoted 10 lines

applying...

Thanks,
Gao Xiang

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
fs/erofs/zmap.c +0 -0
 		compacted_2b = rounddown(totalidx - compacted_4b_initial, 16);
 	else
 		compacted_2b = 0;
Signature · 1 line
1.9.1    
maintainer Reviewed-by
#6 lore raw
In reply to Gao Xiang
Quoted 51 lines · Gao Xiang
Quoted 50 lines · Yue Hu
Quoted 17 lines · On Tue, 14 Sep 2021 12:37:14 +0800 Gao Xiang <[email protected]>…
Quoted 16 lines · Yue Hu

From: Yue Hu <[email protected]>

Currently, the whole indexes will only be compacted 4B if compacted_4b_initial > totalidx. So, the calculated compacted_2b is worthless for that case. It may waste CPU resources.

No need to update compacted_4b_initial as mkfs since it's used to fulfill the alignment of the 1st compacted_2b pack and would handle the case above.

We also need to clarify compacted_4b_end here. It's used for the last lclusters which aren't fitted in the previous compacted_2b packs.

Some messages are from Xiang.

Quoted 7 lines
Quoted 1 line

Looks good to me,

(although I think the subject title would be better changed into
"clear compacted_2b if compacted_4b_initial > totalidx"

Yeah, 'clear' is much better for this change.

Thanks.

Quoted 18 lines

since 'fix'-likewise words could trigger some AI bot for stable kernel backporting..)

Thanks,
Gao Xiang

Quoted 12 lines
---
  fs/erofs/zmap.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
fs/erofs/zmap.c +0 -0
index 9fb98d8..aeed404 100644
@@ -369,7 +369,8 @@ static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m,
  	if (compacted_4b_initial == 32 / 4)
  		compacted_4b_initial = 0;
 
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

fs/erofs/zmap.c static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m, · line 373

Quoted 3 lines
fs/erofs/zmap.c +2 -1
-	if (vi->z_advise & Z_EROFS_ADVISE_COMPACTED_2B)
+	if ((vi->z_advise & Z_EROFS_ADVISE_COMPACTED_2B) &&
+	    compacted_4b_initial <= totalidx) {

btw, I've fixed up the build error due to redundant brace '{' when applying...

It looks good to me after above fix.

Thanks,