Skip to content

Instantly share code, notes, and snippets.

@pcd1193182
Last active December 1, 2016 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pcd1193182/fcb9f8d43dcbcf32ba736ea7ef600658 to your computer and use it in GitHub Desktop.
Save pcd1193182/fcb9f8d43dcbcf32ba736ea7ef600658 to your computer and use it in GitHub Desktop.
diff --git a/usr/src/uts/common/fs/zfs/dmu_send.c b/usr/src/uts/common/fs/zfs/dmu_send.c
index 01a4514..db60198 100644
--- a/usr/src/uts/common/fs/zfs/dmu_send.c
+++ b/usr/src/uts/common/fs/zfs/dmu_send.c
@@ -190,6 +190,15 @@ dump_free(dmu_sendarg_t *dsp, uint64_t object, uint64_t offset,
(object == dsp->dsa_last_data_object &&
offset > dsp->dsa_last_data_offset));
+ /*
+ * If we are doing a non-incremental send, then there can't
+ * be any data in the dataset we're receiving into. Unless we're receiving
+ * a full send as a clone, a free record would simply be a no-op.
+ * If we disable the tunable for this, save space by not sending it to
+ * begin with.
+ */
+ if (!zfs_send_set_freerecords_bit && !dsp->dsa_incremental)
+ return (0);
+
if (length != -1ULL && offset + length < offset)
length = -1ULL;
@@ -388,6 +397,10 @@ dump_freeobjects(dmu_sendarg_t *dsp, uint64_t firstobj, uint64_t numobjs)
{
struct drr_freeobjects *drrfo = &(dsp->dsa_drr->drr_u.drr_freeobjects);
+ /* See comment in dump_free(). */
+ if (!zfs_send_set_freerecords_bit && !dsp->dsa_incremental)
+ return (0);
+
/*
* If there is a pending op, but it's not PENDING_FREEOBJECTS,
* push it out, since free block aggregation can only be done for
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment