Skip to content

Commit 8f37c1a

Browse files
committed
ZSTD replication compatibility improvements
If the dataset being sent has the ZSTD feature activated, and the replication compression flag is specified, we set the ZSTD replication feature flag, so the receiving side will reject the stream if it does not support ZSTD. Only send ZSTD compressed embedded block pointers if the ZSTD replication flag is already set. `zfs send -c` will send ZSTD compressed blocks `zfs send -e` will send embedded LZ4 block pointers but convert ZSTD eBP's into regular blocks `zfs send -ec` will send ZSTD compressed blocks and eBPs Signed-off-by: Allan Jude <allan@klarasystems.com>
1 parent 9adb5fe commit 8f37c1a

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

module/zfs/dmu_send.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,14 @@ send_do_embed(const blkptr_t *bp, uint64_t featureflags)
864864
!(featureflags & DMU_BACKUP_FEATURE_LZ4)))
865865
return (B_FALSE);
866866

867+
/*
868+
* If we have not set the ZSTD feature flag, we can't send ZSTD
869+
* compressed embedded blocks, as the receiver may not support them.
870+
*/
871+
if ((BP_GET_COMPRESS(bp) == ZIO_COMPRESS_ZSTD &&
872+
!(featureflags & DMU_BACKUP_FEATURE_ZSTD)))
873+
return (B_FALSE);
874+
867875
/*
868876
* Embed type must be explicitly enabled.
869877
*/
@@ -1967,9 +1975,13 @@ setup_featureflags(struct dmu_send_params *dspp, objset_t *os,
19671975
*featureflags |= DMU_BACKUP_FEATURE_LZ4;
19681976
}
19691977

1978+
/*
1979+
* We specifically do not include DMU_BACKUP_FEATURE_EMBED_DATA here to
1980+
* allow sending ZSTD compressed datasets to a receiver that does not
1981+
* support ZSTD
1982+
*/
19701983
if ((*featureflags &
1971-
(DMU_BACKUP_FEATURE_EMBED_DATA | DMU_BACKUP_FEATURE_COMPRESSED |
1972-
DMU_BACKUP_FEATURE_RAW)) != 0 &&
1984+
(DMU_BACKUP_FEATURE_COMPRESSED | DMU_BACKUP_FEATURE_RAW)) != 0 &&
19731985
dsl_dataset_feature_is_active(to_ds, SPA_FEATURE_ZSTD_COMPRESS)) {
19741986
*featureflags |= DMU_BACKUP_FEATURE_ZSTD;
19751987
}

0 commit comments

Comments
 (0)