diff --git a/include/sys/zio_compress.h b/include/sys/zio_compress.h index 691d7b6244..d0caee279f 100644 --- a/include/sys/zio_compress.h +++ b/include/sys/zio_compress.h @@ -187,8 +187,6 @@ extern size_t zio_compress_data(enum zio_compress c, abd_t *src, void **dst, size_t s_len, uint8_t level); extern int zio_decompress_data(enum zio_compress c, abd_t *src, void *dst, size_t s_len, size_t d_len, uint8_t *level); -extern int zio_decompress_data_buf(enum zio_compress c, void *src, void *dst, - size_t s_len, size_t d_len, uint8_t *level); extern int zio_compress_to_feature(enum zio_compress comp); #ifdef __cplusplus diff --git a/module/zfs/zio_compress.c b/module/zfs/zio_compress.c index c3bceababa..1d448b0026 100644 --- a/module/zfs/zio_compress.c +++ b/module/zfs/zio_compress.c @@ -161,26 +161,22 @@ zio_compress_data(enum zio_compress c, abd_t *src, void **dst, size_t s_len, } int -zio_decompress_data_buf(enum zio_compress c, void *src, void *dst, +zio_decompress_data(enum zio_compress c, abd_t *src, void *dst, size_t s_len, size_t d_len, uint8_t *level) { zio_compress_info_t *ci = &zio_compress_table[c]; if ((uint_t)c >= ZIO_COMPRESS_FUNCTIONS || ci->ci_decompress == NULL) return (SET_ERROR(EINVAL)); + void *sbuf = abd_borrow_buf_copy(src, s_len); + + int err; if (ci->ci_decompress_level != NULL && level != NULL) - return (ci->ci_decompress_level(src, dst, s_len, d_len, level)); + err = ci->ci_decompress_level(sbuf, dst, s_len, d_len, level); + else + err = ci->ci_decompress(sbuf, dst, s_len, d_len, ci->ci_level); - return (ci->ci_decompress(src, dst, s_len, d_len, ci->ci_level)); -} - -int -zio_decompress_data(enum zio_compress c, abd_t *src, void *dst, - size_t s_len, size_t d_len, uint8_t *level) -{ - void *tmp = abd_borrow_buf_copy(src, s_len); - int ret = zio_decompress_data_buf(c, tmp, dst, s_len, d_len, level); - abd_return_buf(src, tmp, s_len); + abd_return_buf(src, sbuf, s_len); /* * Decompression shouldn't fail, because we've already verified @@ -189,9 +185,9 @@ zio_decompress_data(enum zio_compress c, abd_t *src, void *dst, */ if (zio_decompress_fail_fraction != 0 && random_in_range(zio_decompress_fail_fraction) == 0) - ret = SET_ERROR(EINVAL); + err = SET_ERROR(EINVAL); - return (ret); + return (err); } int