[PATCH v2] erofs-utils: fix battach on full buffer block

Gao Xiang hsiangkao at redhat.com
Fri Jan 22 23:43:52 AEDT 2021

Hi Weiwen,

On Fri, Jan 22, 2021 at 12:26:06AM +0800, Hu Weiwen wrote:
> When __erofs_battach() is called on an buffer block of which
> (bb->buffers.off % EROFS_BLKSIZ == 0), `tail_blkaddr' will not be
> updated correctly. This bug can be reproduced by:
> mkdir bug-repo
> head -c 4032 /dev/urandom > bug-repo/1
> head -c 4095 /dev/urandom > bug-repo/2
> head -c 12345 /dev/urandom > bug-repo/3  # arbitrary size
> mkfs.erofs -Eforce-inode-compact bug-repo.erofs.img bug-repo
> Then mount this image and see that file `3' in the image is different
> from `bug-repo/3'.
> This patch fix this by:
> * Don't inline tail-end data in this case, since the tail-end data will
> be in a different block from inode.
> * Correctly handle `battach' in this case.
> Signed-off-by: Hu Weiwen <sehuww at mail.scut.edu.cn>
> ---
> Hi Xiang,
> I still think send this as a seperate patch would be better. In previous v6
> patch, I have fixed the erofs_mapbh() behaviour so that there should be no
> user-visible bug introduced in that patch. And this patch is almost unrelated
> to that optimization.
> Compared with v1, this version fixes an error when compression is enabled.

I have to say I still don't get the point of the whole description
above and the patch itself honestly. even if (bb->buffers.off %
EROFS_BLKSIZ == 0), the whole block can be used for tail-packing
inline + inode. Assume that you testcase above is the case you
addressed, could you elaborate them in detail?

If the original behavior is no user-visiable, I'm not sure what
issue you'd like to resolve...

Gao Xiang

> Thanks,
> Hu Weiwen

More information about the Linux-erofs mailing list