compress: rework callers to always use the zio_compress calls

This will make future refactoring easier.

There are two we can't change for the moment, because zio_compress_data
does hole detection & collapsing which zio_decompress_data does not
actually know how to handle.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
This commit is contained in:
Rob Norris
2024-07-04 16:11:12 +10:00
committed by Tony Hutter
parent ba2209ec9e
commit 5eede0d5fd
3 changed files with 15 additions and 6 deletions
+9 -4
View File
@@ -52,6 +52,7 @@ ddt_zap_compress(const void *src, uchar_t *dst, size_t s_len, size_t d_len)
ASSERT3U(d_len, >=, s_len + 1); /* no compression plus version byte */
/* Call compress function directly to avoid hole detection. */
c_len = ci->ci_compress((void *)src, dst, s_len, d_len - 1,
ci->ci_level);
@@ -72,12 +73,16 @@ ddt_zap_decompress(uchar_t *src, void *dst, size_t s_len, size_t d_len)
{
uchar_t version = *src++;
int cpfunc = version & DDT_ZAP_COMPRESS_FUNCTION_MASK;
zio_compress_info_t *ci = &zio_compress_table[cpfunc];
if (ci->ci_decompress != NULL)
(void) ci->ci_decompress(src, dst, s_len, d_len, ci->ci_level);
else
if (zio_compress_table[cpfunc].ci_decompress == NULL) {
memcpy(dst, src, d_len);
return;
}
abd_t sabd;
abd_get_from_buf_struct(&sabd, src, s_len);
VERIFY0(zio_decompress_data(cpfunc, &sabd, dst, s_len, d_len, NULL));
abd_free(&sabd);
if (((version & DDT_ZAP_COMPRESS_BYTEORDER_MASK) != 0) !=
(ZFS_HOST_BYTEORDER != 0))