dsl_pool.c revision 1d452cf5123cb6ac0a013a4dbd4dcceeb0da314d
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER START
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The contents of this file are subject to the terms of the
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Common Development and Distribution License (the "License").
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * You may not use this file except in compliance with the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fa9e4066f08beec538e775443c5be79dd423fcabahrens * See the License for the specific language governing permissions
fa9e4066f08beec538e775443c5be79dd423fcabahrens * and limitations under the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * When distributing Covered Code, include this CDDL HEADER in each
fa9e4066f08beec538e775443c5be79dd423fcabahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If applicable, add the following below this CDDL HEADER, with the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fields enclosed by brackets "[]" replaced with your own identifying
fa9e4066f08beec538e775443c5be79dd423fcabahrens * information: Portions Copyright [yyyy] [name of copyright owner]
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER END
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Use is subject to license terms.
fa9e4066f08beec538e775443c5be79dd423fcabahrens#pragma ident "%Z%%M% %I% %E% SMI"
fa9e4066f08beec538e775443c5be79dd423fcabahrens/* internal reserved dir name */
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrockdsl_pool_open_mos_dir(dsl_pool_t *dp, dsl_dir_t **ddp)
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock return (dsl_dir_open_obj(dp, obj, MOS_DIR_NAME, dp, ddp));
fa9e4066f08beec538e775443c5be79dd423fcabahrens list_create(&dp->dp_synced_objsets, sizeof (dsl_dataset_t),
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrockdsl_pool_open(spa_t *spa, uint64_t txg, dsl_pool_t **dpp)
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock err = dmu_objset_open_impl(spa, NULL, &dp->dp_meta_rootbp, &osi);
fa9e4066f08beec538e775443c5be79dd423fcabahrens err = zap_lookup(dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT,
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* drop our reference from dsl_pool_open() */
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* undo the dmu_objset_open_impl(mos) from dsl_pool_open() */
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* create the pool directory */
fa9e4066f08beec538e775443c5be79dd423fcabahrens err = zap_create_claim(dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT,
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* create and open the root dir */
fa9e4066f08beec538e775443c5be79dd423fcabahrens dsl_dataset_create_root(dp, &dp->dp_root_dir_obj, tx);
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock VERIFY(0 == dsl_dir_open_obj(dp, dp->dp_root_dir_obj,
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* create and open the meta-objset dir */
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens (void) dsl_dir_create_sync(dp->dp_root_dir, MOS_DIR_NAME, tx);
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock VERIFY(0 == dsl_pool_open_mos_dir(dp, &dp->dp_mos_dir));
fa9e4066f08beec538e775443c5be79dd423fcabahrens while (ds = txg_list_remove(&dp->dp_dirty_datasets, txg)) {
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens while (dstg = txg_list_remove(&dp->dp_sync_tasks, txg))
fa9e4066f08beec538e775443c5be79dd423fcabahrens while (dd = txg_list_remove(&dp->dp_dirty_dirs, txg))
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens * We need to loop since dsl_sync_task_group_sync()
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens * could create a new (dirty) objset.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * XXX - isn't this taken care of by the spa's sync to
fa9e4066f08beec538e775443c5be79dd423fcabahrens * convergence loop?
fa9e4066f08beec538e775443c5be79dd423fcabahrens } while (!txg_list_empty(&dp->dp_dirty_datasets, txg));
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (list_head(&mosi->os_dirty_dnodes[txg & TXG_MASK]) != NULL ||
fa9e4066f08beec538e775443c5be79dd423fcabahrens list_head(&mosi->os_free_dnodes[txg & TXG_MASK]) != NULL) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens dprintf_bp(&dp->dp_meta_rootbp, "meta objset rootbp is %s", "");
fa9e4066f08beec538e775443c5be79dd423fcabahrens zil_clean(((objset_impl_t *)ds->ds_user_ptr)->os_zil);
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Yeah, this is cheesy. But the SPA needs some way to let
fa9e4066f08beec538e775443c5be79dd423fcabahrens * the sync threads invoke spa_open() and spa_close() while
fa9e4066f08beec538e775443c5be79dd423fcabahrens * it holds the namespace lock. I'm certainly open to better
fa9e4066f08beec538e775443c5be79dd423fcabahrens * ideas for how to determine whether the current thread is
fa9e4066f08beec538e775443c5be79dd423fcabahrens * operating on behalf of spa_sync(). This works for now.
fa9e4066f08beec538e775443c5be79dd423fcabahrensdsl_pool_adjustedsize(dsl_pool_t *dp, boolean_t netfree)
44cd46cadd9aab751dae6a4023c1cb5bf316d274billm * Reserve about 1.6% (1/64), or at least 32MB, for allocation
fa9e4066f08beec538e775443c5be79dd423fcabahrens * efficiency.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * XXX The intent log is not accounted for, so it must fit
fa9e4066f08beec538e775443c5be79dd423fcabahrens * within this slop.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If we're trying to assess whether it's OK to do a free,
fa9e4066f08beec538e775443c5be79dd423fcabahrens * cut the reservation in half to allow forward progress
fa9e4066f08beec538e775443c5be79dd423fcabahrens * (e.g. make it possible to rm(1) files from a full pool).