* [PATCH] erofs: fix small compressed files inlining
@ 2022-02-03 19:02 Gao Xiang
2022-02-04 3:14 ` Chao Yu
0 siblings, 1 reply; 2+ messages in thread
From: Gao Xiang @ 2022-02-03 19:02 UTC (permalink / raw)
To: linux-erofs, Chao Yu; +Cc: LKML, Gao Xiang
From: Gao Xiang <hsiangkao@linux.alibaba.com>
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 <hsiangkao@linux.alibaba.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] erofs: fix small compressed files inlining
2022-02-03 19:02 [PATCH] erofs: fix small compressed files inlining Gao Xiang
@ 2022-02-04 3:14 ` Chao Yu
0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2022-02-04 3:14 UTC (permalink / raw)
To: Gao Xiang, linux-erofs; +Cc: LKML, Gao Xiang
On 2022/2/4 3:02, Gao Xiang wrote:
> From: Gao Xiang <hsiangkao@linux.alibaba.com>
>
> 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 <hsiangkao@linux.alibaba.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-04 3:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-03 19:02 [PATCH] erofs: fix small compressed files inlining Gao Xiang
2022-02-04 3:14 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox