]> git.ipfire.org Git - people/ms/linux.git/commit - fs/erofs/zmap.c
erofs: fix small compressed files inlining
authorGao Xiang <hsiangkao@linux.alibaba.com>
Thu, 3 Feb 2022 19:02:03 +0000 (03:02 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Fri, 4 Feb 2022 04:37:12 +0000 (12:37 +0800)
commit24331050a3e6afcd4451409831dd9ae8085a42f6
treedf3e493ae7115f10582f4bfa903da01e32f7f81c
parent7865827c432bf9885ee26e5767697c3d9e21a82c
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: ab92184ff8f1 ("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>
fs/erofs/zmap.c