Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5313701pxb; Sun, 6 Feb 2022 21:51:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3HEJiNsqKq49+uW6sbkbPzLNWu5/uiWKQg1xh/wQBBwowOWbfRt4OF27he98gVF2/RyxR X-Received: by 2002:a05:6a00:228e:: with SMTP id f14mr14424973pfe.33.1644213112542; Sun, 06 Feb 2022 21:51:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644213112; cv=none; d=google.com; s=arc-20160816; b=c0Vci4GgzNkyF1Fnu0hIGGk+G5KguBB96Ic0PfUw5r2K6kyNMdEdOMmQ9Mf+KNgetf DrThYiElsJCbi8i2VsgYn0hqTI2DBc0oJ7fgZWqA1OGzAVJxdWOiSXvfyvRwXqnUBmva 7R5pyT/rHU3/7pb90FGSn6c25ZHn2HYh5HYEd5a23rplyzqD2QCdMwL7QKf1HRs7RgoP 9deXZSAUlb1YqW6+lFWjRXI/qOTA0PWIh2OgA646pcAQRcXZJxt28js3eOT4qDu1wmhd rFTLh16Bu4/MjkQyJploHTr6z169M4A6mtZOAx6RSuPN8X9XR4OXJZcyESNEtLYRjgsi j9rA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=pz7ud2/CgRMRi21TM0w7xe6ok4nWFEYY0gner1dkq7I=; b=RW1Nlnp7ICrWPWhDbAESopPHp/SuoR6Qcq746sCIgNaEUSmD1Rb9SvlLqWeQTPuH9g gRgoiK9gS1TiwQIpQ3vZDkE3VbddNQuOl0kBp98LBm2TX0b6XwKdGygrXKRfBRPXVdAn so8UnaWHMaC4gWyoZSvxvOWhSJBwDltVZGtwUHw9UKob5krLarYYpibK5D9+5wkHyRLp YWYwQ4+ZTrQncP1lDi+yt50P6PxW0HDQjhpY/6/MAj3NwuufA+0wGSZlvM5szsYMLfmc RQxDcdsyiHxomxm3prAfLfaEkRh4Ofx4f+2RIVSDUpX34AFnZB37bxKNtfZCM4by0kUq Tdsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PjqcSqb6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p41si9044366pfh.140.2022.02.06.21.51.11; Sun, 06 Feb 2022 21:51:52 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PjqcSqb6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353634AbiBCTCO (ORCPT + 99 others); Thu, 3 Feb 2022 14:02:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234261AbiBCTCN (ORCPT ); Thu, 3 Feb 2022 14:02:13 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2567BC061714 for ; Thu, 3 Feb 2022 11:02:13 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B63E16194B for ; Thu, 3 Feb 2022 19:02:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 707D8C340E8; Thu, 3 Feb 2022 19:02:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643914932; bh=cJG9o5eRJ7YKbd6n5DSg9CwYjNG9DgWrahvpoQ7Qonk=; h=From:To:Cc:Subject:Date:From; b=PjqcSqb60rsEKs3aCMdcvdPf2Cgl8zARK3XuFKckymcpDKk/Th5F7QVMJyaBPPmvi ab65P90ABnbMlJ97b0bKPJwTsAABhAjATHPmE1HzC13RYQtngQE9ZaUVZD7ATnxATK /TwWoZzsmPBGwUiTI5U3vJbWmaI2JMfjD6Rdrcb2/eaFu+2nzfeIj7eRdYQhyT48GF UXaHYNZ5igVT+w95Tqt/TEoCK7iCML23hjf9IMZ3vfLjbZwc6fYaZI3Yqxmv1R8omP V6tw9CEBrEwQoFcywDwBz+7UShnMjY+1UovbXs8rmDC6N2CLJaxFod0WmoxhPJeSPe 3jYVAdISA9+bg== From: Gao Xiang To: linux-erofs@lists.ozlabs.org, Chao Yu Cc: LKML , Gao Xiang Subject: [PATCH] erofs: fix small compressed files inlining Date: Fri, 4 Feb 2022 03:02:03 +0800 Message-Id: <20220203190203.30794-1-xiang@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gao Xiang Prior to ztailpacking feature, it's enough that each lcluster has two pclusters at most, and the last pcluster should be turned into an uncompressed pcluster if necessary. For example, _________________________________________________ |_ pcluster n-2 _|_ pcluster n-1 _|____ EOFed ____| which should be converted into: _________________________________________________ |_ pcluster n-2 _|_ pcluster n-1 (uncompressed)' _| That is fine since either pcluster n-1 or (uncompressed)' takes one physical block. However, after ztailpacking supported, the game is changed since the last pcluster can be inlined now. And such case above is quite common for inlining small files. Therefore, in order to inline such files more effectively, special EOF lclusters are now supported which can have three parts at most, as illustrated below: _________________________________________________ |_ pcluster n-2 _|_ pcluster n-1 _|____ EOFed ____| ^ i_size Actually similar code exists in Yue Hu's original patchset [1], but I removed this part on purpose. After evaluating more real cases with small files, I've changed my mind. [1] https://lore.kernel.org/r/20211215094449.15162-1-huyue2@yulong.com Fixes: ab92184ff8f1 ("erofs: add on-disk compressed tail-packing inline support") Signed-off-by: Gao Xiang --- fs/erofs/zmap.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c index 18d7fd1a5064..723ebfa6a27d 100644 --- a/fs/erofs/zmap.c +++ b/fs/erofs/zmap.c @@ -630,6 +630,13 @@ static int z_erofs_do_map_blocks(struct inode *inode, if (endoff >= m.clusterofs) { m.headtype = m.type; map->m_la = (m.lcn << lclusterbits) | m.clusterofs; + /* + * For ztailpacking files, in order to inline data more + * effectively, special EOF lclusters are now supported + * which can have three parts at most. + */ + if (ztailpacking && end >= inode->i_size) + end = inode->i_size; break; } /* m.lcn should be >= 1 if endoff < m.clusterofs */ -- 2.20.1