Skip to content

Commit

Permalink
Compressed receive with different ashift can result in incorrect PSIZ…
Browse files Browse the repository at this point in the history
…E on disk (openzfs#8462)

Signed-off-by: Paul Dagnelie <[email protected]>
  • Loading branch information
pcd1193182 committed Aug 30, 2021
1 parent 70bf547 commit 85e8a53
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions module/zfs/zio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,20 @@ zio_write_compress(zio_t *zio)
zio->io_abd, NULL, lsize, zp->zp_complevel);
if (psize == 0 || psize >= lsize)
compress = ZIO_COMPRESS_OFF;
} else if (zio->io_flags & ZIO_FLAG_RAW_COMPRESS) {
size_t rounded = MIN((size_t)roundup(psize,
spa->spa_min_alloc), lsize);

if (rounded != psize) {
abd_t *cdata = abd_get_from_buf(zio_buf_alloc(rounded),
rounded);
abd_take_ownership_of_buf(cdata, B_TRUE);
abd_zero_off(cdata, psize, rounded - psize);
abd_copy_off(cdata, zio->io_abd, 0, 0, psize);
psize = rounded;
zio_push_transform(zio, cdata,
psize, rounded, NULL);
}
} else {
ASSERT3U(psize, !=, 0);
}
Expand Down

0 comments on commit 85e8a53

Please sign in to comment.