[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <d424334dc32483e93baf0a215dab88c90d14e5c2.1661146058.git.huyue2@coolpad.com>
Date: Mon, 22 Aug 2022 13:53:00 +0800
From: Yue Hu <zbestahu@...il.com>
To: xiang@...nel.org, chao@...nel.org
Cc: linux-erofs@...ts.ozlabs.org, linux-kernel@...r.kernel.org,
zhangwen@...lpad.com, Yue Hu <huyue2@...lpad.com>
Subject: [RFC PATCH 1/2] erofs: support on-disk offset for shifted decompression
From: Yue Hu <huyue2@...lpad.com>
Currently, there is no start offset when writing uncompressed data to
disk blocks for compressed files. However, we are using in-place I/O
which will decrease the number of memory copies a lot if we write it
just from an offset of 'pageofs_out'. So, let's support it.
Signed-off-by: Yue Hu <huyue2@...lpad.com>
---
fs/erofs/decompressor.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index 2d55569f96ac..dc02d95b52d7 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -326,6 +326,7 @@ static int z_erofs_shifted_transform(struct z_erofs_decompress_req *rq,
PAGE_SIZE - rq->pageofs_out);
const unsigned int lefthalf = rq->outputsize - righthalf;
unsigned char *src, *dst;
+ unsigned int headofs_in;
if (nrpages_out > 2) {
DBG_BUGON(1);
@@ -337,21 +338,25 @@ static int z_erofs_shifted_transform(struct z_erofs_decompress_req *rq,
return 0;
}
+ /* set it to pageofs_out if fragments feature is used */
+ headofs_in = 0;
+
src = kmap_atomic(*rq->in) + rq->pageofs_in;
if (rq->out[0]) {
dst = kmap_atomic(rq->out[0]);
- memcpy(dst + rq->pageofs_out, src, righthalf);
+ memcpy(dst + rq->pageofs_out, src + headofs_in, righthalf);
kunmap_atomic(dst);
}
if (nrpages_out == 2) {
DBG_BUGON(!rq->out[1]);
- if (rq->out[1] == *rq->in) {
- memmove(src, src + righthalf, lefthalf);
- } else {
+ if (rq->out[1] != *rq->in) {
dst = kmap_atomic(rq->out[1]);
- memcpy(dst, src + righthalf, lefthalf);
+ memcpy(dst, src + (headofs_in ? 0 : righthalf),
+ lefthalf);
kunmap_atomic(dst);
+ } else if (!headofs_in) {
+ memmove(src, src + righthalf, lefthalf);
}
}
kunmap_atomic(src);
--
2.17.1
Powered by blists - more mailing lists