mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 03:37:45 +03:00
Skip memory allocation when compressing holes
Hole detection in the zio compression code allows us to opportunistically skip compression on holes. We can go a step further by not doing memory allocations on holes either. Reviewed-by: Brian Atkinson <batkinson@lanl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: Richard Yao <richard.yao@klarasystems.com> Sponsored-by: Wasabi Technology, Inc. Closes #14500
This commit is contained in:
+8
-8
@@ -1816,12 +1816,13 @@ arc_hdr_authenticate(arc_buf_hdr_t *hdr, spa_t *spa, uint64_t dsobj)
|
||||
*/
|
||||
if (HDR_GET_COMPRESS(hdr) != ZIO_COMPRESS_OFF &&
|
||||
!HDR_COMPRESSION_ENABLED(hdr)) {
|
||||
tmpbuf = zio_buf_alloc(lsize);
|
||||
|
||||
csize = zio_compress_data(HDR_GET_COMPRESS(hdr),
|
||||
hdr->b_l1hdr.b_pabd, &tmpbuf, lsize, hdr->b_complevel);
|
||||
ASSERT3P(tmpbuf, !=, NULL);
|
||||
ASSERT3U(csize, <=, psize);
|
||||
abd = abd_get_from_buf(tmpbuf, lsize);
|
||||
abd_take_ownership_of_buf(abd, B_TRUE);
|
||||
csize = zio_compress_data(HDR_GET_COMPRESS(hdr),
|
||||
hdr->b_l1hdr.b_pabd, tmpbuf, lsize, hdr->b_complevel);
|
||||
ASSERT3U(csize, <=, psize);
|
||||
abd_zero_off(abd, csize, psize - csize);
|
||||
}
|
||||
|
||||
@@ -9402,7 +9403,7 @@ l2arc_apply_transforms(spa_t *spa, arc_buf_hdr_t *hdr, uint64_t asize,
|
||||
cabd = abd_alloc_for_io(size, ismd);
|
||||
tmp = abd_borrow_buf(cabd, size);
|
||||
|
||||
psize = zio_compress_data(compress, to_write, tmp, size,
|
||||
psize = zio_compress_data(compress, to_write, &tmp, size,
|
||||
hdr->b_complevel);
|
||||
|
||||
if (psize >= asize) {
|
||||
@@ -10867,12 +10868,11 @@ l2arc_log_blk_commit(l2arc_dev_t *dev, zio_t *pio, l2arc_write_callback_t *cb)
|
||||
uint64_t psize, asize;
|
||||
zio_t *wzio;
|
||||
l2arc_lb_abd_buf_t *abd_buf;
|
||||
uint8_t *tmpbuf;
|
||||
uint8_t *tmpbuf = NULL;
|
||||
l2arc_lb_ptr_buf_t *lb_ptr_buf;
|
||||
|
||||
VERIFY3S(dev->l2ad_log_ent_idx, ==, dev->l2ad_log_entries);
|
||||
|
||||
tmpbuf = zio_buf_alloc(sizeof (*lb));
|
||||
abd_buf = zio_buf_alloc(sizeof (*abd_buf));
|
||||
abd_buf->abd = abd_get_from_buf(lb, sizeof (*lb));
|
||||
lb_ptr_buf = kmem_zalloc(sizeof (l2arc_lb_ptr_buf_t), KM_SLEEP);
|
||||
@@ -10891,7 +10891,7 @@ l2arc_log_blk_commit(l2arc_dev_t *dev, zio_t *pio, l2arc_write_callback_t *cb)
|
||||
|
||||
/* try to compress the buffer */
|
||||
psize = zio_compress_data(ZIO_COMPRESS_LZ4,
|
||||
abd_buf->abd, tmpbuf, sizeof (*lb), 0);
|
||||
abd_buf->abd, (void **) &tmpbuf, sizeof (*lb), 0);
|
||||
|
||||
/* a log block is never entirely zero */
|
||||
ASSERT(psize != 0);
|
||||
|
||||
Reference in New Issue
Block a user