dmu_send.c revision 6b4acc8bd9d480535a4d057e291dc7c049f664d9
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#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>
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);
int i;
for (i = 0; i < blksz >> DNODE_SHIFT; i++) {
if (err)
break;
}
} else if (level == 0 &&
if (abuf) {
}
} else {
}
}
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 (fromds)
}
if (err) {
return (err);
}
return (0);
}
struct restorearg {
int err;
int byteswap;
char *buf;
int buflen; /* number of valid bytes in buf */
int bufoff; /* next offset to read */
int bufsize; /* amount of memory allocated for buf */
};
/* ARGSUSED */
static int
{
const char *snapname;
int err;
/* must already be a snapshot of this fs */
return (ENODEV);
/* most recent snapshot must match fromguid */
return (ENODEV);
/* must not have any changes since most recent snapshot */
return (ETXTBSY);
/* new snapshot name must not exist */
return (EEXIST);
snapname++;
if (err == 0)
return (EEXIST);
return (err);
return (0);
}
/* ARGSUSED */
static void
{
}
/* ARGSUSED */
static int
{
char *cp;
int err;
*cp = '\0';
*cp = '@';
return (0);
}
static void
{
char *cp;
*cp = '\0';
*cp = '@';
}
static int
{
char *snapname;
/* XXX verify that drr_toname is in dd */
return (EINVAL);
snapname++;
}
static void
{
char *snapname;
/* set snapshot's creation time and guid */
}
static void *
{
void *rv;
/* some things will require 8-byte alignment, so everything must */
return (NULL);
/* Could compute checksum here? */
}
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);
}
/* currently free, want to be allocated */
if (err) {
return (err);
}
} else {
/* currently allocated, want to be allocated */
/*
* We may change blocksize, so need to
* hold_write
*/
if (err) {
return (err);
}
}
if (err) {
return (EINVAL);
}
if (drro->drr_bonuslen) {
void *data;
}
drro->drr_bonuslen);
}
}
return (0);
}
/* ARGSUSED */
static int
struct drr_freeobjects *drrfo)
{
return (EINVAL);
int err;
continue;
if (err) {
return (err);
}
return (EINVAL);
}
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);
if (err) {
return (err);
}
return (err);
}
int
{
struct restorearg ra;
char *cp;
} else {
goto out;
}
/*
* NB: this assumes that struct drr_begin will be the largest in
* dmu_replay_record_t's drr_u, and thus we don't need to pad it
* with zeros to make it the same length as we wrote out.
*/
} else {
}
}
goto out;
}
/*
* Process the begin in syncing context.
*/
if (drrb->drr_fromguid) {
/* incremental backup */
*cp = '\0';
*cp = '@';
goto out;
/*
* Only do the rollback if the most recent snapshot
* matches the incremental source
*/
if (force) {
drrb->drr_fromguid) {
return (ENODEV);
}
(void) dsl_dataset_rollback(ds);
}
} else {
/* full backup */
const char *tail;
/* can't restore full backup into topmost fs, for now */
goto out;
}
*cp = '\0';
*cp = '@';
goto out;
goto out;
}
}
goto out;
/*
* Open the objset we are modifying.
*/
*cp = '\0';
*cp = '@';
/*
* 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;
}
goto out;
}
default:
goto out;
}
}
out:
if (os)
/*
* processed the begin properly. 'os' will only be set if this
* is the case.
*/
/*
* rollback or destroy what we created, so we don't
* leave it in the restoring state.
*/
int err;
*cp = '\0';
if (err == 0) {
if (drrb->drr_fromguid) {
/* incremental: rollback to most recent snap */
(void) dsl_dataset_rollback(ds);
} else {
/* full: destroy whole fs */
(void) dsl_dataset_destroy(tosnap);
}
}
*cp = '@';
}
if (sizep)
}