f2fs: compress: fix zstd data corruption
authorChao Yu <yuchao0@huawei.com>
Fri, 8 May 2020 01:16:03 +0000 (09:16 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Jun 2020 15:48:43 +0000 (17:48 +0200)
commit88868e552b1d677f026202efe8cb3f701121b0a3
tree8050235261c8512179e2cfc3b47a2b1ca76706b1
parentbec32a54a4de62b46466f4da1beb9ddd42db81b8
f2fs: compress: fix zstd data corruption

[ Upstream commit 1454c978efbb57b052670d50023f48c759d704ce ]

During zstd compression, ZSTD_endStream() may return non-zero value
because distination buffer is full, but there is still compressed data
remained in intermediate buffer, it means that zstd algorithm can not
save at last one block space, let's just writeback raw data instead of
compressed one, this can fix data corruption when decompressing
incomplete stored compression data.

Fixes: 50cfa66f0de0 ("f2fs: compress: support zstd compress algorithm")
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/f2fs/compress.c