* earlier in the stream.
*/
txg_wait_synced(dmu_objset_pool(rwa->os), 0);
- object = drro->drr_object;
+
+ if (dmu_object_info(rwa->os, drro->drr_object, NULL) != ENOENT)
+ return (SET_ERROR(EINVAL));
+
+ /* object was freed and we are about to allocate a new one */
+ object = DMU_NEW_OBJECT;
} else {
/* object is free and we are about to allocate a new one */
object = DMU_NEW_OBJECT;