Skip to contentSkip to conversation

erofs-utils: avoid unnecessary insert behavior when not deduplicating

PATCH In review Yue Hu 2 participants 6 messages Oct 13, 2022 – Oct 14, 2022 Library code

lore
Share & tools
lore

Yue Hu

author
#0 lore raw

PATCH 1/1 erofs-utils: avoid unnecessary insert behavior when not deduplicating

From: Yue Hu <[email protected]>

We should do nothing in dedupe inserting when it's not configured.

---
 lib/dedupe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/dedupe.c +1 -1
index 7962014..9cad905 100644
@@ -99,7 +99,7 @@ int z_erofs_dedupe_insert(struct z_erofs_inmem_extent *e,
 {
 	struct z_erofs_dedupe_item *di;
 
-	if (e->length < window_size)
+	if (!dedupe_subtree || e->length < window_size)
 		return 0;
 
 	di = malloc(sizeof(*di) + e->length - window_size);
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Yue,

Quoted 6 lines · Yue Hu

From: Yue Hu <[email protected]>

We should do nothing in dedupe inserting when it's not configured.

---

Thanks for the patch, do you observe some strange happening?

IMO, If dedupe is not enabled, window_size will be 0 I think. However, I think we might need to disable it explicitly like below.

So,

Thanks,
Gao Xiang

Quoted 18 lines
 lib/dedupe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/dedupe.c +1 -1
index 7962014..9cad905 100644
@@ -99,7 +99,7 @@ int z_erofs_dedupe_insert(struct z_erofs_inmem_extent *e,
 {
 	struct z_erofs_dedupe_item *di;
 
-	if (e->length < window_size)
+	if (!dedupe_subtree || e->length < window_size)
 		return 0;
 
 	di = malloc(sizeof(*di) + e->length - window_size);
Signature · 1 line
2.17.1
author
#2 lore raw
Quoted 11 lines · On Thu, 13 Oct 2022 16:59:26 +0800 Gao Xiang <[email protected]>…

Hi Yue,

Quoted 6 lines · Yue Hu

From: Yue Hu <[email protected]>

We should do nothing in dedupe inserting when it's not configured.

---

Thanks for the patch, do you observe some strange happening?

I can see malloc/memcpy at runtime when dedupe is disabled. So, just skip.

Quoted 29 lines

IMO, If dedupe is not enabled, window_size will be 0 I think. However, I think we might need to disable it explicitly like below.

So,

Thanks,
Gao Xiang

Quoted 18 lines
 lib/dedupe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/dedupe.c +1 -1
index 7962014..9cad905 100644
@@ -99,7 +99,7 @@ int z_erofs_dedupe_insert(struct z_erofs_inmem_extent *e,
 {
 	struct z_erofs_dedupe_item *di;
 
-	if (e->length < window_size)
+	if (!dedupe_subtree || e->length < window_size)
 		return 0;
 
 	di = malloc(sizeof(*di) + e->length - window_size);
Signature · 1 line
2.17.1  
#3 lore raw
Quoted 8 lines · Yue Hu
Quoted 5 lines · On Thu, 13 Oct 2022 16:59:26 +0800 Gao Xiang <[email protected]>…

Hi Yue,

Quoted 2 lines · Yue Hu

From: Yue Hu <[email protected]>

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

We should do nothing in dedupe inserting when it's not configured.

---

Thanks for the patch, do you observe some strange happening?

I can see malloc/memcpy at runtime when dedupe is disabled. So, just skip.

Would you mind confirming the numbers of e->length and window_size at that time?

Thanks,
Gao Xiang

Quoted 10 lines
Quoted 10 lines

IMO, If dedupe is not enabled, window_size will be 0 I think. However, I think we might need to disable it explicitly like below.

So,

Thanks,
Gao Xiang

author
#4 lore raw

Hi Xiang,

Quoted 14 lines · On Fri, 14 Oct 2022 10:15:27 +0800 Gao Xiang <[email protected]>…
Quoted 13 lines · Yue Hu
Quoted 10 lines · On Thu, 13 Oct 2022 16:59:26 +0800 Gao Xiang <[email protected]>…

Hi Yue,

Quoted 6 lines · Yue Hu

From: Yue Hu <[email protected]>

We should do nothing in dedupe inserting when it's not configured.

---

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Thanks for the patch, do you observe some strange happening?

I can see malloc/memcpy at runtime when dedupe is disabled. So, just skip.

Would you mind confirming the numbers of e->length and window_size at that time?

The caller to insert function is just checking "!may_inline && !may_packing".

Check below (-zlz4hc foo.img foo/):

Processing .gitignore ...
<E> erofs: z_erofs_dedupe_insert() Line[105] e->length 84, window_size 0 Processing Kconfig.freezer ...
<E> erofs: z_erofs_dedupe_insert() Line[105] e->length 92, window_size 0 Processing Kconfig.hz ...
<E> erofs: z_erofs_dedupe_insert() Line[105] e->length 1709, window_size 0

lib/dedupe.c +2 -0
@@ -102,6 +102,8 @@ int z_erofs_dedupe_insert(struct z_erofs_inmem_extent *e,
        if (e->length < window_size)
                return 0;
 
+       erofs_err("e->length %u, window_size %u", e->length, window_size);
+
        di = malloc(sizeof(*di) + e->length - window_size);
 

Thanks.

Quoted 14 lines

Thanks,
Gao Xiang

Quoted 10 lines
Quoted 10 lines

IMO, If dedupe is not enabled, window_size will be 0 I think. However, I think we might need to disable it explicitly like below.

So,

Thanks,
Gao Xiang

#5 lore raw
Quoted 28 lines · Yue Hu

Hi Xiang,

Quoted 14 lines · On Fri, 14 Oct 2022 10:15:27 +0800 Gao Xiang <[email protected]>…
Quoted 13 lines · Yue Hu
Quoted 10 lines · On Thu, 13 Oct 2022 16:59:26 +0800 Gao Xiang <[email protected]>…

Hi Yue,

Quoted 6 lines · Yue Hu

From: Yue Hu <[email protected]>

We should do nothing in dedupe inserting when it's not configured.

---

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Thanks for the patch, do you observe some strange happening?

I can see malloc/memcpy at runtime when dedupe is disabled. So, just skip.

Would you mind confirming the numbers of e->length and window_size at that time?

The caller to insert function is just checking "!may_inline && !may_packing".

Quoted 9 lines

Check below (-zlz4hc foo.img foo/):

Processing .gitignore ...
<E> erofs: z_erofs_dedupe_insert() Line[105] e->length 84, window_size 0 Processing Kconfig.freezer ...
<E> erofs: z_erofs_dedupe_insert() Line[105] e->length 92, window_size 0 Processing Kconfig.hz ...
<E> erofs: z_erofs_dedupe_insert() Line[105] e->length 1709, window_size 0

Thanks for confirming!

Thanks,
Gao Xiang