dmu_send.c revision 2bf405a25eb25f79638fc951ff8d8857ad384417
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/dmu_impl.h>
#include <sys/zfs_context.h>
#include <sys/dmu_objset.h>
#include <sys/dmu_traverse.h>
#include <sys/dsl_dataset.h>
#include <sys/dsl_pool.h>
#include <sys/dsl_synctask.h>
#include <sys/zfs_ioctl.h>
#include <sys/zio_checksum.h>
static char *dmu_recv_tag = "dmu_recv_tag";
struct backuparg {
int err;
};
static int
{
}
static int
{
/* write a FREE record */
return (EINTR);
return (0);
}
static int
{
/* write a DATA record */
return (EINTR);
return (EINTR);
return (0);
}
static int
{
/* write a FREEOBJECTS record */
return (EINTR);
return (0);
}
static int
{
/* write an OBJECT record */
return (EINTR);
return (EINTR);
/* free anything past the end of the file */
return (EINTR);
return (EINTR);
return (0);
}
static int
{
int err = 0;
return (EINTR);
return (0);
} else if (type == DMU_OT_DNODE) {
int i;
return (EIO);
for (i = 0; i < blksz >> DNODE_SHIFT; i++) {
(DNODE_BLOCK_SHIFT - DNODE_SHIFT)) + i;
if (err)
break;
}
} else { /* it's a level-0 block of a regular object */
return (EIO);
}
return (err);
}
int
{
int err;
/* tosnap must be a snapshot */
return (EINVAL);
/* fromsnap must be an earlier snapshot from the same fs as tosnap */
return (EXDEV);
if (fromorigin) {
if (fromsnap)
return (EINVAL);
if (err)
return (err);
} else {
}
}
if (fromorigin)
if (fromds)
if (fromds)
if (fromorigin)
}
if (err) {
return (err);
}
}
return (0);
}
struct recvbeginsyncarg {
const char *tofs;
const char *tosnap;
void *tag;
char clonelastname[MAXNAMELEN];
};
static dsl_dataset_t *
{
/* This should always work, since we just created it */
/* XXX - create should return an owned ds */
if (type != DMU_OST_NONE) {
}
return (ds);
}
/* ARGSUSED */
static int
{
int err;
/* make sure it's a snap in the same pool */
return (EXDEV);
return (EINVAL);
return (ENODEV);
}
return (0);
}
static void
{
}
static int
{
int err;
/* must be a head ds */
return (EINVAL);
/* must not be a clone ds */
return (EINVAL);
if (err)
return (err);
/* make sure it's a snap in the same pool */
return (EXDEV);
return (EINVAL);
return (ENODEV);
}
return (0);
}
static void
{
/*
* NB: caller must provide an extra hold on the dsl_dir_t, so it
* won't go away when dsl_dataset_destroy_sync() closes the
* dataset.
*/
}
/* ARGSUSED */
static int
{
int err;
/* must not have any changes since most recent snapshot */
return (ETXTBSY);
/* must already be a snapshot of this fs */
return (ENODEV);
/* most recent snapshot must match fromguid */
return (ENODEV);
/* temporary clone name must not exist */
if (err == 0)
return (EEXIST);
return (err);
/* new snapshot name must not exist */
if (err == 0)
return (EEXIST);
return (err);
return (0);
}
/* ARGSUSED */
static void
{
/* create the temporary clone */
/* open the temporary clone */
/* copy the refquota from the target fs to the clone */
}
/* ARGSUSED */
static void
{
}
/*
* NB: callers *MUST* call dmu_recv_stream() if dmu_recv_begin()
* succeeds; otherwise we will leak the holds on the datasets.
*/
int
{
int err = 0;
struct recvbeginsyncarg rbsa;
int flags;
else
return (EINVAL);
if (byteswap) {
}
if (version != DMU_BACKUP_STREAM_VERSION ||
return (EINVAL);
if (flags & DRR_FLAG_CI_DATA)
/*
* Process the begin in syncing context.
*/
/* offline incremental receive */
if (err)
return (err);
/*
* Only do the rollback if the most recent snapshot
* matches the incremental source
*/
if (force) {
return (ENODEV);
}
}
if (err) {
return (err);
}
/* online incremental receive */
/* tmp clone name is: tofs/%tosnap" */
"%%%s", tosnap);
/* open the dataset we are logically receiving into */
if (err)
return (err);
if (err) {
return (err);
}
} else {
/* create new fs -- full backup or clone */
const char *tail;
if (err)
return (err);
if (!force) {
return (EEXIST);
}
if (err) {
return (err);
}
} else {
}
if (err)
return (err);
}
return (0);
}
struct restorearg {
int err;
int byteswap;
char *buf;
int bufsize; /* amount of memory allocated for buf */
};
static void *
{
void *rv;
int done = 0;
/* some things will require 8-byte alignment, so everything must */
return (NULL);
}
else
return (rv);
}
static void
{
case DRR_BEGIN:
break;
case DRR_OBJECT:
/* DO64(drr_object.drr_allocation_txg); */
break;
case DRR_FREEOBJECTS:
break;
case DRR_WRITE:
break;
case DRR_FREE:
break;
case DRR_END:
break;
}
}
static int
{
int err;
return (EINVAL);
}
return (EINVAL);
if (drro->drr_bonuslen) {
}
/* currently free, want to be allocated */
if (err) {
return (err);
}
} else {
/* currently allocated, want to be allocated */
}
if (err)
return (EINVAL);
if (err) {
return (err);
}
drro->drr_bonuslen);
}
}
return (0);
}
/* ARGSUSED */
static int
struct drr_freeobjects *drrfo)
{
return (EINVAL);
int err;
continue;
if (err)
return (err);
}
return (0);
}
static int
{
void *data;
int err;
return (EINVAL);
return (EINVAL);
if (err) {
return (err);
}
return (0);
}
/* ARGSUSED */
static int
{
int err;
return (EINVAL);
return (EINVAL);
return (err);
}
void
{
/*
* online incremental or new fs: destroy the fs (which
* may be a clone) that we created
*/
} else {
/*
* offline incremental: rollback to most recent snapshot.
*/
}
}
/*
* NB: callers *must* call dmu_recv_end() if this succeeds.
*/
int
{
struct restorearg ra = { 0 };
{
/* compute checksum of drr_begin record */
} else {
}
}
}
/* these were verified in dmu_recv_begin */
/*
* Open the objset we are modifying.
*/
/*
* Read records and process them.
*/
goto out;
}
case DRR_OBJECT:
{
/*
* We need to make a copy of the record header,
* because restore_{object,write} may need to
* restore_read(), which will invalidate drr.
*/
break;
}
case DRR_FREEOBJECTS:
{
struct drr_freeobjects drrfo =
break;
}
case DRR_WRITE:
{
break;
}
case DRR_FREE:
{
break;
}
case DRR_END:
{
/*
* We compare against the *previous* checksum
* value, because the stored checksum is of
* everything before the DRR_END record.
*/
goto out;
}
default:
goto out;
}
}
out:
/*
* rollback or destroy what we created, so we don't
* leave it in the restoring state.
*/
}
}
struct recvendsyncarg {
char *tosnap;
};
static int
{
}
static void
{
/* set snapshot's creation time and guid */
}
int
{
struct recvendsyncarg resa;
int err;
/*
* XXX hack; seems the ds is still dirty and
* dsl_pool_zil_clean() expects it to have a ds_user_ptr
* (and zil), but clone_swap() can close it.
*/
/* we are doing an online recv */
if (err)
} else {
}
/* dsl_dataset_destroy() will disown the ds */
if (err)
return (err);
}
if (err) {
return (err);
} else {
}
}
/* release the hold from dmu_recv_begin */
return (err);
}