Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp17943521rwd; Tue, 27 Jun 2023 09:25:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7WqVdCK1mds8EJRZTTg9Y1ZTmpS3IL9bwXUmuqO465CmZrdHX2Jx9eHtr3CuF1+W1wg6sL X-Received: by 2002:a2e:6e07:0:b0:2b0:573a:3c69 with SMTP id j7-20020a2e6e07000000b002b0573a3c69mr21229734ljc.23.1687883100960; Tue, 27 Jun 2023 09:25:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687883100; cv=none; d=google.com; s=arc-20160816; b=feOV0Gl7SWcjRlyVRN9oaOmXWJAWjQ7nLs7jccih/M2qaAJ+xm+yN70Jh4OcpBE07u kz+TORUuDBb9pDfPpJRv9DK5/23Brct3CxuwjTgs9S7KFI+N2o3d2oaHNgDSEysHOe9H 5H/ZoZ2vJl+pMGmATdKfCDoSPKf2AiRN8aAz/XCkkqtojy5jpRfs+8heGQb3JFCTkAcg YZt4FCYhgRJ8A7A+NS5z0vLcc52HeiP5rYoHkT2jRuF4CIkctRx1OkyD9ud4gCCI3TWB OrZ81aXD/Ww5p4ZYTyuP+HF8gVrj7W2HnlqG11R6dPFqUWUVJddZgU6Ac+sGuFcsy6Em KIOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=TM6XY3wcFgWmuX/qmYGGo3as05E4//UuEAFSwJVyfh8=; fh=O78HJmpL5F5vEBJ7fj5QgOSmUhamGk6jv8eSOg+ntqY=; b=SdFnjUpbdGdqIwvKYdkcnh+0TQEphz78owPEj7XdJ30yk9DVb2q708SEReAhZEtXVu 2Ea5PY+sZ/0LMVuI2WDlfCHv/ZssVa7HgK0EIDvYX+pWtohygq5tBkf/njuvoA9lsIZo id+/coeLVvJrGlp1nsIM8aU34qTQ9hSUsK3aDHXySfwnNYUxe+HWveHRCmO5fxgXpfRd 9+MHHdDlFeYjsb60NSAshVn0d8SID21Ur6E5dWhmDc2SVSCaEDI/UN/vsmIU3Jj9xefC 6xSiisbsAI+NIlWDYyLnSBdAcYHPTsYHpjPLuDFzxYYcD9SjbmR5mPX/LyVVy5MaGdFT 8QVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f23-20020a170906825700b0098e42bef737si3204612ejx.242.2023.06.27.09.24.34; Tue, 27 Jun 2023 09:25:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231886AbjF0QNG (ORCPT + 99 others); Tue, 27 Jun 2023 12:13:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231952AbjF0QNE (ORCPT ); Tue, 27 Jun 2023 12:13:04 -0400 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ECC330DB for ; Tue, 27 Jun 2023 09:12:56 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R381e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0Vm6X30h_1687882372; Received: from e18g06460.et15sqa.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0Vm6X30h_1687882372) by smtp.aliyun-inc.com; Wed, 28 Jun 2023 00:12:53 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: LKML , Gao Xiang Subject: [PATCH 2/2] erofs: simplify z_erofs_transform_plain() Date: Wed, 28 Jun 2023 00:12:40 +0800 Message-Id: <20230627161240.331-2-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.24.4 In-Reply-To: <20230627161240.331-1-hsiangkao@linux.alibaba.com> References: <20230627161240.331-1-hsiangkao@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- preliminary tested with silesia dataset. fs/erofs/decompressor.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c index ad53cf52d899..cfad1eac7fd9 100644 --- a/fs/erofs/decompressor.c +++ b/fs/erofs/decompressor.c @@ -328,7 +328,7 @@ static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq, const unsigned int lefthalf = rq->outputsize - righthalf; const unsigned int interlaced_offset = rq->alg == Z_EROFS_COMPRESSION_SHIFTED ? 0 : rq->pageofs_out; - unsigned char *src, *dst; + u8 *src; if (outpages > 2 && rq->alg == Z_EROFS_COMPRESSION_SHIFTED) { DBG_BUGON(1); @@ -341,22 +341,19 @@ static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq, } src = kmap_local_page(rq->in[inpages - 1]) + rq->pageofs_in; - if (rq->out[0]) { - dst = kmap_local_page(rq->out[0]); - memcpy(dst + rq->pageofs_out, src + interlaced_offset, - righthalf); - kunmap_local(dst); - } + if (rq->out[0]) + memcpy_to_page(rq->out[0], rq->pageofs_out, + src + interlaced_offset, righthalf); if (outpages > inpages) { DBG_BUGON(!rq->out[outpages - 1]); if (rq->out[outpages - 1] != rq->in[inpages - 1]) { - dst = kmap_local_page(rq->out[outpages - 1]); - memcpy(dst, interlaced_offset ? src : - (src + righthalf), lefthalf); - kunmap_local(dst); + memcpy_to_page(rq->out[outpages - 1], 0, src + + (interlaced_offset ? 0 : righthalf), + lefthalf); } else if (!interlaced_offset) { memmove(src, src + righthalf, lefthalf); + flush_dcache_page(rq->in[inpages - 1]); } } kunmap_local(src); -- 2.24.4