Skip to content

Commit 2433105

Browse files
committed
erofs: fix small compressed files inlining
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 when 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 was 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 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 Link: https://lore.kernel.org/r/20220203190203.30794-1-xiang@kernel.org Fixes: ab92184 ("erofs: add on-disk compressed tail-packing inline support") Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
1 parent 7865827 commit 2433105

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/erofs/zmap.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,13 @@ static int z_erofs_do_map_blocks(struct inode *inode,
630630
if (endoff >= m.clusterofs) {
631631
m.headtype = m.type;
632632
map->m_la = (m.lcn << lclusterbits) | m.clusterofs;
633+
/*
634+
* For ztailpacking files, in order to inline data more
635+
* effectively, special EOF lclusters are now supported
636+
* which can have three parts at most.
637+
*/
638+
if (ztailpacking && end > inode->i_size)
639+
end = inode->i_size;
633640
break;
634641
}
635642
/* m.lcn should be >= 1 if endoff < m.clusterofs */

0 commit comments

Comments
 (0)