* [PATCH v3 1/4] erofs-utils: record algorithm id in in-memory compression extents
@ 2026-09-16 7:11 Gao Xiang
0 siblings, 0 replies; 2+ messages in thread
From: Gao Xiang @ 2026-09-16 7:11 UTC (permalink / raw)
To: linux-erofs; +Cc: Gao Xiang
In order to enable the rebuild mode for compressed inodes.
Signed-off-by: Gao Xiang <xiang@kernel.org>
---
include/erofs/dedupe.h | 1 +
lib/compress.c | 13 ++++++++++---
lib/dedupe.c | 3 +++
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/include/erofs/dedupe.h b/include/erofs/dedupe.h
index 14dd7dc..dbcb37c 100644
--- a/include/erofs/dedupe.h
+++ b/include/erofs/dedupe.h
@@ -18,6 +18,7 @@ struct z_erofs_inmem_extent {
unsigned int length;
unsigned short device_id;
bool raw, partial, inlined;
+ char algofmt;
};
struct z_erofs_dedupe_ctx {
diff --git a/lib/compress.c b/lib/compress.c
index ae09e86..3e8f9b6 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -189,7 +189,9 @@ static void z_erofs_write_full_indexes(struct z_erofs_index_writer *ctx,
DBG_BUGON(!e->raw && !inode->idata_size && !inode->fragment_size);
DBG_BUGON(e->partial);
type = e->raw ? Z_EROFS_LCLUSTER_TYPE_PLAIN :
- Z_EROFS_LCLUSTER_TYPE_HEAD1;
+ (e->algofmt == inode->z_algorithmtype[0] ?
+ Z_EROFS_LCLUSTER_TYPE_HEAD1 :
+ Z_EROFS_LCLUSTER_TYPE_HEAD2);
di.di_advise = cpu_to_le16(type);
if (inode->datalayout == EROFS_INODE_COMPRESSED_FULL && !e->plen) {
@@ -238,7 +240,9 @@ static void z_erofs_write_full_indexes(struct z_erofs_index_writer *ctx,
di.di_u.delta[1] = cpu_to_le16(d1);
} else {
type = e->raw ? Z_EROFS_LCLUSTER_TYPE_PLAIN :
- Z_EROFS_LCLUSTER_TYPE_HEAD1;
+ (e->algofmt == inode->z_algorithmtype[0] ?
+ Z_EROFS_LCLUSTER_TYPE_HEAD1 :
+ Z_EROFS_LCLUSTER_TYPE_HEAD2);
if (inode->datalayout == EROFS_INODE_COMPRESSED_FULL &&
!e->plen) {
@@ -700,6 +704,7 @@ frag_packing:
e->inlined = true;
e->plen = blksz;
e->raw = false;
+ e->algofmt = inode->z_algorithmtype[0];
} else {
unsigned int padding;
@@ -755,6 +760,7 @@ frag_packing:
}
ctx->poff += e->plen;
e->raw = false;
+ e->algofmt = inode->z_algorithmtype[0];
may_inline = false;
may_packing = false;
}
@@ -1233,7 +1239,7 @@ static void z_erofs_write_extents(struct erofs_inode *inode,
plen = inode->fragmentoff;
pstart = inode->fragmentoff >> 32;
} else {
- fmt = ei->e.raw ? 0 : inode->z_algorithmtype[0] + 1;
+ fmt = ei->e.raw ? 0 : ei->e.algofmt + 1;
plen |= fmt << Z_EROFS_EXTENT_PLEN_FMT_BIT;
if (ei->e.partial)
plen |= Z_EROFS_EXTENT_PLEN_PARTIAL;
@@ -1350,6 +1356,7 @@ int z_erofs_compress_segment(struct z_erofs_compress_sctx *ctx,
.raw = false,
.partial = false,
.pstart = ctx->pstart,
+ .algofmt = inode->z_algorithmtype[0],
};
init_list_head(&ei->list);
z_erofs_commit_extent(ctx, ei);
diff --git a/lib/dedupe.c b/lib/dedupe.c
index 5166f26..ec9e2bb 100644
--- a/lib/dedupe.c
+++ b/lib/dedupe.c
@@ -77,6 +77,7 @@ struct z_erofs_dedupe_item {
int original_length;
bool partial, raw;
+ char algofmt;
u8 extra_data[];
};
@@ -144,6 +145,7 @@ int z_erofs_dedupe_match(struct z_erofs_dedupe_ctx *ctx)
ctx->e.inlined = false;
ctx->e.pstart = e->pstart;
ctx->e.plen = e->plen;
+ ctx->e.algofmt = e->algofmt;
return 0;
}
return -ENOENT;
@@ -183,6 +185,7 @@ int z_erofs_dedupe_insert(struct z_erofs_inmem_extent *e,
di->plen = e->plen;
di->partial = e->partial;
di->raw = e->raw;
+ di->algofmt = e->algofmt;
di->chain = dedupe_subtree;
dedupe_subtree = di;
list_add_tail(&di->list, p);
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH v3 1/4] erofs-utils: record algorithm id in in-memory compression extents
@ 2026-09-16 7:40 Gao Xiang
0 siblings, 0 replies; 2+ messages in thread
From: Gao Xiang @ 2026-09-16 7:40 UTC (permalink / raw)
To: linux-erofs; +Cc: Gao Xiang
In order to enable the rebuild mode for compressed inodes.
Signed-off-by: Gao Xiang <xiang@kernel.org>
---
include/erofs/dedupe.h | 1 +
lib/compress.c | 13 ++++++++++---
lib/dedupe.c | 3 +++
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/include/erofs/dedupe.h b/include/erofs/dedupe.h
index 14dd7dc..dbcb37c 100644
--- a/include/erofs/dedupe.h
+++ b/include/erofs/dedupe.h
@@ -18,6 +18,7 @@ struct z_erofs_inmem_extent {
unsigned int length;
unsigned short device_id;
bool raw, partial, inlined;
+ char algofmt;
};
struct z_erofs_dedupe_ctx {
diff --git a/lib/compress.c b/lib/compress.c
index ae09e86..3e8f9b6 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -189,7 +189,9 @@ static void z_erofs_write_full_indexes(struct z_erofs_index_writer *ctx,
DBG_BUGON(!e->raw && !inode->idata_size && !inode->fragment_size);
DBG_BUGON(e->partial);
type = e->raw ? Z_EROFS_LCLUSTER_TYPE_PLAIN :
- Z_EROFS_LCLUSTER_TYPE_HEAD1;
+ (e->algofmt == inode->z_algorithmtype[0] ?
+ Z_EROFS_LCLUSTER_TYPE_HEAD1 :
+ Z_EROFS_LCLUSTER_TYPE_HEAD2);
di.di_advise = cpu_to_le16(type);
if (inode->datalayout == EROFS_INODE_COMPRESSED_FULL && !e->plen) {
@@ -238,7 +240,9 @@ static void z_erofs_write_full_indexes(struct z_erofs_index_writer *ctx,
di.di_u.delta[1] = cpu_to_le16(d1);
} else {
type = e->raw ? Z_EROFS_LCLUSTER_TYPE_PLAIN :
- Z_EROFS_LCLUSTER_TYPE_HEAD1;
+ (e->algofmt == inode->z_algorithmtype[0] ?
+ Z_EROFS_LCLUSTER_TYPE_HEAD1 :
+ Z_EROFS_LCLUSTER_TYPE_HEAD2);
if (inode->datalayout == EROFS_INODE_COMPRESSED_FULL &&
!e->plen) {
@@ -700,6 +704,7 @@ frag_packing:
e->inlined = true;
e->plen = blksz;
e->raw = false;
+ e->algofmt = inode->z_algorithmtype[0];
} else {
unsigned int padding;
@@ -755,6 +760,7 @@ frag_packing:
}
ctx->poff += e->plen;
e->raw = false;
+ e->algofmt = inode->z_algorithmtype[0];
may_inline = false;
may_packing = false;
}
@@ -1233,7 +1239,7 @@ static void z_erofs_write_extents(struct erofs_inode *inode,
plen = inode->fragmentoff;
pstart = inode->fragmentoff >> 32;
} else {
- fmt = ei->e.raw ? 0 : inode->z_algorithmtype[0] + 1;
+ fmt = ei->e.raw ? 0 : ei->e.algofmt + 1;
plen |= fmt << Z_EROFS_EXTENT_PLEN_FMT_BIT;
if (ei->e.partial)
plen |= Z_EROFS_EXTENT_PLEN_PARTIAL;
@@ -1350,6 +1356,7 @@ int z_erofs_compress_segment(struct z_erofs_compress_sctx *ctx,
.raw = false,
.partial = false,
.pstart = ctx->pstart,
+ .algofmt = inode->z_algorithmtype[0],
};
init_list_head(&ei->list);
z_erofs_commit_extent(ctx, ei);
diff --git a/lib/dedupe.c b/lib/dedupe.c
index 5166f26..ec9e2bb 100644
--- a/lib/dedupe.c
+++ b/lib/dedupe.c
@@ -77,6 +77,7 @@ struct z_erofs_dedupe_item {
int original_length;
bool partial, raw;
+ char algofmt;
u8 extra_data[];
};
@@ -144,6 +145,7 @@ int z_erofs_dedupe_match(struct z_erofs_dedupe_ctx *ctx)
ctx->e.inlined = false;
ctx->e.pstart = e->pstart;
ctx->e.plen = e->plen;
+ ctx->e.algofmt = e->algofmt;
return 0;
}
return -ENOENT;
@@ -183,6 +185,7 @@ int z_erofs_dedupe_insert(struct z_erofs_inmem_extent *e,
di->plen = e->plen;
di->partial = e->partial;
di->raw = e->raw;
+ di->algofmt = e->algofmt;
di->chain = dedupe_subtree;
dedupe_subtree = di;
list_add_tail(&di->list, p);
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-16 7:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-16 7:11 [PATCH v3 1/4] erofs-utils: record algorithm id in in-memory compression extents Gao Xiang
-- strict thread matches above, loose matches on Subject: below --
2026-09-16 7:40 Gao Xiang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.