From 5eede0d5fde556107321fae6b41d6f83eeaf28a1 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Thu, 4 Jul 2024 16:11:12 +1000 Subject: [PATCH] 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 --- module/zfs/blkptr.c | 7 +++++-- module/zfs/ddt_zap.c | 13 +++++++++---- module/zfs/dsl_dataset.c | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/module/zfs/blkptr.c b/module/zfs/blkptr.c index d85f0737f..6a6f06c73 100644 --- a/module/zfs/blkptr.c +++ b/module/zfs/blkptr.c @@ -142,8 +142,11 @@ decode_embedded_bp(const blkptr_t *bp, void *buf, int buflen) if (BP_GET_COMPRESS(bp) != ZIO_COMPRESS_OFF) { uint8_t dstbuf[BPE_PAYLOAD_SIZE]; decode_embedded_bp_compressed(bp, dstbuf); - VERIFY0(zio_decompress_data_buf(BP_GET_COMPRESS(bp), - dstbuf, buf, psize, buflen, NULL)); + abd_t dstabd; + abd_get_from_buf_struct(&dstabd, dstbuf, psize); + VERIFY0(zio_decompress_data(BP_GET_COMPRESS(bp), &dstabd, + buf, psize, buflen, NULL)); + abd_free(&dstabd); } else { ASSERT3U(lsize, ==, psize); decode_embedded_bp_compressed(bp, buf); diff --git a/module/zfs/ddt_zap.c b/module/zfs/ddt_zap.c index 4e01624f3..8e78ec327 100644 --- a/module/zfs/ddt_zap.c +++ b/module/zfs/ddt_zap.c @@ -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)) diff --git a/module/zfs/dsl_dataset.c b/module/zfs/dsl_dataset.c index 45d8a290d..28e07259d 100644 --- a/module/zfs/dsl_dataset.c +++ b/module/zfs/dsl_dataset.c @@ -2425,6 +2425,7 @@ get_receive_resume_token_impl(dsl_dataset_t *ds) fnvlist_free(token_nv); compressed = kmem_alloc(packed_size, KM_SLEEP); + /* Call compress function directly to avoid hole detection. */ compressed_size = gzip_compress(packed, compressed, packed_size, packed_size, 6);