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
94d1a2100edbb6781ea1c047a6334bb3f15640f5Tim Haley * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
8df0bcf0df7622a075cc6e52f659d2fcfdd08cdcPaul Dagnelie * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
aad02571bc59671aa3103bb070ae365f531b0b62Saso Kiselkov/* Copyright (c) 2013 by Saso Kiselkov. All rights reserved. */
810e43b2eb0e320833671a403fdda51917e8b036Bill Pijewski/* Copyright (c) 2013, Joyent, Inc. All rights reserved. */
eb721827677c553ce8dd0d4390630a857f923f98Alek Pinchuk/* Copyright 2016 Nexenta Systems, Inc. All rights reserved. */
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * Enable/disable nopwrite feature.
fa9e4066f08beec538e775443c5be79dd423fcabahrensconst dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES] = {
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "object directory" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT64, TRUE, "object array" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT8, TRUE, "packed nvlist" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT64, TRUE, "packed nvlist size" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT64, TRUE, "bpobj header" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT64, TRUE, "SPA space map header" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT64, TRUE, "SPA space map" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT64, TRUE, "ZIL intent log" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT64, TRUE, "DSL directory" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "DSL directory child map"},
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "DSL dataset snap map" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT64, TRUE, "DSL dataset" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT8, FALSE, "ZFS plain file" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "ZFS master node" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "ZFS delete queue" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT8, FALSE, "zvol object" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT8, FALSE, "other uint8[]" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT64, FALSE, "other uint64[]" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "persistent error log" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT64, TRUE, "SPA history offsets" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "Pool properties" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "DSL permissions" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT64, TRUE, "FUID table size" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "DSL dataset next clones"},
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "scan work queue" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "ZFS user/group used" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "ZFS user/group quota" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "snapshot refcount tags"},
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "DDT ZAP algorithm" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "DDT statistics" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT8, TRUE, "System attributes" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "SA master node" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "SA attr registration" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "SA attr layouts" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "scan translations" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT8, FALSE, "deduplicated block" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "DSL deadlist map" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT64, TRUE, "DSL deadlist map hdr" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_ZAP, TRUE, "DSL dir clones" },
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden { DMU_BSWAP_UINT64, TRUE, "bpobj subobj" }
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Sidenconst dmu_object_byteswap_info_t dmu_ot_byteswap[DMU_BSWAP_NUMFUNCS] = {
79d728325e257b05859d2eef4a4dfbefdce05a76Matthew Ahrensdmu_buf_hold_noread_by_dnode(dnode_t *dn, uint64_t offset,
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrensdmu_buf_hold_noread(objset_t *os, uint64_t object, uint64_t offset,
79d728325e257b05859d2eef4a4dfbefdce05a76Matthew Ahrensdmu_buf_hold_by_dnode(dnode_t *dn, uint64_t offset,
79d728325e257b05859d2eef4a4dfbefdce05a76Matthew Ahrens err = dmu_buf_hold_noread_by_dnode(dn, offset, tag, dbp);
79d728325e257b05859d2eef4a4dfbefdce05a76Matthew Ahrens dmu_buf_impl_t *db = (dmu_buf_impl_t *)(*dbp);
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrensdmu_buf_hold(objset_t *os, uint64_t object, uint64_t offset,
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens err = dmu_buf_hold_noread(os, object, offset, tag, dbp);
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens dmu_buf_impl_t *db = (dmu_buf_impl_t *)(*dbp);
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Ericksondmu_set_bonus(dmu_buf_t *db_fake, int newsize, dmu_tx_t *tx)
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake;
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson } else if (newsize < 0 || newsize > db_fake->db_size) {
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Ericksondmu_set_bonustype(dmu_buf_t *db_fake, dmu_object_type_t type, dmu_tx_t *tx)
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake;
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake;
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaumdmu_rm_spill(objset_t *os, uint64_t object, dmu_tx_t *tx)
06e0070d70ba2ee95f5aa2645423eb2cf1546788Mark Shellenbaum rw_enter(&dn->dn_struct_rwlock, RW_WRITER);
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * returns ENOENT, EIO, or 0.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrockdmu_bonus_hold(objset_t *os, uint64_t object, void *tag, dmu_buf_t **dbp)
1934e92fc930c49429ad71a8ca97340f33227e78maybee /* as long as the bonus buf is held, the dnode will be held */
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson * Wait to drop dn_struct_rwlock until after adding the bonus dbuf's
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson * hold and incrementing the dbuf count to ensure that dnode_move() sees
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson * a dnode hold for every dbuf.
47cb52daa729f19e298c85a84e8df069365c5232Jeff Bonwick VERIFY(0 == dbuf_read(db, NULL, DB_RF_MUST_SUCCEED | DB_RF_NOPREFETCH));
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock return (0);
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum * returns ENOENT, EIO, or 0.
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum * This interface will allocate a blank spill dbuf when a spill blk
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum * doesn't already exist on the dnode.
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum * if you only want to find an already existing spill db, then
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum * dmu_spill_hold_existing() should be used.
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaumdmu_spill_hold_by_dnode(dnode_t *dn, uint32_t flags, void *tag, dmu_buf_t **dbp)
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum rw_enter(&dn->dn_struct_rwlock, RW_READER);
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaumdmu_spill_hold_existing(dmu_buf_t *bonus, void *tag, dmu_buf_t **dbp)
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson if (spa_version(dn->dn_objset->os_spa) < SPA_VERSION_SA) {
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaumdmu_spill_hold_by_bonus(dmu_buf_t *bonus, void *tag, dmu_buf_t **dbp)
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson err = dmu_spill_hold_by_dnode(dn, DB_RF_CANFAIL, tag, dbp);
13506d1eefbbc37e2f12a0528831d9f6d4c361d7maybee * Note: longer-term, we should modify all of the dmu_buf_*() interfaces
13506d1eefbbc37e2f12a0528831d9f6d4c361d7maybee * to take a held dnode rather than <os, object> -- the lookup is wasteful,
13506d1eefbbc37e2f12a0528831d9f6d4c361d7maybee * and can induce severe lock contention when writing to several files
13506d1eefbbc37e2f12a0528831d9f6d4c361d7maybee * whose dnodes are in the same block.
7bfdf011e081684f853a3242d0296695110d9d84Neil Perrindmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length,
cf6106c8a0d6598b045811f9650d66e07eb332afMatthew Ahrens boolean_t read, void *tag, int *numbufsp, dmu_buf_t ***dbpp, uint32_t flags)
cf6106c8a0d6598b045811f9650d66e07eb332afMatthew Ahrens * Note: We directly notify the prefetch code of this read, so that
cf6106c8a0d6598b045811f9650d66e07eb332afMatthew Ahrens * we can tell it about the multi-block read. dbuf_read() only knows
cf6106c8a0d6598b045811f9650d66e07eb332afMatthew Ahrens * about the one block it is accessing.
cf6106c8a0d6598b045811f9650d66e07eb332afMatthew Ahrens dbuf_flags = DB_RF_CANFAIL | DB_RF_NEVERWAIT | DB_RF_HAVESTRUCT |
cf6106c8a0d6598b045811f9650d66e07eb332afMatthew Ahrens nblks = (P2ROUNDUP(offset + length, 1ULL << blkshift) -
cf6106c8a0d6598b045811f9650d66e07eb332afMatthew Ahrens P2ALIGN(offset, 1ULL << blkshift)) >> blkshift;
0125049cd6136d1d2ca9e982382a915b6d7916ceahrens zfs_panic_recover("zfs: accessing past end of object "
0125049cd6136d1d2ca9e982382a915b6d7916ceahrens "%llx/%llx (size=%u access=%llu+%llu)",
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock dbp = kmem_zalloc(sizeof (dmu_buf_t *) * nblks, KM_SLEEP);
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick zio = zio_root(dn->dn_objset->os_spa, NULL, NULL, ZIO_FLAG_CANFAIL);
fa9e4066f08beec538e775443c5be79dd423fcabahrens for (i = 0; i < nblks; i++) {
cf6106c8a0d6598b045811f9650d66e07eb332afMatthew Ahrens dmu_buf_impl_t *db = dbuf_hold(dn, blkid + i, tag);
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock /* initiate async i/o */
cb92f4130ce5b2c4ae1fa5fa6c776f4d4dc28ad9Alexander Motin DNODE_META_IS_CACHEABLE(dn) && length <= zfetch_array_rd_sz) {
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock /* wait for async i/o */
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock /* wait for other io to complete */
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock for (i = 0; i < nblks; i++) {
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock return (0);
13506d1eefbbc37e2f12a0528831d9f6d4c361d7maybeedmu_buf_hold_array(objset_t *os, uint64_t object, uint64_t offset,
13506d1eefbbc37e2f12a0528831d9f6d4c361d7maybee uint64_t length, int read, void *tag, int *numbufsp, dmu_buf_t ***dbpp)
13506d1eefbbc37e2f12a0528831d9f6d4c361d7maybee err = dmu_buf_hold_array_by_dnode(dn, offset, length, read, tag,
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Ericksondmu_buf_hold_array_by_bonus(dmu_buf_t *db_fake, uint64_t offset,
cf6106c8a0d6598b045811f9650d66e07eb332afMatthew Ahrens uint64_t length, boolean_t read, void *tag, int *numbufsp,
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake;
13506d1eefbbc37e2f12a0528831d9f6d4c361d7maybee err = dmu_buf_hold_array_by_dnode(dn, offset, length, read, tag,
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrockdmu_buf_rele_array(dmu_buf_t **dbp_fake, int numbufs, void *tag)
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock for (i = 0; i < numbufs; i++) {
a2cdcdd260232b58202b11a9bfc0103c9449ed52Paul Dagnelie * Issue prefetch i/os for the given blocks. If level is greater than 0, the
a2cdcdd260232b58202b11a9bfc0103c9449ed52Paul Dagnelie * indirect blocks prefeteched will be those that point to the blocks containing
a2cdcdd260232b58202b11a9bfc0103c9449ed52Paul Dagnelie * the data starting at offset, and continuing to offset + len.
a2cdcdd260232b58202b11a9bfc0103c9449ed52Paul Dagnelie * Note that if the indirect blocks above the blocks being prefetched are not in
a2cdcdd260232b58202b11a9bfc0103c9449ed52Paul Dagnelie * cache, they will be asychronously read in.
a2cdcdd260232b58202b11a9bfc0103c9449ed52Paul Dagneliedmu_prefetch(objset_t *os, uint64_t object, int64_t level, uint64_t offset,
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (len == 0) { /* they're interested in the bonus buffer */
fa9e4066f08beec538e775443c5be79dd423fcabahrens * XXX - Note, if the dnode for the requested object is not
fa9e4066f08beec538e775443c5be79dd423fcabahrens * already cached, we will do a *synchronous* read in the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * dnode_hold() call. The same is true for any indirects.
a2cdcdd260232b58202b11a9bfc0103c9449ed52Paul Dagnelie * offset + len - 1 is the last byte we want to prefetch for, and offset
a2cdcdd260232b58202b11a9bfc0103c9449ed52Paul Dagnelie * is the first. Then dbuf_whichblk(dn, level, off + len - 1) is the
a2cdcdd260232b58202b11a9bfc0103c9449ed52Paul Dagnelie * last block we want to prefetch, and dbuf_whichblock(dn, level,
a2cdcdd260232b58202b11a9bfc0103c9449ed52Paul Dagnelie * offset) is the first. Then the number we need to prefetch is the
a2cdcdd260232b58202b11a9bfc0103c9449ed52Paul Dagnelie * last - first + 1.
a2cdcdd260232b58202b11a9bfc0103c9449ed52Paul Dagnelie nblks = dbuf_whichblock(dn, level, offset + len - 1) -
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (nblks != 0) {
69962b5647e4a8b9b14998733b765925381b727eMatthew Ahrens for (int i = 0; i < nblks; i++)
762562058c49df3abfc6555f5b8174f3900e5c78Mark Maybee * Get the next "chunk" of file data to free. We traverse the file from
762562058c49df3abfc6555f5b8174f3900e5c78Mark Maybee * the end so that the file gets shorter over time (if we crashes in the
762562058c49df3abfc6555f5b8174f3900e5c78Mark Maybee * middle, this will leave us in a better state). We find allocated file
762562058c49df3abfc6555f5b8174f3900e5c78Mark Maybee * data by simply searching the allocated level 1 indirects.
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens * On input, *start should be the first offset that does not need to be
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens * freed (e.g. "offset + length"). On return, *start will be the first
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens * offset that should be freed.
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrensget_next_chunk(dnode_t *dn, uint64_t *start, uint64_t minimum)
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens uint64_t maxblks = DMU_MAX_ACCESS >> (dn->dn_indblkshift + 1);
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens /* bytes of data covered by a level-1 indirect block */
1c8564a7573482b45fcc6f9bc0c2de70f92c193cMark Maybee dn->dn_datablksz * EPB(dn->dn_indblkshift, SPA_BLKPTRSHIFT);
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens if (*start - minimum <= iblkrange * maxblks) {
cdb0ab79ea1af7b8fc339a04d4bf7426dc77ec4emaybee return (0);
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens for (uint64_t blks = 0; *start > minimum && blks < maxblks; blks++) {
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens * dnode_next_offset(BACKWARDS) will find an allocated L1
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens * indirect block at or before the input offset. We must
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens * decrement *start so that it is at the end of the region
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens /* if there are no indirect blocks before start, we are done */
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens } else if (err != 0) {
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens /* set start to the beginning of this L1 indirect */
cdb0ab79ea1af7b8fc339a04d4bf7426dc77ec4emaybee return (0);
eb721827677c553ce8dd0d4390630a857f923f98Alek Pinchuk * If this objset is of type OST_ZFS return true if vfs's unmounted flag is set,
eb721827677c553ce8dd0d4390630a857f923f98Alek Pinchuk * otherwise return false.
eb721827677c553ce8dd0d4390630a857f923f98Alek Pinchuk * Used below in dmu_free_long_range_impl() to enable abort when unmounting
cdb0ab79ea1af7b8fc339a04d4bf7426dc77ec4emaybeedmu_free_long_range_impl(objset_t *os, dnode_t *dn, uint64_t offset,
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens uint64_t object_size = (dn->dn_maxblkid + 1) * dn->dn_datablksz;
cdb0ab79ea1af7b8fc339a04d4bf7426dc77ec4emaybee return (0);
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens if (length == DMU_OBJECT_END || offset + length > object_size)
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens while (length != 0) {
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens /* move chunk_begin backwards to the beginning of this chunk */
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens err = get_next_chunk(dn, &chunk_begin, offset);
4bb73804952172060c9efb163b89c17f56804fe8Matthew Ahrens * Mark this transaction as typically resulting in a net
4bb73804952172060c9efb163b89c17f56804fe8Matthew Ahrens * reduction in space used.
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens dnode_free_range(dn, chunk_begin, chunk_end - chunk_begin, tx);
cdb0ab79ea1af7b8fc339a04d4bf7426dc77ec4emaybee return (0);
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens err = dmu_free_long_range_impl(os, dn, offset, length);
5253393b09789ec67bec153b866d7285a1cf1645Matthew Ahrens * It is important to zero out the maxblkid when freeing the entire
5253393b09789ec67bec153b866d7285a1cf1645Matthew Ahrens * file, so that (a) subsequent calls to dmu_free_long_range_impl()
5253393b09789ec67bec153b866d7285a1cf1645Matthew Ahrens * will take the fast path, and (b) dnode_reallocate() can verify
5253393b09789ec67bec153b866d7285a1cf1645Matthew Ahrens * that the entire file has been freed.
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossman if (err == 0 && offset == 0 && length == DMU_OBJECT_END)
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrensdmu_free_long_object(objset_t *os, uint64_t object)
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens err = dmu_free_long_range(os, object, 0, DMU_OBJECT_END);
713d6c208802cfbb806329ec0d154b641b80c355Matthew Ahrens dmu_tx_hold_free(tx, object, 0, DMU_OBJECT_END);
fa9e4066f08beec538e775443c5be79dd423fcabahrensdmu_free_range(objset_t *os, uint64_t object, uint64_t offset,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ASSERT(size == -1ULL || size <= UINT64_MAX - offset);
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock return (0);
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrockdmu_read(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
feb08c6bb47ceffa5bb7a70f2c0549113f40fcc5billm * Deal with odd block sizes, where there can't be data past the first
feb08c6bb47ceffa5bb7a70f2c0549113f40fcc5billm * block. If we ever do the tail block optimization, we will need to
feb08c6bb47ceffa5bb7a70f2c0549113f40fcc5billm * handle that here as well.
fa9e4066f08beec538e775443c5be79dd423fcabahrens while (size > 0) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens * NB: we could do this block-at-a-time, but it's nice
fa9e4066f08beec538e775443c5be79dd423fcabahrens * to be reading in parallel.
fa9e4066f08beec538e775443c5be79dd423fcabahrens for (i = 0; i < numbufs; i++) {
fa9e4066f08beec538e775443c5be79dd423fcabahrensdmu_write(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock VERIFY(0 == dmu_buf_hold_array(os, object, offset, size,
fa9e4066f08beec538e775443c5be79dd423fcabahrens for (i = 0; i < numbufs; i++) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens ASSERT(i == 0 || i == numbufs-1 || tocpy == db->db_size);
82c9918f28a2d8d9e93769e16f7fa7bee347e80fTim Haleydmu_prealloc(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
82c9918f28a2d8d9e93769e16f7fa7bee347e80fTim Haley VERIFY(0 == dmu_buf_hold_array(os, object, offset, size,
82c9918f28a2d8d9e93769e16f7fa7bee347e80fTim Haley for (i = 0; i < numbufs; i++) {
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrensdmu_write_embedded(objset_t *os, uint64_t object, uint64_t offset,
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens void *data, uint8_t etype, uint8_t comp, int uncompressed_size,
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens int compressed_size, int byteorder, dmu_tx_t *tx)
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens VERIFY0(dmu_buf_hold_noread(os, object, offset,
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens data, (bp_embedded_type_t)etype, (enum zio_compress)comp,
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens uncompressed_size, compressed_size, byteorder, tx);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States * DMU support for xuio
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United Stateskstat_t *xuio_ksp = NULL;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United Statesdmu_xuio_init(xuio_t *xuio, int nblk)
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States dmu_xuio_t *priv;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States uio_t *uio = &xuio->xu_uio;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States uio->uio_iovcnt = nblk;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States uio->uio_iov = kmem_zalloc(nblk * sizeof (iovec_t), KM_SLEEP);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States priv = kmem_zalloc(sizeof (dmu_xuio_t), KM_SLEEP);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States priv->cnt = nblk;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States priv->bufs = kmem_zalloc(nblk * sizeof (arc_buf_t *), KM_SLEEP);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States priv->iovp = uio->uio_iov;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States XUIO_XUZC_PRIV(xuio) = priv;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States if (XUIO_XUZC_RW(xuio) == UIO_READ)
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States XUIOSTAT_INCR(xuiostat_onloan_rbuf, nblk);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States XUIOSTAT_INCR(xuiostat_onloan_wbuf, nblk);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States return (0);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United Statesdmu_xuio_fini(xuio_t *xuio)
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States dmu_xuio_t *priv = XUIO_XUZC_PRIV(xuio);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States int nblk = priv->cnt;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States kmem_free(priv->iovp, nblk * sizeof (iovec_t));
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States kmem_free(priv->bufs, nblk * sizeof (arc_buf_t *));
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States kmem_free(priv, sizeof (dmu_xuio_t));
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States if (XUIO_XUZC_RW(xuio) == UIO_READ)
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States XUIOSTAT_INCR(xuiostat_onloan_rbuf, -nblk);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States XUIOSTAT_INCR(xuiostat_onloan_wbuf, -nblk);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States * Initialize iov[priv->next] and priv->bufs[priv->next] with { off, n, abuf }
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States * and increase priv->next by 1.
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United Statesdmu_xuio_add(xuio_t *xuio, arc_buf_t *abuf, offset_t off, size_t n)
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States struct iovec *iov;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States uio_t *uio = &xuio->xu_uio;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States dmu_xuio_t *priv = XUIO_XUZC_PRIV(xuio);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States int i = priv->next++;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States ASSERT(i < priv->cnt);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States iov = uio->uio_iov + i;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States iov->iov_base = (char *)abuf->b_data + off;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States iov->iov_len = n;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States priv->bufs[i] = abuf;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States return (0);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United Statesdmu_xuio_cnt(xuio_t *xuio)
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States dmu_xuio_t *priv = XUIO_XUZC_PRIV(xuio);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States return (priv->cnt);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United Statesarc_buf_t *
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United Statesdmu_xuio_arcbuf(xuio_t *xuio, int i)
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States dmu_xuio_t *priv = XUIO_XUZC_PRIV(xuio);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States ASSERT(i < priv->cnt);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States return (priv->bufs[i]);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United Statesdmu_xuio_clear(xuio_t *xuio, int i)
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States dmu_xuio_t *priv = XUIO_XUZC_PRIV(xuio);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States ASSERT(i < priv->cnt);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States priv->bufs[i] = NULL;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United Statesstatic void
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United Statesxuio_stat_init(void)
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States xuio_ksp = kstat_create("zfs", 0, "xuio_stats", "misc",
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States KSTAT_TYPE_NAMED, sizeof (xuio_stats) / sizeof (kstat_named_t),
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States KSTAT_FLAG_VIRTUAL);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States if (xuio_ksp != NULL) {
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States xuio_ksp->ks_data = &xuio_stats;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States kstat_install(xuio_ksp);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United Statesstatic void
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United Statesxuio_stat_fini(void)
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States if (xuio_ksp != NULL) {
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States kstat_delete(xuio_ksp);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States xuio_ksp = NULL;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States XUIOSTAT_BUMP(xuiostat_wbuf_copied);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States XUIOSTAT_BUMP(xuiostat_wbuf_nocopy);
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrensdmu_read_uio_dnode(dnode_t *dn, uio_t *uio, uint64_t size)
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States xuio_t *xuio = NULL;
feb08c6bb47ceffa5bb7a70f2c0549113f40fcc5billm * NB: we could do this block-at-a-time, but it's nice
feb08c6bb47ceffa5bb7a70f2c0549113f40fcc5billm * to be reading in parallel.
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens err = dmu_buf_hold_array_by_dnode(dn, uio->uio_loffset, size,
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States if (uio->uio_extflg == UIO_XUIO)
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States xuio = (xuio_t *)uio;
feb08c6bb47ceffa5bb7a70f2c0549113f40fcc5billm for (i = 0; i < numbufs; i++) {
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States if (xuio) {
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States dmu_buf_impl_t *dbi = (dmu_buf_impl_t *)db;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States arc_buf_t *dbuf_abuf = dbi->db_buf;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States arc_buf_t *abuf = dbuf_loan_arcbuf(dbi);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States err = dmu_xuio_add(xuio, abuf, bufoff, tocpy);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States if (!err) {
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States uio->uio_resid -= tocpy;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States uio->uio_loffset += tocpy;
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States if (abuf == dbuf_abuf)
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States XUIOSTAT_BUMP(xuiostat_rbuf_nocopy);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States XUIOSTAT_BUMP(xuiostat_rbuf_copied);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States } else {
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States err = uiomove((char *)db->db_data + bufoff, tocpy,
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States UIO_READ, uio);
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * Read 'size' bytes into the uio buffer.
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * From object zdb->db_object.
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * Starting at offset uio->uio_loffset.
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * If the caller already has a dbuf in the target object
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * (e.g. its bonus buffer), this routine is faster than dmu_read_uio(),
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * because we don't have to find the dnode_t for the object.
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrensdmu_read_uio_dbuf(dmu_buf_t *zdb, uio_t *uio, uint64_t size)
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * Read 'size' bytes into the uio buffer.
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * From the specified object
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * Starting at offset uio->uio_loffset.
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrensdmu_read_uio(objset_t *os, uint64_t object, uio_t *uio, uint64_t size)
94d1a2100edbb6781ea1c047a6334bb3f15640f5Tim Haleydmu_write_uio_dnode(dnode_t *dn, uio_t *uio, uint64_t size, dmu_tx_t *tx)
94d1a2100edbb6781ea1c047a6334bb3f15640f5Tim Haley err = dmu_buf_hold_array_by_dnode(dn, uio->uio_loffset, size,
fa9e4066f08beec538e775443c5be79dd423fcabahrens for (i = 0; i < numbufs; i++) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens ASSERT(i == 0 || i == numbufs-1 || tocpy == db->db_size);
fa9e4066f08beec538e775443c5be79dd423fcabahrens * XXX uiomove could block forever (eg. nfs-backed
fa9e4066f08beec538e775443c5be79dd423fcabahrens * pages). There needs to be a uiolockdown() function
fa9e4066f08beec538e775443c5be79dd423fcabahrens * to lock the pages in memory, so that uiomove won't
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * Write 'size' bytes from the uio buffer.
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * To object zdb->db_object.
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * Starting at offset uio->uio_loffset.
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * If the caller already has a dbuf in the target object
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * (e.g. its bonus buffer), this routine is faster than dmu_write_uio(),
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * because we don't have to find the dnode_t for the object.
94d1a2100edbb6781ea1c047a6334bb3f15640f5Tim Haleydmu_write_uio_dbuf(dmu_buf_t *zdb, uio_t *uio, uint64_t size,
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * Write 'size' bytes from the uio buffer.
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * To the specified object.
f8554bb92be6be88a684bea58293b41a6168a538Matthew Ahrens * Starting at offset uio->uio_loffset.
94d1a2100edbb6781ea1c047a6334bb3f15640f5Tim Haleydmu_write_uio(objset_t *os, uint64_t object, uio_t *uio, uint64_t size,
44eda4d76a9383a159e44aa60b63a17644ddd5b1maybeedmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
44eda4d76a9383a159e44aa60b63a17644ddd5b1maybee return (0);
44eda4d76a9383a159e44aa60b63a17644ddd5b1maybee for (i = 0; i < numbufs; i++) {
44eda4d76a9383a159e44aa60b63a17644ddd5b1maybee ASSERT(i == 0 || i == numbufs-1 || tocpy == db->db_size);
44eda4d76a9383a159e44aa60b63a17644ddd5b1maybee for (copied = 0; copied < tocpy; copied += PAGESIZE) {
2fdbea25c2ba89186b8a6b7c6840ebc9f4dff245Aleksandr Guzovskiy * Allocate a loaned anonymous arc buffer.
2fdbea25c2ba89186b8a6b7c6840ebc9f4dff245Aleksandr Guzovskiydmu_request_arcbuf(dmu_buf_t *handle, int size)
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel return (arc_loan_buf(db->db_objset->os_spa, B_FALSE, size));
2fdbea25c2ba89186b8a6b7c6840ebc9f4dff245Aleksandr Guzovskiy * Free a loaned arc buffer.
2fdbea25c2ba89186b8a6b7c6840ebc9f4dff245Aleksandr Guzovskiy * When possible directly assign passed loaned arc buffer to a dbuf.
2fdbea25c2ba89186b8a6b7c6840ebc9f4dff245Aleksandr Guzovskiy * If this is not possible copy the contents of passed arc buf via
2fdbea25c2ba89186b8a6b7c6840ebc9f4dff245Aleksandr Guzovskiy * dmu_write().
2fdbea25c2ba89186b8a6b7c6840ebc9f4dff245Aleksandr Guzovskiydmu_assign_arcbuf(dmu_buf_t *handle, uint64_t offset, arc_buf_t *buf,
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson dmu_buf_impl_t *dbuf = (dmu_buf_impl_t *)handle;
2fdbea25c2ba89186b8a6b7c6840ebc9f4dff245Aleksandr Guzovskiy rw_enter(&dn->dn_struct_rwlock, RW_READER);
2fdbea25c2ba89186b8a6b7c6840ebc9f4dff245Aleksandr Guzovskiy VERIFY((db = dbuf_hold(dn, blkid, FTAG)) != NULL);
8a9047098ad8ce5afa38b6d012c8b509bb619f40Matthew Ahrens * We can only assign if the offset is aligned, the arc buf is the
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel * same size as the dbuf, and the dbuf is not metadata.
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel if (offset == db->db.db_offset && blksz == db->db.db_size) {
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel /* compressed bufs must always be assignable to their dbuf */
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel ASSERT3U(arc_get_compression(buf), ==, ZIO_COMPRESS_OFF);
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel ASSERT(!(buf->b_flags & ARC_BUF_FLAG_COMPRESSED));
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson dmu_write(os, object, offset, blksz, buf->b_data, tx);
c242f9a02a2ef021449275ae0a1d2581ee77231dchunli zhang - Sun Microsystems - Irvine United States XUIOSTAT_BUMP(xuiostat_wbuf_copied);
c5c6ffa0498b9c8555798756141b4a3061a138c1maybeetypedef struct {
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick/* ARGSUSED */
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwickdmu_sync_ready(zio_t *zio, arc_buf_t *buf, void *varg)
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * A block of zeros may compress to a hole, but the
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * block size still needs to be known for replay.
c5c6ffa0498b9c8555798756141b4a3061a138c1maybee/* ARGSUSED */
b50a0fe0a71cfbd8811ad06ae54e0986ff73b9deNeil Perrin ASSERT(dr->dt.dl.dr_override_state == DR_IN_DMU_SYNC);
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson dr->dt.dl.dr_nopwrite = !!(zio->io_flags & ZIO_FLAG_NOPWRITE);
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson ASSERT(zio->io_prop.zp_compress != ZIO_COMPRESS_OFF);
70163ac57e58ace1c5c94dfbe85dca5a974eff36Prakash Surya * Old style holes are filled with all zeros, whereas
70163ac57e58ace1c5c94dfbe85dca5a974eff36Prakash Surya * new-style holes maintain their lsize, type, level,
70163ac57e58ace1c5c94dfbe85dca5a974eff36Prakash Surya * and birth time (see zio_write_compress). While we
70163ac57e58ace1c5c94dfbe85dca5a974eff36Prakash Surya * need to reset the BP_SET_LSIZE() call that happened
70163ac57e58ace1c5c94dfbe85dca5a974eff36Prakash Surya * in dmu_sync_ready for old style holes, we do *not*
70163ac57e58ace1c5c94dfbe85dca5a974eff36Prakash Surya * want to wipe out the information contained in new
70163ac57e58ace1c5c94dfbe85dca5a974eff36Prakash Surya * style holes. Thus, only zero out the block pointer if
70163ac57e58ace1c5c94dfbe85dca5a974eff36Prakash Surya * it's an old style hole.
70163ac57e58ace1c5c94dfbe85dca5a974eff36Prakash Surya if (BP_IS_HOLE(&dr->dt.dl.dr_overridden_by) &&
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick dr->dt.dl.dr_override_state = DR_NOT_OVERRIDDEN;
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * If we didn't allocate a new block (i.e. ZIO_FLAG_NOPWRITE)
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * then there is nothing to do here. Otherwise, free the
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * newly allocated block in this txg.
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson ASSERT(BP_IS_HOLE(bp_orig) || !BP_EQUAL(bp, bp_orig));
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson ASSERT(zio->io_txg > spa_syncing_txg(zio->io_spa));
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson zio_free(zio->io_spa, zio->io_txg, zio->io_bp);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwickdmu_sync_late_arrival(zio_t *pio, objset_t *os, dmu_sync_cb_t *done, zgd_t *zgd,
be6fd75a69ae679453d9cda5bff3326111e6d1caMatthew Ahrens /* Make zl_get_data do txg_waited_synced() */
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick dsa = kmem_alloc(sizeof (dmu_sync_arg_t), KM_SLEEP);
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel zio_nowait(zio_write(pio, os->os_spa, dmu_tx_get_txg(tx), zgd->zgd_bp,
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel zgd->zgd_db->db_data, zgd->zgd_db->db_size, zgd->zgd_db->db_size,
8df0bcf0df7622a075cc6e52f659d2fcfdd08cdcPaul Dagnelie NULL, dmu_sync_late_arrival_done, dsa, ZIO_PRIORITY_SYNC_WRITE,
c5c6ffa0498b9c8555798756141b4a3061a138c1maybee * Intent log support: sync the block associated with db to disk.
c5c6ffa0498b9c8555798756141b4a3061a138c1maybee * N.B. and XXX: the caller is responsible for making sure that the
c5c6ffa0498b9c8555798756141b4a3061a138c1maybee * data isn't changing while dmu_sync() is writing it.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Return values:
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * EEXIST: this txg has already been synced, so there's nothing to do.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The caller should not log the write.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * ENOENT: the block was dbuf_free_range()'d, so there's nothing to do.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The caller should not log the write.
c5c6ffa0498b9c8555798756141b4a3061a138c1maybee * EALREADY: this block is already in the process of being synced.
c5c6ffa0498b9c8555798756141b4a3061a138c1maybee * The caller should track its progress (somehow).
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * EIO: could not do the I/O.
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * The caller should do a txg_wait_synced().
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * 0: the I/O has been initiated.
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * The caller should log this blkptr in the done callback.
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * It is possible that the I/O will fail, in which case
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * the error will be reported to the done callback and
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * propagated to pio from zio_done().
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwickdmu_sync(zio_t *pio, uint64_t txg, dmu_sync_cb_t *done, zgd_t *zgd)
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick dmu_buf_impl_t *db = (dmu_buf_impl_t *)zgd->zgd_db;
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel dmu_write_policy(os, dn, db->db_level, WP_DMU_SYNC,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * If we're frozen (running ziltest), we always need to generate a bp.
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick return (dmu_sync_late_arrival(pio, os, done, zgd, &zp, &zb));
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * Grabbing db_mtx now provides a barrier between dbuf_sync_leaf()
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * and us. If we determine that this txg is not yet syncing,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * but it begins to sync a moment later, that's OK because the
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * sync thread will block in dbuf_sync_leaf() until we drop db_mtx.
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * This txg has already synced. There's nothing to do.
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * This txg is currently syncing, so we can't mess with
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * the dirty record anymore; just write a new log block.
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick return (dmu_sync_late_arrival(pio, os, done, zgd, &zp, &zb));
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * There's no dr for this dbuf, so it must have been freed.
c5c6ffa0498b9c8555798756141b4a3061a138c1maybee * There's no need to log writes to freed blocks, so we're done.
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson ASSERT(dr->dr_next == NULL || dr->dr_next->dr_txg < txg);
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens * Assume the on-disk data is X, the current syncing data (in
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens * txg - 1) is Y, and the current in-memory data is Z (currently
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens * in dmu_sync).
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens * We usually want to perform a nopwrite if X and Z are the
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens * same. However, if Y is different (i.e. the BP is going to
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens * change before this write takes effect), then a nopwrite will
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens * be incorrect - we would override with X, which could have
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens * been freed when Y was written.
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens * (Note that this is not a concern when we are nop-writing from
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens * syncing context, because X and Y must be identical, because
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens * all previous txgs have been synced.)
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens * Therefore, we disable nopwrite if the current BP could change
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens * before this TXG. There are two ways it could change: by
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens * being dirty (dr_next is non-NULL), or by being freed
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens * (dnode_block_freed()). This behavior is verified by
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens * zio_done(), which VERIFYs that the override BP is identical
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens * to the on-disk BP.
34e8acef009195effafdcf6417aec385e241796eMatthew Ahrens if (dr->dr_next != NULL || dnode_block_freed(dn, db->db_blkid))
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick if (dr->dt.dl.dr_override_state == DR_IN_DMU_SYNC ||
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick dr->dt.dl.dr_override_state == DR_OVERRIDDEN) {
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * We have already issued a sync write for this buffer,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * or this buffer has already been synced. It could not
c717a56157ae0e6fca6a1e3689ae1edc385716a3maybee * have been dirtied since, or we would have cleared the state.
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick ASSERT(dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick dsa = kmem_alloc(sizeof (dmu_sync_arg_t), KM_SLEEP);
aad02571bc59671aa3103bb070ae365f531b0b62Saso Kiselkov bp, dr->dt.dl.dr_data, DBUF_IS_L2CACHEABLE(db),
dcbf3bd6a1f1360fc1afcee9e22c6dcff7844bf2George Wilson &zp, dmu_sync_ready, NULL, NULL, dmu_sync_done, dsa,
8df0bcf0df7622a075cc6e52f659d2fcfdd08cdcPaul Dagnelie ZIO_PRIORITY_SYNC_WRITE, ZIO_FLAG_CANFAIL, &zb));
fa9e4066f08beec538e775443c5be79dd423fcabahrensdmu_object_set_blocksize(objset_t *os, uint64_t object, uint64_t size, int ibs,
fa9e4066f08beec538e775443c5be79dd423fcabahrensdmu_object_set_checksum(objset_t *os, uint64_t object, uint8_t checksum,
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens * Send streams include each object's checksum function. This
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens * check ensures that the receiving system can understand the
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens * checksum function transmitted.
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens ASSERT3U(checksum, <, ZIO_CHECKSUM_LEGACY_FUNCTIONS);
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens ASSERT3U(checksum, <, ZIO_CHECKSUM_FUNCTIONS);
fa9e4066f08beec538e775443c5be79dd423fcabahrensdmu_object_set_compress(objset_t *os, uint64_t object, uint8_t compress,
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens * Send streams include each object's compression function. This
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens * check ensures that the receiving system can understand the
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens * compression function transmitted.
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens ASSERT3U(compress, <, ZIO_COMPRESS_LEGACY_FUNCTIONS);
edf345e6b8342e8627ec20ce821a977a62cee19dMatthew Ahrens * When the "redundant_metadata" property is set to "most", only indirect
edf345e6b8342e8627ec20ce821a977a62cee19dMatthew Ahrens * blocks of this level and higher will have an additional ditto block.
edf345e6b8342e8627ec20ce821a977a62cee19dMatthew Ahrensint zfs_redundant_metadata_most_ditto_level = 2;
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmeldmu_write_policy(objset_t *os, dnode_t *dn, int level, int wp,
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel enum zio_compress override_compress, zio_prop_t *zp)
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick dmu_object_type_t type = dn ? dn->dn_type : DMU_OT_OBJSET;
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden boolean_t ismd = (level > 0 || DMU_OT_IS_METADATA(type) ||
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick enum zio_checksum dedup_checksum = os->os_dedup_checksum;
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel boolean_t lz4_ac = spa_feature_is_active(os->os_spa,
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel IMPLY(override_compress == ZIO_COMPRESS_LZ4, lz4_ac);
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * We maintain different write policies for each of the following
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * types of data:
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * 1. metadata
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * 2. preallocated blocks (i.e. level-0 blocks of a dump device)
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * 3. all other level 0 blocks
db1741f555ec79def5e9846e6bfd132248514ffeJustin T. Gibbs * XXX -- we should design a compression algorithm
db1741f555ec79def5e9846e6bfd132248514ffeJustin T. Gibbs * that specializes in arrays of bps.
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * Metadata always gets checksummed. If the data
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * checksum is multi-bit correctable, and it's not a
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * ZBT-style checksum, then it's suitable for metadata
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * as well. Otherwise, the metadata checksum defaults
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * to fletcher4.
45818ee124adeaaf947698996b4f4c722afc6d1fMatthew Ahrens if (!(zio_checksum_table[checksum].ci_flags &
edf345e6b8342e8627ec20ce821a977a62cee19dMatthew Ahrens if (os->os_redundant_metadata == ZFS_REDUNDANT_METADATA_ALL ||
edf345e6b8342e8627ec20ce821a977a62cee19dMatthew Ahrens (level >= zfs_redundant_metadata_most_ditto_level ||
edf345e6b8342e8627ec20ce821a977a62cee19dMatthew Ahrens DMU_OT_IS_METADATA(type) || (wp & WP_SPILL))))
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * If we're writing preallocated blocks, we aren't actually
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * writing them so don't set any policy properties. These
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * blocks are currently only used by an external subsystem
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * outside of zfs (i.e. dump) and not written by the zio
db1741f555ec79def5e9846e6bfd132248514ffeJustin T. Gibbs compress = zio_compress_select(os->os_spa, dn->dn_compress,
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson checksum = (dedup_checksum == ZIO_CHECKSUM_OFF) ?
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson zio_checksum_select(dn->dn_checksum, checksum) :
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * Determine dedup setting. If we are in dmu_sync(),
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * we won't actually dedup now because that's all
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * done in syncing context; but we do want to use the
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * dedup checkum. If the checksum is not strong
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * enough to ensure unique signatures, force
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson * dedup_verify.
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson dedup = (wp & WP_DMU_SYNC) ? B_FALSE : B_TRUE;
45818ee124adeaaf947698996b4f4c722afc6d1fMatthew Ahrens if (!(zio_checksum_table[checksum].ci_flags &
45818ee124adeaaf947698996b4f4c722afc6d1fMatthew Ahrens * Enable nopwrite if we have secure enough checksum
45818ee124adeaaf947698996b4f4c722afc6d1fMatthew Ahrens * algorithm (see comment in zio_nop_write) and
45818ee124adeaaf947698996b4f4c722afc6d1fMatthew Ahrens * compression is enabled. We don't enable nopwrite if
45818ee124adeaaf947698996b4f4c722afc6d1fMatthew Ahrens * dedup is enabled as the two features are mutually
45818ee124adeaaf947698996b4f4c722afc6d1fMatthew Ahrens nopwrite = (!dedup && (zio_checksum_table[checksum].ci_flags &
80901aea8e78a2c20751f61f01bebd1d5b5c2ba5George Wilson compress != ZIO_COMPRESS_OFF && zfs_nopwrite_enabled);
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel * If we're writing a pre-compressed buffer, the compression type we use
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel * must match the data. If it hasn't been compressed yet, then we should
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel * use the value dictated by the policies above.
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel zp->zp_compress = override_compress != ZIO_COMPRESS_INHERIT
5602294fda888d923d57a78bafdaf48ae6223deaDan Kimmel ASSERT3U(zp->zp_compress, !=, ZIO_COMPRESS_INHERIT);
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum zp->zp_type = (wp & WP_SPILL) ? dn->dn_bonustype : type;
edf345e6b8342e8627ec20ce821a977a62cee19dMatthew Ahrens zp->zp_copies = MIN(copies, spa_max_replication(os->os_spa));
fa9e4066f08beec538e775443c5be79dd423fcabahrensdmu_offset_next(objset_t *os, uint64_t object, boolean_t hole, uint64_t *off)
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Sync any current changes before
fa9e4066f08beec538e775443c5be79dd423fcabahrens * we go trundling through the block pointers.
cdb0ab79ea1af7b8fc339a04d4bf7426dc77ec4emaybee err = dnode_next_offset(dn, (hole ? DNODE_FIND_HOLE : 0), off, 1, 1, 0);
2bcf0248e992f292c7b814458bcdce2f004925d6Max Grossman * Given the ZFS object, if it contains any dirty nodes
2bcf0248e992f292c7b814458bcdce2f004925d6Max Grossman * this function flushes all dirty blocks to disk. This
2bcf0248e992f292c7b814458bcdce2f004925d6Max Grossman * ensures the DMU object info is updated. A more efficient
2bcf0248e992f292c7b814458bcdce2f004925d6Max Grossman * future version might just find the TXG with the maximum
2bcf0248e992f292c7b814458bcdce2f004925d6Max Grossman * ID and wait for that to be synced.
9a686fbc186e8e2a64e9a5094d44c7d6fa0ea167Paul Dagneliedmu_object_wait_synced(objset_t *os, uint64_t object)
2bcf0248e992f292c7b814458bcdce2f004925d6Max Grossman for (i = 0; i < TXG_SIZE; i++) {
fa9e4066f08beec538e775443c5be79dd423fcabahrensdmu_object_info_from_dnode(dnode_t *dn, dmu_object_info_t *doi)
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick doi->doi_physical_blocks_512 = (DN_USED_BYTES(dnp) + 256) >> 9;
d04756377ddd1cf28ebcf652541094e17b03c889Matthew Ahrens doi->doi_max_offset = (dn->dn_maxblkid + 1) * dn->dn_datablksz;
5d7b4d438c4a51eccc95e77a83a437b4d48380ebMatthew Ahrens doi->doi_fill_count += BP_GET_FILL(&dnp->dn_blkptr[i]);
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Get information on a DMU object.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If doi is NULL, just indicates whether the object exists.
fa9e4066f08beec538e775443c5be79dd423fcabahrensdmu_object_info(objset_t *os, uint64_t object, dmu_object_info_t *doi)
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (0);
fa9e4066f08beec538e775443c5be79dd423fcabahrens * As above, but faster; can be used when you have a held dbuf in hand.
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Ericksondmu_object_info_from_db(dmu_buf_t *db_fake, dmu_object_info_t *doi)
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake;
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Faster still when you only care about the size.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * This is specifically optimized for zfs_getattr().
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Ericksondmu_object_size_from_db(dmu_buf_t *db_fake, uint32_t *blksize,
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake;
99653d4ee642c6528e88224f12409a5f23060994eschrock /* add 1 for dnode space */
99653d4ee642c6528e88224f12409a5f23060994eschrock *nblk512 = ((DN_USED_BYTES(dn->dn_phys) + SPA_MINBLOCKSIZE/2) >>
fa9e4066f08beec538e775443c5be79dd423fcabahrens for (i = 0; i < count; i++)
fa9e4066f08beec538e775443c5be79dd423fcabahrens for (i = 0; i < count; i++)
fa9e4066f08beec538e775443c5be79dd423fcabahrens for (i = 0; i < count; i++)
fa9e4066f08beec538e775443c5be79dd423fcabahrens/* ARGSUSED */
3e30c24aeefdee1631958ecf17f18da671781956Will Andrews arc_fini(); /* arc depends on l2arc, so arc must go first */