Skip to content

Commit 51907a3

Browse files
kernelOfTruthbehlendorf
authored andcommitted
OpenZFS 7230 - add assertions to dmu_send_impl() to verify that stream includes BEGIN and END records
Authored by: Matt Krantz <matt.krantz@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Paul Dagnelie <pcd@delphix.com> Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Approved by: Robert Mustacchi <rm@joyent.com> Ported-by: kernelOfTruth <kerneloftruth@gmail.com> OpenZFS-issue: https://www.illumos.org/issues/7230 OpenZFS-commit: illumos/illumos-gate@12b90ee2 Closes #5112
1 parent 5df39c1 commit 51907a3

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

include/sys/dmu_impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ typedef struct dmu_sendarg {
273273
uint64_t dsa_last_data_offset;
274274
uint64_t dsa_resume_object;
275275
uint64_t dsa_resume_offset;
276+
boolean_t dsa_sent_begin;
277+
boolean_t dsa_sent_end;
276278
} dmu_sendarg_t;
277279

278280
void dmu_object_zapify(objset_t *, uint64_t, dmu_object_type_t, dmu_tx_t *);

module/zfs/dmu_send.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,16 @@ dump_record(dmu_sendarg_t *dsp, void *payload, int payload_len)
169169
fletcher_4_incremental_native(dsp->dsa_drr,
170170
offsetof(dmu_replay_record_t, drr_u.drr_checksum.drr_checksum),
171171
&dsp->dsa_zc);
172-
if (dsp->dsa_drr->drr_type != DRR_BEGIN) {
172+
if (dsp->dsa_drr->drr_type == DRR_BEGIN) {
173+
dsp->dsa_sent_begin = B_TRUE;
174+
} else {
173175
ASSERT(ZIO_CHECKSUM_IS_ZERO(&dsp->dsa_drr->drr_u.
174176
drr_checksum.drr_checksum));
175177
dsp->dsa_drr->drr_u.drr_checksum.drr_checksum = dsp->dsa_zc;
176178
}
179+
if (dsp->dsa_drr->drr_type == DRR_END) {
180+
dsp->dsa_sent_end = B_TRUE;
181+
}
177182
fletcher_4_incremental_native(&dsp->dsa_drr->
178183
drr_u.drr_checksum.drr_checksum,
179184
sizeof (zio_cksum_t), &dsp->dsa_zc);
@@ -979,6 +984,8 @@ dmu_send_impl(void *tag, dsl_pool_t *dp, dsl_dataset_t *to_ds,
979984
list_remove(&to_ds->ds_sendstreams, dsp);
980985
mutex_exit(&to_ds->ds_sendstream_lock);
981986

987+
VERIFY(err != 0 || (dsp->dsa_sent_begin && dsp->dsa_sent_end));
988+
982989
kmem_free(drr, sizeof (dmu_replay_record_t));
983990
kmem_free(dsp, sizeof (dmu_sendarg_t));
984991

0 commit comments

Comments
 (0)