diff options
author | Rob Norris <[email protected]> | 2024-07-04 14:48:38 +1000 |
---|---|---|
committer | Tony Hutter <[email protected]> | 2024-08-22 16:22:24 -0700 |
commit | f62e6e1f985b5cc197940dcd2dc839aab0708ca2 (patch) | |
tree | 3579464a2971d651e4398b24c9849f6d886ba5d9 /cmd | |
parent | d3c12383c95cf7988ac00234a42a4da7989c9034 (diff) |
compress: change zio_compress API to use ABDs
This commit changes the frontend zio_compress_data and
zio_decompress_data APIs to take ABD points instead of buffer pointers.
All callers are updated to match. Any that already have an appropriate
ABD nearby now use it directly, while at the rest we create an one.
Internally, the ABDs are passed through to the provider directly.
Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <[email protected]>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/zdb/zdb.c | 37 | ||||
-rw-r--r-- | cmd/zstream/zstream_recompress.c | 17 |
2 files changed, 36 insertions, 18 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index c72df3909..41c2b6765 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -4657,7 +4657,6 @@ dump_l2arc_log_blocks(int fd, const l2arc_dev_hdr_phys_t *l2dhdr, l2arc_log_blk_phys_t this_lb; uint64_t asize; l2arc_log_blkptr_t lbps[2]; - abd_t *abd; zio_cksum_t cksum; int failed = 0; l2arc_dev_t dev; @@ -4711,20 +4710,25 @@ dump_l2arc_log_blocks(int fd, const l2arc_dev_hdr_phys_t *l2dhdr, switch (L2BLK_GET_COMPRESS((&lbps[0])->lbp_prop)) { case ZIO_COMPRESS_OFF: break; - default: - abd = abd_alloc_for_io(asize, B_TRUE); + default: { + abd_t *abd = abd_alloc_linear(asize, B_TRUE); abd_copy_from_buf_off(abd, &this_lb, 0, asize); - if (zio_decompress_data(L2BLK_GET_COMPRESS( - (&lbps[0])->lbp_prop), abd, &this_lb, - asize, sizeof (this_lb), NULL) != 0) { + abd_t dabd; + abd_get_from_buf_struct(&dabd, &this_lb, + sizeof (this_lb)); + int err = zio_decompress_data(L2BLK_GET_COMPRESS( + (&lbps[0])->lbp_prop), abd, &dabd, + asize, sizeof (this_lb), NULL); + abd_free(&dabd); + abd_free(abd); + if (err != 0) { (void) printf("L2ARC block decompression " "failed\n"); - abd_free(abd); goto out; } - abd_free(abd); break; } + } if (this_lb.lb_magic == BSWAP_64(L2ARC_LOG_BLK_MAGIC)) byteswap_uint64_array(&this_lb, sizeof (this_lb)); @@ -8618,13 +8622,22 @@ try_decompress_block(abd_t *pabd, uint64_t lsize, uint64_t psize, memset(lbuf, 0x00, lsize); memset(lbuf2, 0xff, lsize); + abd_t labd, labd2; + abd_get_from_buf_struct(&labd, lbuf, lsize); + abd_get_from_buf_struct(&labd2, lbuf2, lsize); + + boolean_t ret = B_FALSE; if (zio_decompress_data(cfunc, pabd, - lbuf, psize, lsize, NULL) == 0 && + &labd, psize, lsize, NULL) == 0 && zio_decompress_data(cfunc, pabd, - lbuf2, psize, lsize, NULL) == 0 && + &labd2, psize, lsize, NULL) == 0 && memcmp(lbuf, lbuf2, lsize) == 0) - return (B_TRUE); - return (B_FALSE); + ret = B_TRUE; + + abd_free(&labd2); + abd_free(&labd); + + return (ret); } static uint64_t diff --git a/cmd/zstream/zstream_recompress.c b/cmd/zstream/zstream_recompress.c index 0e5cc9cd8..32ef6fa54 100644 --- a/cmd/zstream/zstream_recompress.c +++ b/cmd/zstream/zstream_recompress.c @@ -259,12 +259,13 @@ zstream_do_recompress(int argc, char *argv[]) /* Read and decompress the payload */ (void) sfread(cbuf, payload_size, stdin); if (dtype != ZIO_COMPRESS_OFF) { - abd_t cabd; + abd_t cabd, dabd; abd_get_from_buf_struct(&cabd, cbuf, payload_size); - if (zio_decompress_data(dtype, &cabd, dbuf, - payload_size, - MIN(bufsz, drrw->drr_logical_size), + abd_get_from_buf_struct(&dabd, dbuf, + MIN(bufsz, drrw->drr_logical_size)); + if (zio_decompress_data(dtype, &cabd, &dabd, + payload_size, abd_get_size(&dabd), NULL) != 0) { warnx("decompression type %d failed " "for ino %llu offset %llu", @@ -274,17 +275,20 @@ zstream_do_recompress(int argc, char *argv[]) exit(4); } payload_size = drrw->drr_logical_size; + abd_free(&dabd); abd_free(&cabd); free(cbuf); } /* Recompress the payload */ if (ctype != ZIO_COMPRESS_OFF) { - abd_t dabd; + abd_t dabd, abd; abd_get_from_buf_struct(&dabd, dbuf, drrw->drr_logical_size); + abd_t *pabd = + abd_get_from_buf_struct(&abd, buf, bufsz); payload_size = P2ROUNDUP(zio_compress_data( - ctype, &dabd, (void **)&buf, + ctype, &dabd, &pabd, drrw->drr_logical_size, level), SPA_MINBLOCKSIZE); if (payload_size != drrw->drr_logical_size) { @@ -296,6 +300,7 @@ zstream_do_recompress(int argc, char *argv[]) drrw->drr_compressiontype = 0; drrw->drr_compressed_size = 0; } + abd_free(&abd); abd_free(&dabd); free(dbuf); } else { |