Prefer embedded blocks to dedup

Since embedded blocks introduction 11 years ago, their writing was
blocked if dedup is enabled.  After searching through the modern
code I see no reason for this restriction to exist.  Same time
embedded blocks are dramatically cheaper.  Even regular write of
so small blocks would likely be cheaper than deduplication, even
if the last is successful, not mentioning otherwise.

Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by:	Alexander Motin <mav@FreeBSD.org>
Sponsored by:	iXsystems, Inc.
Closes #17113
This commit is contained in:
Alexander Motin 2025-03-13 13:27:15 -04:00 committed by GitHub
parent 13ec35ce3b
commit 09f4dd06c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 4 deletions

View File

@ -2005,8 +2005,7 @@ zio_write_compress(zio_t *zio)
compress = ZIO_COMPRESS_OFF;
if (cabd != NULL)
abd_free(cabd);
} else if (!zp->zp_dedup && !zp->zp_encrypt &&
psize <= BPE_PAYLOAD_SIZE &&
} else if (psize <= BPE_PAYLOAD_SIZE && !zp->zp_encrypt &&
zp->zp_level == 0 && !DMU_OT_HAS_FILL(zp->zp_type) &&
spa_feature_is_enabled(spa, SPA_FEATURE_EMBEDDED_DATA)) {
void *cbuf = abd_borrow_buf_copy(cabd, lsize);

View File

@ -75,7 +75,7 @@ log_must zpool prefetch -t ddt $TESTPOOL
# to generate a reasonable size DDT for testing purposes.
DATASET=$TESTPOOL/ddt
log_must zfs create -o dedup=on $DATASET
log_must zfs create -o compression=off -o dedup=on $DATASET
MNTPOINT=$(get_prop mountpoint $TESTPOOL/ddt)
log_note "Generating dataset ..."

View File

@ -79,7 +79,7 @@ function do_setup
log_must truncate -s 5G $VDEV_GENERAL
# Use 'xattr=sa' to prevent selinux xattrs influencing our accounting
log_must zpool create -o ashift=12 -f -O xattr=sa -m $MOUNTDIR $POOL $VDEV_GENERAL
log_must zfs set dedup=on $POOL
log_must zfs set compression=off dedup=on $POOL
log_must set_tunable32 TXG_TIMEOUT 600
}