Skip to content

Commit

Permalink
Fixed uncompressed ARC handling of buffer sizes for L2ARC
Browse files Browse the repository at this point in the history
I have no idea when this case comes up, and don't want
to investigate. But it definitely does when early abort
is enabled, because it's passing compress a buffer it
claims is 128k after allocating 512b.

Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
  • Loading branch information
rincebrain committed Apr 24, 2022
1 parent e3eb7fa commit ff1bcc4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9337,19 +9337,20 @@ l2arc_apply_transforms(spa_t *spa, arc_buf_hdr_t *hdr, uint64_t asize,
}

if (compress != ZIO_COMPRESS_OFF && !HDR_COMPRESSION_ENABLED(hdr)) {
cabd = abd_alloc_for_io(asize, ismd);
tmp = abd_borrow_buf(cabd, asize);
cabd = abd_alloc_for_io(size, ismd);
tmp = abd_borrow_buf(cabd, size);

psize = zio_compress_data(compress, to_write, tmp, size,
hdr->b_complevel);

if (psize >= size) {
abd_return_buf(cabd, tmp, asize);
if (psize >= asize) {
psize = HDR_GET_PSIZE(hdr);
abd_return_buf(cabd, tmp, size);
HDR_SET_COMPRESS(hdr, ZIO_COMPRESS_OFF);
to_write = cabd;
abd_copy(to_write, hdr->b_l1hdr.b_pabd, size);
if (size != asize)
abd_zero_off(to_write, size, asize - size);
abd_copy(to_write, hdr->b_l1hdr.b_pabd, psize);
if (psize != asize)
abd_zero_off(to_write, psize, asize - psize);
goto encrypt;
}
ASSERT3U(psize, <=, HDR_GET_PSIZE(hdr));
Expand Down

0 comments on commit ff1bcc4

Please sign in to comment.