From 4b040d9513e4d31372856aca8ce478e8eb9ccfea Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Mon, 25 May 2015 11:56:57 +0000 Subject: [PATCH] zfs: fixes for a full stream received into an existing dataset - this should fail early unless the force flag is set - if the force flag is set then any local modifications including snapshots should be undone See: https://www.illumos.org/issues/5912 See: https://reviews.csiden.org/r/220/ Reviewed by: mahrens, Paul Dagnelie MFC after: 15 days Sponsored by: ClusterHQ --- .../contrib/opensolaris/uts/common/fs/zfs/dmu_send.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c index a0c13777deeb..adee4f858a1b 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c @@ -983,10 +983,12 @@ recv_begin_check_existing_impl(dmu_recv_begin_arg_t *drba, dsl_dataset_t *ds, dsl_dataset_rele(snap, FTAG); } else { - /* if full, most recent snapshot must be $ORIGIN */ - if (dsl_dataset_phys(ds)->ds_prev_snap_txg >= TXG_INITIAL) - return (SET_ERROR(ENODEV)); - drba->drba_snapobj = dsl_dataset_phys(ds)->ds_prev_snap_obj; + /* if full, then must be forced */ + if (!drba->drba_cookie->drc_force) + return (SET_ERROR(EEXIST)); + /* start from $ORIGIN@$ORIGIN, if supported */ + drba->drba_snapobj = dp->dp_origin_snap != NULL ? + dp->dp_origin_snap->ds_object : 0; } return (0);