Skip to contentSkip to conversation

erofs-utils: no compression case for tail-end block in vle_write_indexes()

PATCH Superseded Yue Hu 2 participants 3 messages Jul 23, 2021 Library code

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yue Hu

author
#0 lore raw

PATCH 1/1 erofs-utils: no compression case for tail-end block in vle_write_indexes()

From: Yue Hu <[email protected]>

Note that count value will be always greater than EROFS_BLKSIZ when calling erofs_compress_destsize() in vle_compress_one(). So, the d1 always >= 1 for compressed block in vle_write_indexes(). That is to say tail-end block can't be compressed.

---
 lib/compress.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
lib/compress.c +2 -3
index af0c720..93fc543 100644
@@ -73,10 +73,9 @@ static void vle_write_indexes(struct z_erofs_vle_compress_ctx *ctx,
 
 	di.di_clusterofs = cpu_to_le16(ctx->clusterofs);
 
-	/* whether the tail-end (un)compressed block or not */
+	/* whether the tail-end uncompressed block or not */
 	if (!d1) {
-		type = raw ? Z_EROFS_VLE_CLUSTER_TYPE_PLAIN :
-			Z_EROFS_VLE_CLUSTER_TYPE_HEAD;
+		type = Z_EROFS_VLE_CLUSTER_TYPE_PLAIN;
 		advise = cpu_to_le16(type << Z_EROFS_VLE_DI_CLUSTER_TYPE_BIT);
 
 		di.di_advise = advise;
Signature · 1 line
1.9.1
#1 lore raw

Hi Yue,

Quoted 8 lines · Yue Hu

From: Yue Hu <[email protected]>

Note that count value will be always greater than EROFS_BLKSIZ when calling erofs_compress_destsize() in vle_compress_one(). So, the d1 always >= 1 for compressed block in vle_write_indexes(). That is to say tail-end block can't be compressed.

I once thought tail end block can be compressed with < EROFS_BLKSIZ as well (as long as it has some benefit) and also tail-packing inline like uncompressed cases together after compress extents, so that when we reading the last compress extent meta block, the tail-packing compressed data can be loaded together.

Currently, I think we could do that, but could you add some DBG_BUGON like DBG_BUGON(!raw) right above
"type = Z_EROFS_VLE_CLUSTER_TYPE_PLAIN;" and a TODO comment to mention tail-packing inline compressed cases is under TODO list? That would be much better.

Thanks,
Gao Xiang

Quoted 23 lines
---
 lib/compress.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
lib/compress.c +2 -3
index af0c720..93fc543 100644
@@ -73,10 +73,9 @@ static void vle_write_indexes(struct z_erofs_vle_compress_ctx *ctx,
 
 	di.di_clusterofs = cpu_to_le16(ctx->clusterofs);
 
-	/* whether the tail-end (un)compressed block or not */
+	/* whether the tail-end uncompressed block or not */
 	if (!d1) {
-		type = raw ? Z_EROFS_VLE_CLUSTER_TYPE_PLAIN :
-			Z_EROFS_VLE_CLUSTER_TYPE_HEAD;
+		type = Z_EROFS_VLE_CLUSTER_TYPE_PLAIN;
 		advise = cpu_to_le16(type << Z_EROFS_VLE_DI_CLUSTER_TYPE_BIT);
 
 		di.di_advise = advise;
Signature · 1 line
1.9.1
author
#2 lore raw
Quoted 10 lines · On Fri, 23 Jul 2021 13:02:14 +0800 Gao Xiang <[email protected]>…

Hi Yue,

Quoted 7 lines · Yue Hu

From: Yue Hu <[email protected]>

Note that count value will be always greater than EROFS_BLKSIZ when calling erofs_compress_destsize() in vle_compress_one(). So, the d1 always >= 1 for compressed block in vle_write_indexes(). That is to say tail-end block can't be compressed.

Quoted 7 lines
Quoted 1 line

I once thought tail end block can be compressed with < EROFS_BLKSIZ as well (as long as it has some benefit) and also tail-packing inline like uncompressed cases together after compress extents, so that when we reading the last compress extent meta block, the tail-packing compressed data can be loaded together.

Understood.

Quoted 5 lines

Currently, I think we could do that, but could you add some DBG_BUGON like DBG_BUGON(!raw) right above
"type = Z_EROFS_VLE_CLUSTER_TYPE_PLAIN;" and a TODO comment to mention tail-packing inline compressed cases is under TODO list? That would be

Will do it in v2.

Thanks.

Quoted 28 lines

much better.

Thanks,
Gao Xiang

Quoted 23 lines
---
 lib/compress.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
lib/compress.c +2 -3
index af0c720..93fc543 100644
@@ -73,10 +73,9 @@ static void vle_write_indexes(struct z_erofs_vle_compress_ctx *ctx,
 
 	di.di_clusterofs = cpu_to_le16(ctx->clusterofs);
 
-	/* whether the tail-end (un)compressed block or not */
+	/* whether the tail-end uncompressed block or not */
 	if (!d1) {
-		type = raw ? Z_EROFS_VLE_CLUSTER_TYPE_PLAIN :
-			Z_EROFS_VLE_CLUSTER_TYPE_HEAD;
+		type = Z_EROFS_VLE_CLUSTER_TYPE_PLAIN;
 		advise = cpu_to_le16(type << Z_EROFS_VLE_DI_CLUSTER_TYPE_BIT);
 
 		di.di_advise = advise;
Signature · 1 line
1.9.1