dsl_pool.c revision f17457368189aa911f774c38c1f21875a568bdca
/*
* 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) 2012 by Delphix. All rights reserved.
*/
#include <sys/dsl_pool.h>
#include <sys/dsl_dataset.h>
#include <sys/dsl_prop.h>
#include <sys/dsl_synctask.h>
#include <sys/dsl_scan.h>
#include <sys/dmu_objset.h>
#include <sys/zfs_context.h>
#include <sys/zfs_znode.h>
#include <sys/spa_impl.h>
#include <sys/dsl_deadlist.h>
#include <sys/zfeature.h>
#include <sys/zil_impl.h>
int zfs_no_write_throttle = 0;
static pgcnt_t old_physmem = 0;
int
{
int err;
if (err)
return (err);
}
static dsl_pool_t *
{
dsl_pool_t *dp;
1, 4, 0);
return (dp);
}
int
{
int err;
&dp->dp_meta_objset);
if (err != 0)
else
return (err);
}
int
{
int err;
&dp->dp_root_dir_obj);
if (err)
goto out;
if (err)
goto out;
if (err)
goto out;
if (err)
goto out;
if (err == 0) {
&dp->dp_origin_snap);
}
if (err)
goto out;
}
&dp->dp_free_dir);
if (err)
goto out;
if (err)
goto out;
}
&dp->dp_bptree_obj);
if (err != 0)
goto out;
}
&dp->dp_empty_bpobj);
if (err != 0)
goto out;
}
err = 0;
if (err)
goto out;
out:
return (err);
}
void
{
/* drop our references from dsl_pool_open() */
/*
* Since we held the origin_snap from "syncing" context (which
* includes pool-opening context), it actually only got a "ref"
* and not a hold, so just drop that here.
*/
if (dp->dp_origin_snap)
if (dp->dp_mos_dir)
if (dp->dp_free_dir)
if (dp->dp_root_dir)
/* undo the dmu_objset_open_impl(mos) from dsl_pool_open() */
if (dp->dp_meta_objset)
if (dp->dp_blkstats)
}
{
int err;
/* create and open the MOS (meta-objset) */
/* create the pool directory */
/* Initialize scan structures */
/* create and open the root dir */
/* create and open the meta-objset dir */
/* create and open the free dir */
FREE_DIR_NAME, tx);
/* create and open the free_bplist */
}
/* create the root dataset */
/* create the root objset */
#ifdef _KERNEL
#endif
return (dp);
}
/*
* Account for the meta-objset space in its placeholder dsl_dir.
*/
void
{
}
static int
{
return (0);
}
void
{
int err;
/*
* We need to copy dp_space_towrite() before doing
* dsl_sync_task_group_sync(), because
* dsl_dataset_snapshot_reserve_space() will increase
* dp_space_towrite but not actually write anything.
*/
dp->dp_read_overhead = 0;
/*
* We must not sync any non-MOS datasets twice, because
* we may have taken a snapshot of them. However, we
* may sync newly-created datasets on pass 2.
*/
}
/*
* After the data blocks have been written (ensured by the zio_wait()
*/
/*
* Sync the datasets again to push out the changes due to
* userspace updates. This must be done before we process the
* sync tasks, so that any snapshots will have the correct
* user accounting information (and we won't get confused
* about which blocks are part of the snapshot).
*/
}
/*
* Now that the datasets have been completely synced, we can
* clean up our in-memory structures accumulated while syncing:
*
* - move dead blocks from the pending deadlist to the on-disk deadlist
* - clean up zil records
* - release hold from dsl_dataset_dirty()
*/
}
/*
* The MOS's space is accounted for in the pool/$MOS
* (dp_mos_dir). We can't modify the mos while we're syncing
* it, so we remember the deltas and apply them here.
*/
dp->dp_mos_uncompressed_delta != 0) {
dp->dp_mos_used_delta = 0;
dp->dp_mos_compressed_delta = 0;
dp->dp_mos_uncompressed_delta = 0;
}
}
/*
* If we modify a dataset in the same txg that we want to destroy it,
* its dsl_dir's dd_dbuf will be dirty, and thus have a hold on it.
* dsl_dir_destroy_check() will fail if there are unexpected holds.
* Therefore, we want to sync the MOS (thus syncing the dd_dbuf
* and clearing the hold on it) before we process the sync_tasks.
* The MOS data dirtied by the sync_tasks will be synced on the next
* pass.
*/
/*
* No more sync tasks should have been added while we
* were syncing.
*/
}
/*
* If the write limit max has not been explicitly set, set it
* to a fraction of available physical memory (default 1/8th).
* Note that we must inflate the limit because the spa
* inflates write sizes to account for data replication.
* Check this each sync phase to catch changing memory size.
*/
}
/*
* Attempt to keep the sync time consistent by adjusting the
* amount of write traffic allowed into each transaction group.
* Weight the throughput calculation towards the current value:
* thru = 3/4 old_thru + 1/4 new_thru
*
* Note: write_time is in nanosecs, so write_time/MICROSEC
* yields millisecs
*/
ASSERT(zfs_write_limit_min > 0);
if (dp->dp_throughput)
else
}
}
void
{
}
}
/*
* TRUE if the current thread is the tx_sync_thread or if we
* are being called from SPA context during pool initialization.
*/
int
{
}
{
/*
* Reserve about 1.6% (1/64), or at least 32MB, for allocation
* efficiency.
* XXX The intent log is not accounted for, so it must fit
* within this slop.
*
* If we're trying to assess whether it's OK to do a free,
* cut the reservation in half to allow forward progress
* (e.g. make it possible to rm(1) files from a full pool).
*/
if (netfree)
resv >>= 1;
}
int
{
if (zfs_no_write_throttle) {
space);
return (0);
}
/*
* Check to see if we have exceeded the maximum allowed IO for
* this transaction group. We can do this without locks since
* a little slop here is ok. Note that we do the reserved check
* with only half the requested reserve: this is because the
* reserve requests are worst-case, and we really don't want to
* throttle based off of worst-case estimates.
*/
if (write_limit > 0) {
return (ERESTART);
}
/*
* If this transaction group is over 7/8ths capacity, delay
* the caller 1 clock tick. This will slow down the "fill"
* rate until the sync process can catch up with us.
*/
return (0);
}
void
{
}
void
{
uint64_t space_inuse = 0;
int i;
return;
for (i = 0; i < TXG_SIZE; i++) {
}
}
void
{
if (space > 0) {
}
}
/* ARGSUSED */
static int
{
int err;
if (err)
return (err);
if (err) {
return (err);
}
break;
}
/*
* The $ORIGIN can't have any data, or the accounting
* will be wrong.
*/
/* The origin doesn't get attached to itself */
return (0);
}
}
}
}
return (0);
}
void
{
tx, DS_FIND_CHILDREN));
}
/* ARGSUSED */
static int
{
}
}
return (0);
}
void
{
/*
* We can't use bpobj_alloc(), because spa_version() still
* returns the old version, and we need a new-version bpobj with
* subobj support. So call dmu_object_alloc() directly.
*/
}
void
{
/* create the origin dir, ds, & snap-ds */
}
taskq_t *
{
return (dp->dp_vnrele_taskq);
}
/*
* Walk through the pool-wide zap object of temporary snapshot user holds
* and release them.
*/
void
{
if (zapobj == 0)
return;
zap_cursor_advance(&zc)) {
char *htag;
*htag = '\0';
++htag;
}
}
/*
* Create the pool-wide zap object for storing temporary snapshot holds.
*/
void
{
}
static int
{
char *name;
int error;
/*
* If the pool was created prior to SPA_VERSION_USERREFS, the
* zap object for temporary holds might not exist yet.
*/
if (zapobj == 0) {
if (holding) {
} else {
return (ENOENT);
}
}
if (holding)
else
return (error);
}
/*
* Add a temporary hold for the given dataset object and tag.
*/
int
{
}
/*
* Release a temporary hold for the given dataset object and tag.
*/
int
{
}