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 5457EC47258 for ; Mon, 15 Jan 2024 15:06:12 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TDFpC0M7sz3bpt for ; Tue, 16 Jan 2024 02:06:11 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.alibaba.com (client-ip=115.124.30.124; helo=out30-124.freemail.mail.aliyun.com; envelope-from=hsiangkao@linux.alibaba.com; receiver=lists.ozlabs.org) Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (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 4TDFp43vXHz2ytJ for ; Tue, 16 Jan 2024 02:06:02 +1100 (AEDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0W-j7XYN_1705331151; Received: from e69b19392.et15sqa.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0W-j7XYN_1705331151) by smtp.aliyun-inc.com; Mon, 15 Jan 2024 23:05:56 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Subject: [PATCH] erofs-utils: lib: use dummy_pivot to dedupe the beginnings of files Date: Mon, 15 Jan 2024 23:05:50 +0800 Message-Id: <20240115150550.1961455-1-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 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 , Yifan Zhao Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" The beginnings of files are incorrectly skipped for deduplication, which causes unexpected image size regression. Fix it. Reported-by: Yifan Zhao Fixes: 8ead5f8bd38c ("erofs-utils: lib: generate compression indexes in memory first") Signed-off-by: Gao Xiang --- lib/compress.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/compress.c b/lib/compress.c index 8f61f92..22782cb 100644 --- a/lib/compress.c +++ b/lib/compress.c @@ -200,9 +200,16 @@ static bool z_erofs_need_refill(struct z_erofs_vle_compress_ctx *ctx) return true; } +static struct z_erofs_extent_item dummy_pivot = { + .e.length = 0 +}; + static void z_erofs_commit_extent(struct z_erofs_vle_compress_ctx *ctx, struct z_erofs_extent_item *ei) { + if (ei == &dummy_pivot) + return; + list_add_tail(&ei->list, &ctx->extents); ctx->clusterofs = (ctx->clusterofs + ei->e.length) & (erofs_blksiz(ctx->inode->sbi) - 1); @@ -980,7 +987,7 @@ int erofs_write_compressed_file(struct erofs_inode *inode, int fd) ctx.metacur = compressmeta + Z_EROFS_LEGACY_MAP_HEADER_SIZE; ctx.head = ctx.tail = 0; ctx.clusterofs = 0; - ctx.pivot = NULL; + ctx.pivot = &dummy_pivot; init_list_head(&ctx.extents); ctx.remaining = inode->i_size - inode->fragment_size; ctx.fix_dedupedfrag = false; -- 2.39.3