From fa0d54d431ac459ce8a06a0d135454d76a2a7ceb Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 28 Mar 2019 13:41:09 -0700 Subject: [PATCH] reduce: write uncompressed data when compress returns error Most typically, the error will be -ENOSPC, meaning the destination buffer wasn't big enough to hold the compressed data. But even for other types of errors, just write the uncompressed data rather than treating it as an I/O failure. Signed-off-by: Jim Harris Change-Id: Id6526cab95488a1a587b183237f9980c83287761 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449511 Tested-by: SPDK CI Jenkins Reviewed-by: Paul Luse Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker --- lib/reduce/reduce.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/reduce/reduce.c b/lib/reduce/reduce.c index 27dbf19f6..632637f11 100644 --- a/lib/reduce/reduce.c +++ b/lib/reduce/reduce.c @@ -1018,10 +1018,14 @@ _write_compress_done(void *_req, int reduce_errno) { struct spdk_reduce_vol_request *req = _req; - /* Negative reduce_errno indicates failure for compression operations. */ + /* Negative reduce_errno indicates failure for compression operations. + * Just write the uncompressed data instead. Force this to happen + * by just passing the full chunk size to _reduce_vol_write_chunk. + * When it sees the data couldn't be compressed, it will just write + * the uncompressed buffer to disk. + */ if (reduce_errno < 0) { - _reduce_vol_complete_req(req, reduce_errno); - return; + reduce_errno = req->vol->params.chunk_size; } /* Positive reduce_errno indicates number of bytes in compressed buffer. */