erofs-utils: lib: fix compressed packed inodes
authorDanny Lin <danny@orbstack.dev>
Mon, 23 Sep 2024 05:17:29 +0000 (22:17 -0700)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Mon, 23 Sep 2024 15:17:04 +0000 (23:17 +0800)
commit8b56d3f08d08d12df73de05f338edb84506247f2
tree3bc24b476af15afdd7e2e7322cbd179a802e0d4a
parente975306228724e41e918d7bb6fa7cb7d0040daa2
erofs-utils: lib: fix compressed packed inodes

Commit 2fdbd28 fixed uncompressed packed inodes by not always writing
compressed data, but it broke compressed packed inodes because now
uncompressed file data is always written after the compressed data.

The new error handling always rewinds with lseek and falls through to
write_uncompressed_file_from_fd, regardless of whether the compressed
data was written successfully (ret = 0) or not (ret = -ENOSPC). This
can result in corrupted files.

Fix it by simplifying the error handling to better match the old code.

Fixes: 2fdbd28 ("erofs-utils: lib: fix uncompressed packed inode")
Co-authored-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Danny Lin <danny@orbstack.dev>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240923051759.7563-2-danny@orbstack.dev
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
lib/inode.c