/*
* 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 (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/dmu_objset.h>
#include <sys/dmu_traverse.h>
#include <sys/dsl_dataset.h>
#include <sys/dsl_pool.h>
#include <sys/refcount.h>
/*
* A bptree is a queue of root block pointers from destroyed datasets. When a
* dataset is destroyed its root block pointer is put on the end of the pool's
* bptree queue so the dataset's blocks can be freed asynchronously by
* dsl_scan_sync. This allows the delete operation to finish without traversing
* all the dataset's blocks.
*
* Note that while bt_begin and bt_end are only ever incremented in this code,
* they are effectively reset to 0 every time the entire bptree is freed because
* the bptree's object is destroyed and re-created.
*/
struct bptree_args {
{
sizeof (bptree_phys_t), tx);
/*
* Bonus buffer contents are already initialized to 0, but for
* readability we make it explicit.
*/
return (obj);
}
int
{
}
{
return (rv);
}
void
{
/*
* bptree objects are in the pool mos, therefore they can only be
* modified in syncing context. Furthermore, this is only modified
* by the sync thread, so no locking is necessary.
*/
}
/* ARGSUSED */
static int
{
int err;
return (0);
}
return (err);
}
/*
* If "free" is set:
* - It is assumed that "func" will be freeing the block pointers.
* - If "func" returns nonzero, the bookmark will be remembered and
* iteration will be restarted from this point on next invocation.
* - If an i/o error is encountered (e.g. "func" returns EIO or ECKSUM),
* bptree_iterate will remember the bookmark, continue traversing
* any additional entries, and return 0.
*
* If "free" is not set, traversal will stop and return an error if
* an i/o error is encountered.
*
* In either case, if zfs_free_leak_on_eio is set, i/o errors will be
* ignored and traversal will continue (i.e. TRAVERSE_HARD will be passed to
* traverse_dataset_destroyed()).
*/
int
{
int err;
uint64_t i;
if (err != 0)
return (err);
if (free)
err = 0;
if (err != 0)
break;
if (zfs_free_leak_on_eio)
flags |= TRAVERSE_HARD;
zfs_dbgmsg("bptree index %lld: traversing from min_txg=%lld "
"bookmark %lld/%lld/%lld/%lld",
(longlong_t)i,
bptree_visit_cb, &ba);
if (free) {
/*
* The callback has freed the visited block pointers.
* Record our traversal progress on disk, either by
* updating this record's bookmark, or by logically
* removing this record by advancing bt_begin.
*/
if (err != 0) {
/* save bookmark for future resume */
/*
* Skip the rest of this tree and
* continue on to the next entry.
*/
err = 0;
} else {
break;
}
} else if (ioerr) {
/*
* This entry is finished, but there were
* i/o errors on previous entries, so we
* can't adjust bt_begin. Set this entry's
* be_birth_txg such that it will be
* treated as a no-op in future traversals.
*/
}
if (!ioerr) {
}
} else if (err != 0) {
break;
}
}
/* if all blocks are free there should be no used space */
if (zfs_free_leak_on_eio) {
}
}
return (err);
}