From fc6700425a8471e1e1feeeadba96742776470ef8 Mon Sep 17 00:00:00 2001 From: Matthew Ahrens Date: Wed, 18 Mar 2020 13:31:10 -0700 Subject: [PATCH] Deprecate deduplicated send streams Dedup send can only deduplicate over the set of blocks in the send command being invoked, and it does not take advantage of the dedup table to do so. This is a very common misconception among not only users, but developers, and makes the feature seem more useful than it is. As a result, many users are using the feature but not getting any benefit from it. Dedup send requires a nontrivial expenditure of memory and CPU to operate, especially if the dataset(s) being sent is (are) not already using a dedup-strength checksum. Dedup send adds developer burden. It expands the test matrix when developing new features, causing bugs in released code, and delaying development efforts by forcing more testing to be done. As a result, we are deprecating the use of `zfs send -D` and receiving of such streams. This change adds a warning to the man page, and also prints the warning whenever dedup send or receive are used. In a future release, we plan to: 1. remove the kernel code for generating deduplicated streams 2. make `zfs send -D` generate regular, non-deduplicated streams 3. remove the kernel code for receiving deduplicated streams 4. make `zfs receive` of deduplicated streams process them in userland to "re-duplicate" them, so that they can still be received. Reviewed-by: Paul Dagnelie Reviewed-by: Brian Behlendorf Reviewed-by: George Melikov Signed-off-by: Matthew Ahrens Closes #7887 Closes #10117 --- cmd/zfs/zfs_main.c | 10 ++++++++++ include/libzfs_impl.h | 1 + lib/libzfs/libzfs_sendrecv.c | 20 ++++++++++++++++++++ man/man8/zfs.8 | 15 +++++++++++++++ 4 files changed, 46 insertions(+) diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index fa1c6aa302..b8fbf1c893 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -4144,6 +4144,16 @@ zfs_do_send(int argc, char **argv) } } + if (flags.dedup) { + (void) fprintf(stderr, + gettext("WARNING: deduplicated send is " + "deprecated, and will be removed in a\n" + "future release. (In the future, the flag will be " + "accepted, but a\n" + "regular, non-deduplicated stream will be " + "generated.)\n\n")); + } + argc -= optind; argv += optind; diff --git a/include/libzfs_impl.h b/include/libzfs_impl.h index 9a46b9f129..d5614987c7 100644 --- a/include/libzfs_impl.h +++ b/include/libzfs_impl.h @@ -71,6 +71,7 @@ struct libzfs_handle { int libzfs_pool_iter; char libzfs_chassis_id[256]; boolean_t libzfs_prop_debug; + boolean_t libzfs_dedup_warning_printed; }; #define ZFSSHARE_MISS 0x01 /* Didn't find entry in cache */ diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index 1875f79e7c..10241f530f 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -3984,6 +3984,26 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, (void) printf("found clone origin %s\n", origin); } + if (!hdl->libzfs_dedup_warning_printed && + (DMU_GET_FEATUREFLAGS(drrb->drr_versioninfo) & + DMU_BACKUP_FEATURE_DEDUP)) { + (void) fprintf(stderr, + gettext("WARNING: This is a deduplicated send stream. " + "The ability to send and\n" + "receive deduplicated send streams is deprecated. " + "In the future, the\n" + "ability to receive a deduplicated send stream with " + "\"zfs receive\" will be\n" + "removed. However, in the future, a utility will be " + "provided to convert a\n" + "deduplicated send stream to a regular " + "(non-deduplicated) stream. This\n" + "future utility will require that the send stream be " + "located in a\n" + "seek-able file, rather than provided by a pipe.\n\n")); + hdl->libzfs_dedup_warning_printed = B_TRUE; + } + boolean_t resuming = DMU_GET_FEATUREFLAGS(drrb->drr_versioninfo) & DMU_BACKUP_FEATURE_RESUMING; boolean_t raw = DMU_GET_FEATUREFLAGS(drrb->drr_versioninfo) & diff --git a/man/man8/zfs.8 b/man/man8/zfs.8 index 496363642b..029730bd4d 100644 --- a/man/man8/zfs.8 +++ b/man/man8/zfs.8 @@ -3461,6 +3461,9 @@ By default, a full stream is generated. .Bl -tag -width "-D" .It Fl D, -dedup Generate a deduplicated stream. +\fBDeduplicated send is deprecated and will be removed in a future release.\fR +(In the future, the flag will be accepted but a regular, non-deduplicated +stream will be generated.) Blocks which would have been sent multiple times in the send stream will only be sent once. The receiving system must also support this feature to receive a deduplicated @@ -3835,6 +3838,18 @@ destroyed by using the .Nm zfs Cm destroy Fl d command. .Pp +Deduplicated send streams can be generated by using the +.Nm zfs Cm send Fl D +command. +\fBThe ability to send and receive deduplicated send streams is deprecated.\fR +In the future, the ability to receive a deduplicated send stream with +.Nm zfs Cm receive +will be removed. +However, in the future, a utility will be provided to convert a +deduplicated send stream to a regular (non-deduplicated) stream. +This future utility will require that the send stream be located in a +seek-able file, rather than provided by a pipe. +.Pp If .Fl o Em property Ns = Ns Ar value or