Deleted Added
full compact
dsl_pool.c (208047) dsl_pool.c (209962)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 5 unchanged lines hidden (view full) ---

14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 5 unchanged lines hidden (view full) ---

14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26#include <sys/dsl_pool.h>
27#include <sys/dsl_dataset.h>
28#include <sys/dsl_dir.h>
29#include <sys/dsl_synctask.h>
30#include <sys/dmu_tx.h>

--- 97 unchanged lines hidden (view full) ---

128 goto out;
129
130 if (spa_version(spa) >= SPA_VERSION_ORIGIN) {
131 err = dsl_pool_open_special_dir(dp, ORIGIN_DIR_NAME, &dd);
132 if (err)
133 goto out;
134 err = dsl_dataset_hold_obj(dp, dd->dd_phys->dd_head_dataset_obj,
135 FTAG, &ds);
23 * Use is subject to license terms.
24 */
25
26#include <sys/dsl_pool.h>
27#include <sys/dsl_dataset.h>
28#include <sys/dsl_dir.h>
29#include <sys/dsl_synctask.h>
30#include <sys/dmu_tx.h>

--- 97 unchanged lines hidden (view full) ---

128 goto out;
129
130 if (spa_version(spa) >= SPA_VERSION_ORIGIN) {
131 err = dsl_pool_open_special_dir(dp, ORIGIN_DIR_NAME, &dd);
132 if (err)
133 goto out;
134 err = dsl_dataset_hold_obj(dp, dd->dd_phys->dd_head_dataset_obj,
135 FTAG, &ds);
136 if (err == 0) {
137 err = dsl_dataset_hold_obj(dp,
138 ds->ds_phys->ds_prev_snap_obj, dp,
139 &dp->dp_origin_snap);
140 dsl_dataset_rele(ds, FTAG);
141 }
142 dsl_dir_close(dd, dp);
136 if (err)
137 goto out;
143 if (err)
144 goto out;
138 err = dsl_dataset_hold_obj(dp, ds->ds_phys->ds_prev_snap_obj,
139 dp, &dp->dp_origin_snap);
140 if (err)
141 goto out;
142 dsl_dataset_rele(ds, FTAG);
143 dsl_dir_close(dd, dp);
144 }
145
146 /* get scrub status */
147 err = zap_lookup(dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT,
148 DMU_POOL_SCRUB_FUNC, sizeof (uint32_t), 1,
149 &dp->dp_scrub_func);
150 if (err == 0) {
151 err = zap_lookup(dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT,

--- 146 unchanged lines hidden (view full) ---

298 hrtime_t start, write_time;
299 uint64_t data_written;
300 int err;
301
302 tx = dmu_tx_create_assigned(dp, txg);
303
304 dp->dp_read_overhead = 0;
305 start = gethrtime();
145 }
146
147 /* get scrub status */
148 err = zap_lookup(dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT,
149 DMU_POOL_SCRUB_FUNC, sizeof (uint32_t), 1,
150 &dp->dp_scrub_func);
151 if (err == 0) {
152 err = zap_lookup(dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT,

--- 146 unchanged lines hidden (view full) ---

299 hrtime_t start, write_time;
300 uint64_t data_written;
301 int err;
302
303 tx = dmu_tx_create_assigned(dp, txg);
304
305 dp->dp_read_overhead = 0;
306 start = gethrtime();
307
306 zio = zio_root(dp->dp_spa, NULL, NULL, ZIO_FLAG_MUSTSUCCEED);
307 while (ds = txg_list_remove(&dp->dp_dirty_datasets, txg)) {
308 zio = zio_root(dp->dp_spa, NULL, NULL, ZIO_FLAG_MUSTSUCCEED);
309 while (ds = txg_list_remove(&dp->dp_dirty_datasets, txg)) {
308 if (!list_link_active(&ds->ds_synced_link))
309 list_insert_tail(&dp->dp_synced_datasets, ds);
310 else
311 dmu_buf_rele(ds->ds_dbuf, ds);
310 /*
311 * We must not sync any non-MOS datasets twice, because
312 * we may have taken a snapshot of them. However, we
313 * may sync newly-created datasets on pass 2.
314 */
315 ASSERT(!list_link_active(&ds->ds_synced_link));
316 list_insert_tail(&dp->dp_synced_datasets, ds);
312 dsl_dataset_sync(ds, zio, tx);
313 }
314 DTRACE_PROBE(pool_sync__1setup);
317 dsl_dataset_sync(ds, zio, tx);
318 }
319 DTRACE_PROBE(pool_sync__1setup);
315
316 err = zio_wait(zio);
320 err = zio_wait(zio);
321
317 write_time = gethrtime() - start;
318 ASSERT(err == 0);
319 DTRACE_PROBE(pool_sync__2rootzio);
320
322 write_time = gethrtime() - start;
323 ASSERT(err == 0);
324 DTRACE_PROBE(pool_sync__2rootzio);
325
321 while (dstg = txg_list_remove(&dp->dp_sync_tasks, txg))
326 for (ds = list_head(&dp->dp_synced_datasets); ds;
327 ds = list_next(&dp->dp_synced_datasets, ds))
328 dmu_objset_do_userquota_callbacks(ds->ds_user_ptr, tx);
329
330 /*
331 * Sync the datasets again to push out the changes due to
332 * userquota updates. This must be done before we process the
333 * sync tasks, because that could cause a snapshot of a dataset
334 * whose ds_bp will be rewritten when we do this 2nd sync.
335 */
336 zio = zio_root(dp->dp_spa, NULL, NULL, ZIO_FLAG_MUSTSUCCEED);
337 while (ds = txg_list_remove(&dp->dp_dirty_datasets, txg)) {
338 ASSERT(list_link_active(&ds->ds_synced_link));
339 dmu_buf_rele(ds->ds_dbuf, ds);
340 dsl_dataset_sync(ds, zio, tx);
341 }
342 err = zio_wait(zio);
343
344 while (dstg = txg_list_remove(&dp->dp_sync_tasks, txg)) {
345 /*
346 * No more sync tasks should have been added while we
347 * were syncing.
348 */
349 ASSERT(spa_sync_pass(dp->dp_spa) == 1);
322 dsl_sync_task_group_sync(dstg, tx);
350 dsl_sync_task_group_sync(dstg, tx);
351 }
323 DTRACE_PROBE(pool_sync__3task);
324
325 start = gethrtime();
326 while (dd = txg_list_remove(&dp->dp_dirty_dirs, txg))
327 dsl_dir_sync(dd, tx);
328 write_time += gethrtime() - start;
329
330 if (spa_sync_pass(dp->dp_spa) == 1)

--- 238 unchanged lines hidden (view full) ---

569 ds->ds_phys->ds_prev_snap_obj, ds, &ds->ds_prev));
570 }
571 }
572
573 ASSERT(ds->ds_dir->dd_phys->dd_origin_obj == prev->ds_object);
574 ASSERT(ds->ds_phys->ds_prev_snap_obj == prev->ds_object);
575
576 if (prev->ds_phys->ds_next_clones_obj == 0) {
352 DTRACE_PROBE(pool_sync__3task);
353
354 start = gethrtime();
355 while (dd = txg_list_remove(&dp->dp_dirty_dirs, txg))
356 dsl_dir_sync(dd, tx);
357 write_time += gethrtime() - start;
358
359 if (spa_sync_pass(dp->dp_spa) == 1)

--- 238 unchanged lines hidden (view full) ---

598 ds->ds_phys->ds_prev_snap_obj, ds, &ds->ds_prev));
599 }
600 }
601
602 ASSERT(ds->ds_dir->dd_phys->dd_origin_obj == prev->ds_object);
603 ASSERT(ds->ds_phys->ds_prev_snap_obj == prev->ds_object);
604
605 if (prev->ds_phys->ds_next_clones_obj == 0) {
606 dmu_buf_will_dirty(prev->ds_dbuf, tx);
577 prev->ds_phys->ds_next_clones_obj =
578 zap_create(dp->dp_meta_objset,
579 DMU_OT_NEXT_CLONES, DMU_OT_NONE, 0, tx);
580 }
581 VERIFY(0 == zap_add_int(dp->dp_meta_objset,
582 prev->ds_phys->ds_next_clones_obj, ds->ds_object, tx));
583
584 dsl_dataset_rele(ds, FTAG);
585 if (prev != dp->dp_origin_snap)
586 dsl_dataset_rele(prev, FTAG);
587 return (0);
588}
589
590void
591dsl_pool_upgrade_clones(dsl_pool_t *dp, dmu_tx_t *tx)
592{
593 ASSERT(dmu_tx_is_syncing(tx));
594 ASSERT(dp->dp_origin_snap != NULL);
595
607 prev->ds_phys->ds_next_clones_obj =
608 zap_create(dp->dp_meta_objset,
609 DMU_OT_NEXT_CLONES, DMU_OT_NONE, 0, tx);
610 }
611 VERIFY(0 == zap_add_int(dp->dp_meta_objset,
612 prev->ds_phys->ds_next_clones_obj, ds->ds_object, tx));
613
614 dsl_dataset_rele(ds, FTAG);
615 if (prev != dp->dp_origin_snap)
616 dsl_dataset_rele(prev, FTAG);
617 return (0);
618}
619
620void
621dsl_pool_upgrade_clones(dsl_pool_t *dp, dmu_tx_t *tx)
622{
623 ASSERT(dmu_tx_is_syncing(tx));
624 ASSERT(dp->dp_origin_snap != NULL);
625
596 (void) dmu_objset_find_spa(dp->dp_spa, NULL, upgrade_clones_cb,
597 tx, DS_FIND_CHILDREN);
626 VERIFY3U(0, ==, dmu_objset_find_spa(dp->dp_spa, NULL, upgrade_clones_cb,
627 tx, DS_FIND_CHILDREN));
598}
599
600void
601dsl_pool_create_origin(dsl_pool_t *dp, dmu_tx_t *tx)
602{
603 uint64_t dsobj;
604 dsl_dataset_t *ds;
605

--- 20 unchanged lines hidden ---
628}
629
630void
631dsl_pool_create_origin(dsl_pool_t *dp, dmu_tx_t *tx)
632{
633 uint64_t dsobj;
634 dsl_dataset_t *ds;
635

--- 20 unchanged lines hidden ---