Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F72BC32771 for ; Mon, 26 Sep 2022 15:25:44 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4MbmmQ5ZDnz3bZs for ; Tue, 27 Sep 2022 01:25:42 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.alibaba.com (client-ip=115.124.30.45; helo=out30-45.freemail.mail.aliyun.com; envelope-from=hsiangkao@linux.alibaba.com; receiver=) Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4MbmmB6TKZz300V for ; Tue, 27 Sep 2022 01:25:30 +1000 (AEST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0VQoJOMD_1664205926; Received: from e18g06460.et15sqa.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VQoJOMD_1664205926) by smtp.aliyun-inc.com; Mon, 26 Sep 2022 23:25:27 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Subject: [PATCH 4/8] erofs-utils: mkfs: support interlaced uncompressed data layout Date: Mon, 26 Sep 2022 23:25:07 +0800 Message-Id: <20220926152511.94832-5-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.24.4 In-Reply-To: <20220926152511.94832-1-hsiangkao@linux.alibaba.com> References: <20220926152511.94832-1-hsiangkao@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: linux-erofs@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Linux EROFS file system List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gao Xiang , Yue Hu , Ziyang Zhang Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" From: Yue Hu Interlaced uncompressed data can minimize unnecessary data processing by using in-place I/O. However it cannot be used together with deduplication. Signed-off-by: Yue Hu Signed-off-by: Gao Xiang --- lib/compress.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/compress.c b/lib/compress.c index 3c1d9db..8fa60e2 100644 --- a/lib/compress.c +++ b/lib/compress.c @@ -150,7 +150,7 @@ static int write_uncompressed_extent(struct z_erofs_vle_compress_ctx *ctx, unsigned int *len, char *dst) { int ret; - unsigned int count; + unsigned int count, interlaced_offset, rightpart; /* reset clusterofs to 0 if permitted */ if (!erofs_sb_has_lz4_0padding() && ctx->clusterofs && @@ -160,11 +160,16 @@ static int write_uncompressed_extent(struct z_erofs_vle_compress_ctx *ctx, ctx->clusterofs = 0; } - /* write uncompressed data */ count = min(EROFS_BLKSIZ, *len); - memcpy(dst, ctx->queue + ctx->head, count); - memset(dst + count, 0, EROFS_BLKSIZ - count); + /* write interlaced uncompressed data if needed */ + interlaced_offset = 0; /* will set it to clusterofs */ + rightpart = min(EROFS_BLKSIZ - interlaced_offset, count); + + memset(dst, 0, EROFS_BLKSIZ); + + memcpy(dst + interlaced_offset, ctx->queue + ctx->head, rightpart); + memcpy(dst, ctx->queue + ctx->head + rightpart, count - rightpart); erofs_dbg("Writing %u uncompressed data to block %u", count, ctx->blkaddr); -- 2.24.4