Skip to content

Commit c553976

Browse files
committed
erofs: simplify z_erofs_transform_plain()
Use memcpy_to_page() instead of open-coding them. In addition, add a missing flush_dcache_page() even though almost all modern architectures clear `PG_dcache_clean` flag for new file cache pages so that it doesn't change anything in practice. Signed-off-by: Gao Xiang <[email protected]> Reviewed-by: Yue Hu <[email protected]> Reviewed-by: Chao Yu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Gao Xiang <[email protected]>
1 parent 123ec24 commit c553976

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

fs/erofs/decompressor.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq,
328328
const unsigned int lefthalf = rq->outputsize - righthalf;
329329
const unsigned int interlaced_offset =
330330
rq->alg == Z_EROFS_COMPRESSION_SHIFTED ? 0 : rq->pageofs_out;
331-
unsigned char *src, *dst;
331+
u8 *src;
332332

333333
if (outpages > 2 && rq->alg == Z_EROFS_COMPRESSION_SHIFTED) {
334334
DBG_BUGON(1);
@@ -341,22 +341,19 @@ static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq,
341341
}
342342

343343
src = kmap_local_page(rq->in[inpages - 1]) + rq->pageofs_in;
344-
if (rq->out[0]) {
345-
dst = kmap_local_page(rq->out[0]);
346-
memcpy(dst + rq->pageofs_out, src + interlaced_offset,
347-
righthalf);
348-
kunmap_local(dst);
349-
}
344+
if (rq->out[0])
345+
memcpy_to_page(rq->out[0], rq->pageofs_out,
346+
src + interlaced_offset, righthalf);
350347

351348
if (outpages > inpages) {
352349
DBG_BUGON(!rq->out[outpages - 1]);
353350
if (rq->out[outpages - 1] != rq->in[inpages - 1]) {
354-
dst = kmap_local_page(rq->out[outpages - 1]);
355-
memcpy(dst, interlaced_offset ? src :
356-
(src + righthalf), lefthalf);
357-
kunmap_local(dst);
351+
memcpy_to_page(rq->out[outpages - 1], 0, src +
352+
(interlaced_offset ? 0 : righthalf),
353+
lefthalf);
358354
} else if (!interlaced_offset) {
359355
memmove(src, src + righthalf, lefthalf);
356+
flush_dcache_page(rq->in[inpages - 1]);
360357
}
361358
}
362359
kunmap_local(src);

0 commit comments

Comments
 (0)