Skip to content

Commit

Permalink
ZSTD replication compatibility improvements
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
allanjude committed Jul 29, 2020
1 parent 9adb5fe commit 8f37c1a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions module/zfs/dmu_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,14 @@ send_do_embed(const blkptr_t *bp, uint64_t featureflags)
!(featureflags & DMU_BACKUP_FEATURE_LZ4)))
return (B_FALSE);

/*
* If we have not set the ZSTD feature flag, we can't send ZSTD
* compressed embedded blocks, as the receiver may not support them.
*/
if ((BP_GET_COMPRESS(bp) == ZIO_COMPRESS_ZSTD &&
!(featureflags & DMU_BACKUP_FEATURE_ZSTD)))
return (B_FALSE);

/*
* Embed type must be explicitly enabled.
*/
Expand Down Expand Up @@ -1967,9 +1975,13 @@ setup_featureflags(struct dmu_send_params *dspp, objset_t *os,
*featureflags |= DMU_BACKUP_FEATURE_LZ4;
}

/*
* We specifically do not include DMU_BACKUP_FEATURE_EMBED_DATA here to
* allow sending ZSTD compressed datasets to a receiver that does not
* support ZSTD
*/
if ((*featureflags &
(DMU_BACKUP_FEATURE_EMBED_DATA | DMU_BACKUP_FEATURE_COMPRESSED |
DMU_BACKUP_FEATURE_RAW)) != 0 &&
(DMU_BACKUP_FEATURE_COMPRESSED | DMU_BACKUP_FEATURE_RAW)) != 0 &&
dsl_dataset_feature_is_active(to_ds, SPA_FEATURE_ZSTD_COMPRESS)) {
*featureflags |= DMU_BACKUP_FEATURE_ZSTD;
}
Expand Down

0 comments on commit 8f37c1a

Please sign in to comment.