From 973a9d5a79331fee6ab310102a94112b6bf0529c Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 18 Dec 2008 13:41:21 -0800 Subject: [PATCH] Resolve drr shadow by breaking hunk in to a new function, which is just cleaner anyway --- module/zfs/dmu_send.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/module/zfs/dmu_send.c b/module/zfs/dmu_send.c index 857b9a343f..db4890c7b7 100644 --- a/module/zfs/dmu_send.c +++ b/module/zfs/dmu_send.c @@ -956,6 +956,28 @@ dmu_recv_abort_cleanup(dmu_recv_cookie_t *drc) } } +/* + * Compute checksum of drr_begin record + */ +static void +dmu_recv_stream_cksum(struct restorearg *ra) +{ + dmu_replay_record_t *drr; + + drr = kmem_zalloc(sizeof (dmu_replay_record_t), KM_SLEEP); + + drr->drr_type = DRR_BEGIN; + drr->drr_u.drr_begin = *drc->drc_drrb; + if (ra->byteswap) { + fletcher_4_incremental_byteswap(drr, + sizeof (dmu_replay_record_t), &(ra->cksum)); + } else { + fletcher_4_incremental_native(drr, + sizeof (dmu_replay_record_t), &(ra->cksum)); + } + kmem_free(drr, sizeof (dmu_replay_record_t)); +} + /* * NB: callers *must* call dmu_recv_end() if this succeeds. */ @@ -970,22 +992,7 @@ dmu_recv_stream(dmu_recv_cookie_t *drc, vnode_t *vp, offset_t *voffp) if (drc->drc_drrb->drr_magic == BSWAP_64(DMU_BACKUP_MAGIC)) ra.byteswap = TRUE; - { - /* compute checksum of drr_begin record */ - dmu_replay_record_t *drr; - drr = kmem_zalloc(sizeof (dmu_replay_record_t), KM_SLEEP); - - drr->drr_type = DRR_BEGIN; - drr->drr_u.drr_begin = *drc->drc_drrb; - if (ra.byteswap) { - fletcher_4_incremental_byteswap(drr, - sizeof (dmu_replay_record_t), &ra.cksum); - } else { - fletcher_4_incremental_native(drr, - sizeof (dmu_replay_record_t), &ra.cksum); - } - kmem_free(drr, sizeof (dmu_replay_record_t)); - } + dmu_recv_stream_cksum(&ra); if (ra.byteswap) { struct drr_begin *drrb = drc->drc_drrb;