Skip to contentSkip to conversation

erofs-utils: don't hard code constants

PATCH Applied Kelvin Zhang via Linux-erofs 2 participants 4 messages Jan 31, 2022 – Feb 2, 2022 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 erofs-utils: don't hard code constants

Use sizeof(z_erofs_vle_decompressed_index) to compute legacy index count

Test: th

---
 lib/compress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/compress.c +1 -1
index 98be7a2..c520a1e 100644
@@ -359,7 +359,7 @@ int z_erofs_convert_to_compacted_format(struct erofs_inode *inode,
 							   inode->xattr_isize) +
 				  sizeof(struct z_erofs_map_header);
 	const unsigned int totalidx = (legacymetasize -
-				       Z_EROFS_LEGACY_MAP_HEADER_SIZE) / 8;
+				       Z_EROFS_LEGACY_MAP_HEADER_SIZE) / sizeof(struct z_erofs_vle_decompressed_index);
 	const unsigned int logical_clusterbits = inode->z_logical_clusterbits;
 	u8 *out, *in;
 	struct z_erofs_compressindex_vec cv[16];
Signature · 1 line
2.35.0.rc2.247.g8bbb082509-goog
Applied
#1 lore raw
Quoted 13 lines · Kelvin Zhang

Use sizeof(z_erofs_vle_decompressed_index) to compute legacy index count

Test: th

---
 lib/compress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/compress.c +0 -0
index 98be7a2..c520a1e 100644

lib/compress.c int z_erofs_convert_to_compacted_format(struct erofs_inode *inode, · line 362

Quoted 5 lines
lib/compress.c +1 -1
@@ -359,7 +359,7 @@ int z_erofs_convert_to_compacted_format(struct erofs_inode *inode,
 							   inode->xattr_isize) +
 				  sizeof(struct z_erofs_map_header);
 	const unsigned int totalidx = (legacymetasize -
-				       Z_EROFS_LEGACY_MAP_HEADER_SIZE) / 8;
+				       Z_EROFS_LEGACY_MAP_HEADER_SIZE) / sizeof(struct z_erofs_vle_decompressed_index);

It would be better to keep 80-char limit rule.

Thanks, applied.

Happy chinese new year!
Gao Xiang

Quoted 5 lines
lib/compress.c +0 -0
 	const unsigned int logical_clusterbits = inode->z_logical_clusterbits;
 	u8 *out, *in;
 	struct z_erofs_compressindex_vec cv[16];
Signature · 1 line
2.35.0.rc2.247.g8bbb082509-goog
#2 lore raw

Thanks Gao! I'm reading compressed indices code recently. Is there any notes/sketches/design docs you can share with me regarding that?

Happy Chinese New Year!

Quoted 33 lines · Gao Xiang
Quoted 13 lines · Kelvin Zhang

Use sizeof(z_erofs_vle_decompressed_index) to compute legacy index count

Test: th

---
 lib/compress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/compress.c +0 -0
index 98be7a2..c520a1e 100644

lib/compress.c int z_erofs_convert_to_compacted_format(struct erofs_inode *inode, · line 362

Quoted 5 lines
lib/compress.c +1 -1
@@ -359,7 +359,7 @@ int z_erofs_convert_to_compacted_format(struct erofs_inode *inode,
                                                         inode->xattr_isize) +
                                sizeof(struct z_erofs_map_header);
      const unsigned int totalidx = (legacymetasize -
-                                    Z_EROFS_LEGACY_MAP_HEADER_SIZE) / 8;
+                                    Z_EROFS_LEGACY_MAP_HEADER_SIZE) / sizeof(struct z_erofs_vle_decompressed_index);

It would be better to keep 80-char limit rule.

Thanks, applied.

Happy chinese new year!
Gao Xiang

Quoted 5 lines
lib/compress.c +0 -1
      const unsigned int logical_clusterbits = inode->z_logical_clusterbits;
      u8 *out, *in;
      struct z_erofs_compressindex_vec cv[16];
--

2.35.0.rc2.247.g8bbb082509-goog

Signature · 3 lines
Sincerely,

Kelvin Zhang
#3 lore raw
Quoted 3 lines · Kelvin Zhang

Thanks Gao! I'm reading compressed indices code recently. Is there any notes/sketches/design docs you can share with me regarding that?

There are some kernel commit messages to describe the on-disk format:
ec8c24420501d4cf3ed495c4d026984194897276 b86269f43892316ef5a177d7180d09d101a46f22

And Yue Hu wrote his own notes about compacted indexes (in Chinese):
http://tjtech.me/erofs-compacted-index-generation.html

Hope they are useful! I know that may not enough, I will try to write more this year.

Thanks,
Gao Xiang

Quoted 43 lines

Happy Chinese New Year!

Quoted 33 lines · Gao Xiang
Quoted 13 lines · Kelvin Zhang

Use sizeof(z_erofs_vle_decompressed_index) to compute legacy index count

Test: th

---
 lib/compress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/compress.c +0 -0
index 98be7a2..c520a1e 100644

lib/compress.c int z_erofs_convert_to_compacted_format(struct erofs_inode *inode, · line 362

Quoted 5 lines
lib/compress.c +1 -1
@@ -359,7 +359,7 @@ int z_erofs_convert_to_compacted_format(struct erofs_inode *inode,
                                                         inode->xattr_isize) +
                                sizeof(struct z_erofs_map_header);
      const unsigned int totalidx = (legacymetasize -
-                                    Z_EROFS_LEGACY_MAP_HEADER_SIZE) / 8;
+                                    Z_EROFS_LEGACY_MAP_HEADER_SIZE) / sizeof(struct z_erofs_vle_decompressed_index);

It would be better to keep 80-char limit rule.

Thanks, applied.

Happy chinese new year!
Gao Xiang

Quoted 5 lines
lib/compress.c +0 -1
      const unsigned int logical_clusterbits = inode->z_logical_clusterbits;
      u8 *out, *in;
      struct z_erofs_compressindex_vec cv[16];
--

2.35.0.rc2.247.g8bbb082509-goog

Signature · 3 lines
Sincerely,

Kelvin Zhang