summaryrefslogtreecommitdiff
path: root/fs/f2fs/compress.c
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2020-05-08 04:16:03 +0300
committerJaegeuk Kim <jaegeuk@kernel.org>2020-05-12 06:37:13 +0300
commit1454c978efbb57b052670d50023f48c759d704ce (patch)
tree27e5443f67eb0dec0eb93c238165193333b93d8d /fs/f2fs/compress.c
parent9c1223845a37ce09fd498b8c8ed061decff20eda (diff)
downloadlinux-1454c978efbb57b052670d50023f48c759d704ce.tar.xz
f2fs: compress: fix zstd data corruption
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>
Diffstat (limited to 'fs/f2fs/compress.c')
-rw-r--r--fs/f2fs/compress.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index dcedf008f359..bf152c0d79fe 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -360,6 +360,13 @@ static int zstd_compress_pages(struct compress_ctx *cc)
return -EIO;
}
+ /*
+ * there is compressed data remained in intermediate buffer due to
+ * no more space in cbuf.cdata
+ */
+ if (ret)
+ return -EAGAIN;
+
cc->clen = outbuf.pos;
return 0;
}