Allow zero compression if dedup is enabled

Having high-refcount dedup entries for zero blocks is inefficient
when they could be recorded as a holes instead.  Normally, zero
compression is not done if compression is disabled to not confuse
naive benchmarks.  But with dedup enabled, it is expected that the
write will be skipped anyway, so we are just optimizing the way it
is skipped.

Reviewed-by: Rob Norris <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Signed-off-by:	Alexander Motin <[email protected]>
Sponsored by:	iXsystems, Inc.
Closes #17435
This commit is contained in:
Alexander Motin authored and GitHub committed 2025-06-10 09:28:14 -07:00
1 parent 0e9e2e2501
commit bcd0430236
1 file changed
+9
+9
View File
@@ -2422,6 +2422,15 @@ dmu_write_policy(objset_t *os, dnode_t *dn, int level, int wp, zio_prop_t *zp)
complevel = zio_complevel_select(os->os_spa, compress,
complevel, complevel);
/*
* Storing many references to an all zeros block in the dedup
* table would be expensive. Instead, if dedup is enabled,
* store them as holes even if compression is not enabled.
*/
if (compress == ZIO_COMPRESS_OFF &&
dedup_checksum != ZIO_CHECKSUM_OFF)
compress = ZIO_COMPRESS_EMPTY;
checksum = (dedup_checksum == ZIO_CHECKSUM_OFF) ?
zio_checksum_select(dn->dn_checksum, checksum) :
dedup_checksum;