Skip to content

Commit c45dd5a

Browse files
Matt Krantzahrens
authored andcommitted
7230 add assertions to dmu_send_impl() to verify that stream includes BEGIN and END records
Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Paul Dagnelie <pcd@delphix.com> Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com> This adds an assertion to dmu_send_impl() to ensure that we either have a nonzero exit code or we have sent both a BEGIN and an END record as part of the stream. Closes #148
1 parent 7f57006 commit c45dd5a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

usr/src/uts/common/fs/zfs/dmu_send.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,16 @@ dump_record(dmu_sendarg_t *dsp, void *payload, int payload_len)
135135
fletcher_4_incremental_native(dsp->dsa_drr,
136136
offsetof(dmu_replay_record_t, drr_u.drr_checksum.drr_checksum),
137137
&dsp->dsa_zc);
138-
if (dsp->dsa_drr->drr_type != DRR_BEGIN) {
138+
if (dsp->dsa_drr->drr_type == DRR_BEGIN) {
139+
dsp->dsa_sent_begin = B_TRUE;
140+
} else {
139141
ASSERT(ZIO_CHECKSUM_IS_ZERO(&dsp->dsa_drr->drr_u.
140142
drr_checksum.drr_checksum));
141143
dsp->dsa_drr->drr_u.drr_checksum.drr_checksum = dsp->dsa_zc;
142144
}
145+
if (dsp->dsa_drr->drr_type == DRR_END) {
146+
dsp->dsa_sent_end = B_TRUE;
147+
}
143148
fletcher_4_incremental_native(&dsp->dsa_drr->
144149
drr_u.drr_checksum.drr_checksum,
145150
sizeof (zio_cksum_t), &dsp->dsa_zc);
@@ -881,6 +886,8 @@ dmu_send_impl(void *tag, dsl_pool_t *dp, dsl_dataset_t *to_ds,
881886
list_remove(&to_ds->ds_sendstreams, dsp);
882887
mutex_exit(&to_ds->ds_sendstream_lock);
883888

889+
VERIFY(err != 0 || (dsp->dsa_sent_begin && dsp->dsa_sent_end));
890+
884891
kmem_free(drr, sizeof (dmu_replay_record_t));
885892
kmem_free(dsp, sizeof (dmu_sendarg_t));
886893

usr/src/uts/common/fs/zfs/sys/dmu_impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ typedef struct dmu_sendarg {
298298
uint64_t dsa_last_data_offset;
299299
uint64_t dsa_resume_object;
300300
uint64_t dsa_resume_offset;
301+
boolean_t dsa_sent_begin;
302+
boolean_t dsa_sent_end;
301303
} dmu_sendarg_t;
302304

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

0 commit comments

Comments
 (0)