From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: linux-erofs@lists.ozlabs.org
Cc: Gao Xiang <hsiangkao@linux.alibaba.com>
Subject: [PATCH 2/2] erofs-utils: mkfs: support compact indexes for smaller block sizes
Date: Thu, 23 Nov 2023 13:22:45 +0800 [thread overview]
Message-ID: <20231123052245.868698-2-hsiangkao@linux.alibaba.com> (raw)
In-Reply-To: <20231123052245.868698-1-hsiangkao@linux.alibaba.com>
This commit also adds mkfs support of compact indexes for smaller
block sizes (less than 4096).
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
lib/compress.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/lib/compress.c b/lib/compress.c
index 47f1c1d..61328ed 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -627,19 +627,20 @@ static void *write_compacted_indexes(u8 *out,
struct z_erofs_compressindex_vec *cv,
erofs_blk_t *blkaddr_ret,
unsigned int destsize,
- unsigned int logical_clusterbits,
+ unsigned int lclusterbits,
bool final, bool *dummy_head,
bool update_blkaddr)
{
- unsigned int vcnt, encodebits, pos, i, cblks;
+ unsigned int vcnt, lobits, encodebits, pos, i, cblks;
erofs_blk_t blkaddr;
if (destsize == 4)
vcnt = 2;
- else if (destsize == 2 && logical_clusterbits == 12)
+ else if (destsize == 2 && lclusterbits <= 12)
vcnt = 16;
else
return ERR_PTR(-EINVAL);
+ lobits = max(lclusterbits, ilog2(Z_EROFS_LI_D0_CBLKCNT) + 1U);
encodebits = (vcnt * destsize * 8 - 32) / vcnt;
blkaddr = *blkaddr_ret;
@@ -656,7 +657,7 @@ static void *write_compacted_indexes(u8 *out,
*dummy_head = false;
} else if (i + 1 == vcnt) {
offset = min_t(u16, cv[i].u.delta[1],
- (1 << logical_clusterbits) - 1);
+ (1 << lobits) - 1);
} else {
offset = cv[i].u.delta[0];
}
@@ -676,7 +677,7 @@ static void *write_compacted_indexes(u8 *out,
DBG_BUGON(cv[i].u.blkaddr);
}
}
- v = (cv[i].clustertype << logical_clusterbits) | offset;
+ v = (cv[i].clustertype << lobits) | offset;
rem = pos & 7;
ch = out[pos / 8] & ((1 << rem) - 1);
out[pos / 8] = (v << rem) | ch;
@@ -711,7 +712,7 @@ int z_erofs_convert_to_compacted_format(struct erofs_inode *inode,
bool dummy_head;
bool big_pcluster = erofs_sb_has_big_pcluster(sbi);
- if (logical_clusterbits < sbi->blkszbits || sbi->blkszbits < 12)
+ if (logical_clusterbits < sbi->blkszbits)
return -EINVAL;
if (logical_clusterbits > 14) {
erofs_err("compact format is unsupported for lcluster size %u",
@@ -720,7 +721,7 @@ int z_erofs_convert_to_compacted_format(struct erofs_inode *inode,
}
if (inode->z_advise & Z_EROFS_ADVISE_COMPACTED_2B) {
- if (logical_clusterbits != 12) {
+ if (logical_clusterbits > 12) {
erofs_err("compact 2B is unsupported for lcluster size %u",
1 << logical_clusterbits);
return -EINVAL;
--
2.39.3
next prev parent reply other threads:[~2023-11-23 5:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-23 5:22 [PATCH 1/2] erofs-utils: lib: fix up compact indexes for block size < 4096 Gao Xiang
2023-11-23 5:22 ` Gao Xiang [this message]
2023-11-23 9:12 ` [PATCH 2/2] erofs-utils: mkfs: support compact indexes for smaller block sizes Yue Hu
2023-11-23 9:11 ` [PATCH 1/2] erofs-utils: lib: fix up compact indexes for block size < 4096 Yue Hu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231123052245.868698-2-hsiangkao@linux.alibaba.com \
--to=hsiangkao@linux.alibaba.com \
--cc=linux-erofs@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox