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, 2014 by Delphix. All rights reserved.
24 */
25 /* Copyright (c) 2013 by Saso Kiselkov. All rights reserved. */
26 /* Copyright (c) 2013, Joyent, Inc. All rights reserved. */
27
28 #include <sys/dmu.h>
29 #include <sys/dmu_impl.h>
30 #include <sys/dmu_tx.h>
31 #include <sys/dbuf.h>
32 #include <sys/dnode.h>
33 #include <sys/zfs_context.h>
34 #include <sys/dmu_objset.h>
35 #include <sys/dmu_traverse.h>
36 #include <sys/dsl_dataset.h>
37 #include <sys/dsl_dir.h>
38 #include <sys/dsl_pool.h>
39 #include <sys/dsl_synctask.h>
40 #include <sys/dsl_prop.h>
41 #include <sys/dmu_zfetch.h>
42 #include <sys/zfs_ioctl.h>
43 #include <sys/zap.h>
44 #include <sys/zio_checksum.h>
45 #include <sys/zio_compress.h>
46 #include <sys/sa.h>
47 #ifdef _KERNEL
48 #include <sys/vmsystm.h>
49 #include <sys/zfs_znode.h>
50 #endif
51
52 /*
53 * Enable/disable nopwrite feature.
54 */
55 int zfs_nopwrite_enabled = 1;
56
57 const dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES] = {
58 { DMU_BSWAP_UINT8, TRUE, "unallocated" },
59 { DMU_BSWAP_ZAP, TRUE, "object directory" },
60 { DMU_BSWAP_UINT64, TRUE, "object array" },
61 { DMU_BSWAP_UINT8, TRUE, "packed nvlist" },
62 { DMU_BSWAP_UINT64, TRUE, "packed nvlist size" },
63 { DMU_BSWAP_UINT64, TRUE, "bpobj" },
64 { DMU_BSWAP_UINT64, TRUE, "bpobj header" },
65 { DMU_BSWAP_UINT64, TRUE, "SPA space map header" },
66 { DMU_BSWAP_UINT64, TRUE, "SPA space map" },
1573 enum zio_checksum checksum = os->os_checksum;
1574 enum zio_compress compress = os->os_compress;
1575 enum zio_checksum dedup_checksum = os->os_dedup_checksum;
1576 boolean_t dedup = B_FALSE;
1577 boolean_t nopwrite = B_FALSE;
1578 boolean_t dedup_verify = os->os_dedup_verify;
1579 int copies = os->os_copies;
1580
1581 /*
1582 * We maintain different write policies for each of the following
1583 * types of data:
1584 * 1. metadata
1585 * 2. preallocated blocks (i.e. level-0 blocks of a dump device)
1586 * 3. all other level 0 blocks
1587 */
1588 if (ismd) {
1589 /*
1590 * XXX -- we should design a compression algorithm
1591 * that specializes in arrays of bps.
1592 */
1593 compress = zfs_mdcomp_disable ? ZIO_COMPRESS_EMPTY :
1594 ZIO_COMPRESS_LZJB;
1595
1596 /*
1597 * Metadata always gets checksummed. If the data
1598 * checksum is multi-bit correctable, and it's not a
1599 * ZBT-style checksum, then it's suitable for metadata
1600 * as well. Otherwise, the metadata checksum defaults
1601 * to fletcher4.
1602 */
1603 if (zio_checksum_table[checksum].ci_correctable < 1 ||
1604 zio_checksum_table[checksum].ci_eck)
1605 checksum = ZIO_CHECKSUM_FLETCHER_4;
1606
1607 if (os->os_redundant_metadata == ZFS_REDUNDANT_METADATA_ALL ||
1608 (os->os_redundant_metadata ==
1609 ZFS_REDUNDANT_METADATA_MOST &&
1610 (level >= zfs_redundant_metadata_most_ditto_level ||
1611 DMU_OT_IS_METADATA(type) || (wp & WP_SPILL))))
1612 copies++;
1613 } else if (wp & WP_NOFILL) {
1614 ASSERT(level == 0);
1615
|
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, 2014 by Delphix. All rights reserved.
24 */
25 /* Copyright (c) 2013 by Saso Kiselkov. All rights reserved. */
26 /* Copyright (c) 2013, Joyent, Inc. All rights reserved. */
27 /* Copyright (c) 2014, Nexenta Systems, Inc. All rights reserved. */
28
29 #include <sys/dmu.h>
30 #include <sys/dmu_impl.h>
31 #include <sys/dmu_tx.h>
32 #include <sys/dbuf.h>
33 #include <sys/dnode.h>
34 #include <sys/zfs_context.h>
35 #include <sys/dmu_objset.h>
36 #include <sys/dmu_traverse.h>
37 #include <sys/dsl_dataset.h>
38 #include <sys/dsl_dir.h>
39 #include <sys/dsl_pool.h>
40 #include <sys/dsl_synctask.h>
41 #include <sys/dsl_prop.h>
42 #include <sys/dmu_zfetch.h>
43 #include <sys/zfs_ioctl.h>
44 #include <sys/zap.h>
45 #include <sys/zio_checksum.h>
46 #include <sys/zio_compress.h>
47 #include <sys/sa.h>
48 #include <sys/zfeature.h>
49 #ifdef _KERNEL
50 #include <sys/vmsystm.h>
51 #include <sys/zfs_znode.h>
52 #endif
53
54 /*
55 * Enable/disable nopwrite feature.
56 */
57 int zfs_nopwrite_enabled = 1;
58
59 const dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES] = {
60 { DMU_BSWAP_UINT8, TRUE, "unallocated" },
61 { DMU_BSWAP_ZAP, TRUE, "object directory" },
62 { DMU_BSWAP_UINT64, TRUE, "object array" },
63 { DMU_BSWAP_UINT8, TRUE, "packed nvlist" },
64 { DMU_BSWAP_UINT64, TRUE, "packed nvlist size" },
65 { DMU_BSWAP_UINT64, TRUE, "bpobj" },
66 { DMU_BSWAP_UINT64, TRUE, "bpobj header" },
67 { DMU_BSWAP_UINT64, TRUE, "SPA space map header" },
68 { DMU_BSWAP_UINT64, TRUE, "SPA space map" },
1575 enum zio_checksum checksum = os->os_checksum;
1576 enum zio_compress compress = os->os_compress;
1577 enum zio_checksum dedup_checksum = os->os_dedup_checksum;
1578 boolean_t dedup = B_FALSE;
1579 boolean_t nopwrite = B_FALSE;
1580 boolean_t dedup_verify = os->os_dedup_verify;
1581 int copies = os->os_copies;
1582
1583 /*
1584 * We maintain different write policies for each of the following
1585 * types of data:
1586 * 1. metadata
1587 * 2. preallocated blocks (i.e. level-0 blocks of a dump device)
1588 * 3. all other level 0 blocks
1589 */
1590 if (ismd) {
1591 /*
1592 * XXX -- we should design a compression algorithm
1593 * that specializes in arrays of bps.
1594 */
1595 boolean_t lz4_ac = spa_feature_is_active(os->os_spa,
1596 SPA_FEATURE_LZ4_COMPRESS);
1597
1598 if (zfs_mdcomp_disable) {
1599 compress = ZIO_COMPRESS_EMPTY;
1600 } else if (lz4_ac) {
1601 compress = ZIO_COMPRESS_LZ4;
1602 } else {
1603 compress = ZIO_COMPRESS_LZJB;
1604 }
1605
1606 /*
1607 * Metadata always gets checksummed. If the data
1608 * checksum is multi-bit correctable, and it's not a
1609 * ZBT-style checksum, then it's suitable for metadata
1610 * as well. Otherwise, the metadata checksum defaults
1611 * to fletcher4.
1612 */
1613 if (zio_checksum_table[checksum].ci_correctable < 1 ||
1614 zio_checksum_table[checksum].ci_eck)
1615 checksum = ZIO_CHECKSUM_FLETCHER_4;
1616
1617 if (os->os_redundant_metadata == ZFS_REDUNDANT_METADATA_ALL ||
1618 (os->os_redundant_metadata ==
1619 ZFS_REDUNDANT_METADATA_MOST &&
1620 (level >= zfs_redundant_metadata_most_ditto_level ||
1621 DMU_OT_IS_METADATA(type) || (wp & WP_SPILL))))
1622 copies++;
1623 } else if (wp & WP_NOFILL) {
1624 ASSERT(level == 0);
1625
|