Skip to content

Commit e055b42

Browse files
gmelikovlundman
authored andcommitted
ZLE compression: don't use BPE_PAYLOAD_SIZE
ZLE compressor needs additional bytes to process d_len argument efficiently. Don't use BPE_PAYLOAD_SIZE as d_len with it before we rework zle compressor somehow. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: George Melikov <[email protected]> Closes openzfs#9416
1 parent 5d823c4 commit e055b42

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

include/sys/zio.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,8 @@ extern int zio_alloc_zil(spa_t *spa, objset_t *os, uint64_t txg,
608608
extern void zio_flush(zio_t *zio, vdev_t *vd);
609609
extern void zio_shrink(zio_t *zio, uint64_t size);
610610

611-
extern size_t zio_get_compression_max_size(uint64_t gcd_alloc,
612-
uint64_t min_alloc, size_t s_len);
611+
extern size_t zio_get_compression_max_size(enum zio_compress compress,
612+
uint64_t gcd_alloc, uint64_t min_alloc, size_t s_len);
613613
extern int zio_wait(zio_t *zio);
614614
extern void zio_nowait(zio_t *zio);
615615
extern void zio_execute(void *zio);

module/zfs/arc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10525,7 +10525,8 @@ l2arc_log_blk_commit(l2arc_dev_t *dev, zio_t *pio, l2arc_write_callback_t *cb)
1052510525
/* try to compress the buffer, at least one sector to save */
1052610526
psize = zio_compress_data(ZIO_COMPRESS_LZ4,
1052710527
abd_buf->abd, &abd, sizeof (*lb),
10528-
zio_get_compression_max_size(dev->l2ad_vdev->vdev_ashift,
10528+
zio_get_compression_max_size(ZIO_COMPRESS_LZ4,
10529+
dev->l2ad_vdev->vdev_ashift,
1052910530
dev->l2ad_vdev->vdev_ashift, sizeof (*lb)), 0);
1053010531

1053110532
/* a log block is never entirely zero */

module/zfs/zio.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,15 +1706,20 @@ zio_roundup_alloc_size(spa_t *spa, uint64_t size)
17061706
}
17071707

17081708
size_t
1709-
zio_get_compression_max_size(uint64_t gcd_alloc, uint64_t min_alloc,
1710-
size_t s_len)
1709+
zio_get_compression_max_size(enum zio_compress compress, uint64_t gcd_alloc,
1710+
uint64_t min_alloc, size_t s_len)
17111711
{
17121712
size_t d_len;
17131713

17141714
/* minimum 12.5% must be saved (legacy value, may be changed later) */
17151715
d_len = s_len - (s_len >> 3);
17161716

1717+
/* ZLE can't use exactly d_len bytes, it needs more, so ignore it */
1718+
if (compress == ZIO_COMPRESS_ZLE)
1719+
return (d_len);
1720+
17171721
d_len = d_len - d_len % gcd_alloc;
1722+
17181723
if (d_len < min_alloc)
17191724
return (BPE_PAYLOAD_SIZE);
17201725
return (d_len);
@@ -1902,8 +1907,8 @@ zio_write_compress(zio_t *zio)
19021907
else
19031908
psize = zio_compress_data(compress, zio->io_abd, &cabd,
19041909
lsize,
1905-
zio_get_compression_max_size(spa->spa_gcd_alloc,
1906-
spa->spa_min_alloc, lsize),
1910+
zio_get_compression_max_size(compress,
1911+
spa->spa_gcd_alloc, spa->spa_min_alloc, lsize),
19071912
zp->zp_complevel);
19081913
if (psize == 0) {
19091914
compress = ZIO_COMPRESS_OFF;

0 commit comments

Comments
 (0)