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
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2012 by Delphix. All rights reserved.
24 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
25 */
26
27 /*
28 * The objective of this program is to provide a DMU/ZAP/SPA stress test
29 * that runs entirely in userland, is easy to use, and easy to extend.
30 *
31 * The overall design of the ztest program is as follows:
32 *
33 * (1) For each major functional area (e.g. adding vdevs to a pool,
34 * creating and destroying datasets, reading and writing objects, etc)
35 * we have a simple routine to test that functionality. These
36 * individual routines do not have to do anything "stressful".
37 *
38 * (2) We turn these simple functionality tests into a stress test by
39 * running them all in parallel, with as many threads as desired,
40 * and spread across as many datasets, objects, and vdevs as desired.
41 *
42 * (3) While all this is happening, we inject faults into the pool to
43 * verify that self-healing data really works.
44 *
4694 error = dsl_dataset_user_hold(holds, 0, NULL);
4695 fnvlist_free(holds);
4696
4697 if (error)
4698 fatal(0, "dsl_dataset_user_hold(%s)", fullname, tag);
4699
4700 error = dsl_destroy_snapshot(fullname, B_FALSE);
4701 if (error != EBUSY) {
4702 fatal(0, "dsl_destroy_snapshot(%s, B_FALSE) = %d",
4703 fullname, error);
4704 }
4705
4706 error = dsl_destroy_snapshot(fullname, B_TRUE);
4707 if (error) {
4708 fatal(0, "dsl_destroy_snapshot(%s, B_TRUE) = %d",
4709 fullname, error);
4710 }
4711
4712 error = user_release_one(fullname, tag);
4713 if (error)
4714 fatal(0, "user_release_one(%s)", fullname, tag);
4715
4716 VERIFY3U(dmu_objset_hold(fullname, FTAG, &origin), ==, ENOENT);
4717
4718 out:
4719 (void) rw_unlock(&ztest_name_lock);
4720 }
4721
4722 /*
4723 * Inject random faults into the on-disk data.
4724 */
4725 /* ARGSUSED */
4726 void
4727 ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
4728 {
4729 ztest_shared_t *zs = ztest_shared;
4730 spa_t *spa = ztest_spa;
4731 int fd;
4732 uint64_t offset;
4733 uint64_t leaves;
4734 uint64_t bad = 0x1990c0ffeedecade;
|
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
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2012 by Delphix. All rights reserved.
24 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
25 * Copyright (c) 2013 Steven Hartland. All rights reserved.
26 */
27
28 /*
29 * The objective of this program is to provide a DMU/ZAP/SPA stress test
30 * that runs entirely in userland, is easy to use, and easy to extend.
31 *
32 * The overall design of the ztest program is as follows:
33 *
34 * (1) For each major functional area (e.g. adding vdevs to a pool,
35 * creating and destroying datasets, reading and writing objects, etc)
36 * we have a simple routine to test that functionality. These
37 * individual routines do not have to do anything "stressful".
38 *
39 * (2) We turn these simple functionality tests into a stress test by
40 * running them all in parallel, with as many threads as desired,
41 * and spread across as many datasets, objects, and vdevs as desired.
42 *
43 * (3) While all this is happening, we inject faults into the pool to
44 * verify that self-healing data really works.
45 *
4695 error = dsl_dataset_user_hold(holds, 0, NULL);
4696 fnvlist_free(holds);
4697
4698 if (error)
4699 fatal(0, "dsl_dataset_user_hold(%s)", fullname, tag);
4700
4701 error = dsl_destroy_snapshot(fullname, B_FALSE);
4702 if (error != EBUSY) {
4703 fatal(0, "dsl_destroy_snapshot(%s, B_FALSE) = %d",
4704 fullname, error);
4705 }
4706
4707 error = dsl_destroy_snapshot(fullname, B_TRUE);
4708 if (error) {
4709 fatal(0, "dsl_destroy_snapshot(%s, B_TRUE) = %d",
4710 fullname, error);
4711 }
4712
4713 error = user_release_one(fullname, tag);
4714 if (error)
4715 fatal(0, "user_release_one(%s, %s) = %d", fullname, tag, error);
4716
4717 VERIFY3U(dmu_objset_hold(fullname, FTAG, &origin), ==, ENOENT);
4718
4719 out:
4720 (void) rw_unlock(&ztest_name_lock);
4721 }
4722
4723 /*
4724 * Inject random faults into the on-disk data.
4725 */
4726 /* ARGSUSED */
4727 void
4728 ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
4729 {
4730 ztest_shared_t *zs = ztest_shared;
4731 spa_t *spa = ztest_spa;
4732 int fd;
4733 uint64_t offset;
4734 uint64_t leaves;
4735 uint64_t bad = 0x1990c0ffeedecade;
|