annotate usr/src/uts/common/fs/zfs/dbuf.c @ 13765:9410cf539b11

backout 3006: causes 3046 (panics after mounting root)
author Richard Lowe <richlowe@richlowe.net>
date Wed, 01 Aug 2012 16:40:39 -0400
parents 38b4aca480b3
children e3a9ae14a119
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2 * CDDL HEADER START
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
4 * The contents of this file are subject to the terms of the
1491
bdcb30e07e7d 6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents: 1199
diff changeset
5 * Common Development and Distribution License (the "License").
bdcb30e07e7d 6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents: 1199
diff changeset
6 * You may not use this file except in compliance with the License.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
7 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
9 * or http://www.opensolaris.org/os/licensing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
10 * See the License for the specific language governing permissions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
11 * and limitations under the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
12 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
13 * When distributing Covered Code, include this CDDL HEADER in each
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
15 * If applicable, add the following below this CDDL HEADER, with the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
16 * fields enclosed by brackets "[]" replaced with your own identifying
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
17 * information: Portions Copyright [yyyy] [name of copyright owner]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
18 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
19 * CDDL HEADER END
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
20 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
21 /*
12178
93ec1371f750 6939983 assertion failed: zap_count(os, DMU_USERUSED_OBJECT, &count) != 0||count == 0, in dsl_dataset.c
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11935
diff changeset
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
13298
c234f438c0d3 764 panic in zfs:dbuf_sync_list
Gordon Ross <gwr@nexenta.com>
parents: 13026
diff changeset
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13298
diff changeset
24 * Copyright (c) 2012 by Delphix. All rights reserved.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
25 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
26
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
27 #include <sys/zfs_context.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
28 #include <sys/dmu.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
29 #include <sys/dmu_impl.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
30 #include <sys/dbuf.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
31 #include <sys/dmu_objset.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
32 #include <sys/dsl_dataset.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
33 #include <sys/dsl_dir.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
34 #include <sys/dmu_tx.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
35 #include <sys/spa.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
36 #include <sys/zio.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
37 #include <sys/dmu_zfetch.h>
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
38 #include <sys/sa.h>
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
39 #include <sys/sa_impl.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
40
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
41 static void dbuf_destroy(dmu_buf_impl_t *db);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
42 static int dbuf_undirty(dmu_buf_impl_t *db, dmu_tx_t *tx);
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
43 static void dbuf_write(dbuf_dirty_record_t *dr, arc_buf_t *data, dmu_tx_t *tx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
44
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
45 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
46 * Global data structures and functions for the dbuf cache.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
47 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
48 static kmem_cache_t *dbuf_cache;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
49
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
50 /* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
51 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
52 dbuf_cons(void *vdb, void *unused, int kmflag)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
53 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
54 dmu_buf_impl_t *db = vdb;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
55 bzero(db, sizeof (dmu_buf_impl_t));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
56
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
57 mutex_init(&db->db_mtx, NULL, MUTEX_DEFAULT, NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
58 cv_init(&db->db_changed, NULL, CV_DEFAULT, NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
59 refcount_create(&db->db_holds);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
60 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
61 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
62
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
63 /* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
64 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
65 dbuf_dest(void *vdb, void *unused)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
66 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
67 dmu_buf_impl_t *db = vdb;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
68 mutex_destroy(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
69 cv_destroy(&db->db_changed);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
70 refcount_destroy(&db->db_holds);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
71 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
72
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
73 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
74 * dbuf hash table routines
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
75 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
76 static dbuf_hash_table_t dbuf_hash_table;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
77
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
78 static uint64_t dbuf_hash_count;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
79
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
80 static uint64_t
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
81 dbuf_hash(void *os, uint64_t obj, uint8_t lvl, uint64_t blkid)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
82 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
83 uintptr_t osv = (uintptr_t)os;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
84 uint64_t crc = -1ULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
85
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
86 ASSERT(zfs_crc64_table[128] == ZFS_CRC64_POLY);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
87 crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (lvl)) & 0xFF];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
88 crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (osv >> 6)) & 0xFF];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
89 crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (obj >> 0)) & 0xFF];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
90 crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (obj >> 8)) & 0xFF];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
91 crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (blkid >> 0)) & 0xFF];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
92 crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (blkid >> 8)) & 0xFF];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
93
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
94 crc ^= (osv>>14) ^ (obj>>16) ^ (blkid>>16);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
95
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
96 return (crc);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
97 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
98
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
99 #define DBUF_HASH(os, obj, level, blkid) dbuf_hash(os, obj, level, blkid);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
100
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
101 #define DBUF_EQUAL(dbuf, os, obj, level, blkid) \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
102 ((dbuf)->db.db_object == (obj) && \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
103 (dbuf)->db_objset == (os) && \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
104 (dbuf)->db_level == (level) && \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
105 (dbuf)->db_blkid == (blkid))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
106
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
107 dmu_buf_impl_t *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
108 dbuf_find(dnode_t *dn, uint8_t level, uint64_t blkid)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
109 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
110 dbuf_hash_table_t *h = &dbuf_hash_table;
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9653
diff changeset
111 objset_t *os = dn->dn_objset;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
112 uint64_t obj = dn->dn_object;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
113 uint64_t hv = DBUF_HASH(os, obj, level, blkid);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
114 uint64_t idx = hv & h->hash_table_mask;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
115 dmu_buf_impl_t *db;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
116
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
117 mutex_enter(DBUF_HASH_MUTEX(h, idx));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
118 for (db = h->hash_table[idx]; db != NULL; db = db->db_hash_next) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
119 if (DBUF_EQUAL(db, os, obj, level, blkid)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
120 mutex_enter(&db->db_mtx);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
121 if (db->db_state != DB_EVICTING) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
122 mutex_exit(DBUF_HASH_MUTEX(h, idx));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
123 return (db);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
124 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
125 mutex_exit(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
126 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
127 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
128 mutex_exit(DBUF_HASH_MUTEX(h, idx));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
129 return (NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
130 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
131
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
132 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
133 * Insert an entry into the hash table. If there is already an element
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
134 * equal to elem in the hash table, then the already existing element
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
135 * will be returned and the new element will not be inserted.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
136 * Otherwise returns NULL.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
137 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
138 static dmu_buf_impl_t *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
139 dbuf_hash_insert(dmu_buf_impl_t *db)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
140 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
141 dbuf_hash_table_t *h = &dbuf_hash_table;
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9653
diff changeset
142 objset_t *os = db->db_objset;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
143 uint64_t obj = db->db.db_object;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
144 int level = db->db_level;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
145 uint64_t blkid = db->db_blkid;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
146 uint64_t hv = DBUF_HASH(os, obj, level, blkid);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
147 uint64_t idx = hv & h->hash_table_mask;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
148 dmu_buf_impl_t *dbf;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
149
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
150 mutex_enter(DBUF_HASH_MUTEX(h, idx));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
151 for (dbf = h->hash_table[idx]; dbf != NULL; dbf = dbf->db_hash_next) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
152 if (DBUF_EQUAL(dbf, os, obj, level, blkid)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
153 mutex_enter(&dbf->db_mtx);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
154 if (dbf->db_state != DB_EVICTING) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
155 mutex_exit(DBUF_HASH_MUTEX(h, idx));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
156 return (dbf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
157 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
158 mutex_exit(&dbf->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
159 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
160 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
161
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
162 mutex_enter(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
163 db->db_hash_next = h->hash_table[idx];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
164 h->hash_table[idx] = db;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
165 mutex_exit(DBUF_HASH_MUTEX(h, idx));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
166 atomic_add_64(&dbuf_hash_count, 1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
167
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
168 return (NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
169 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
170
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
171 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
172 * Remove an entry from the hash table. This operation will
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
173 * fail if there are any existing holds on the db.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
174 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
175 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
176 dbuf_hash_remove(dmu_buf_impl_t *db)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
177 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
178 dbuf_hash_table_t *h = &dbuf_hash_table;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
179 uint64_t hv = DBUF_HASH(db->db_objset, db->db.db_object,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
180 db->db_level, db->db_blkid);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
181 uint64_t idx = hv & h->hash_table_mask;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
182 dmu_buf_impl_t *dbf, **dbp;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
183
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
184 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
185 * We musn't hold db_mtx to maintin lock ordering:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
186 * DBUF_HASH_MUTEX > db_mtx.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
187 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
188 ASSERT(refcount_is_zero(&db->db_holds));
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
189 ASSERT(db->db_state == DB_EVICTING);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
190 ASSERT(!MUTEX_HELD(&db->db_mtx));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
191
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
192 mutex_enter(DBUF_HASH_MUTEX(h, idx));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
193 dbp = &h->hash_table[idx];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
194 while ((dbf = *dbp) != db) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
195 dbp = &dbf->db_hash_next;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
196 ASSERT(dbf != NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
197 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
198 *dbp = db->db_hash_next;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
199 db->db_hash_next = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
200 mutex_exit(DBUF_HASH_MUTEX(h, idx));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
201 atomic_add_64(&dbuf_hash_count, -1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
202 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
203
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
204 static arc_evict_func_t dbuf_do_evict;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
205
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
206 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
207 dbuf_evict_user(dmu_buf_impl_t *db)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
208 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
209 ASSERT(MUTEX_HELD(&db->db_mtx));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
210
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
211 if (db->db_level != 0 || db->db_evict_func == NULL)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
212 return;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
213
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
214 if (db->db_user_data_ptr_ptr)
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
215 *db->db_user_data_ptr_ptr = db->db.db_data;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
216 db->db_evict_func(&db->db, db->db_user_ptr);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
217 db->db_user_ptr = NULL;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
218 db->db_user_data_ptr_ptr = NULL;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
219 db->db_evict_func = NULL;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
220 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
221
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
222 boolean_t
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
223 dbuf_is_metadata(dmu_buf_impl_t *db)
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
224 {
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
225 if (db->db_level > 0) {
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
226 return (B_TRUE);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
227 } else {
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
228 boolean_t is_metadata;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
229
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
230 DB_DNODE_ENTER(db);
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13298
diff changeset
231 is_metadata = DMU_OT_IS_METADATA(DB_DNODE(db)->dn_type);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
232 DB_DNODE_EXIT(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
233
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
234 return (is_metadata);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
235 }
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
236 }
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
237
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
238 void
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
239 dbuf_evict(dmu_buf_impl_t *db)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
240 {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
241 ASSERT(MUTEX_HELD(&db->db_mtx));
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
242 ASSERT(db->db_buf == NULL);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
243 ASSERT(db->db_data_pending == NULL);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
244
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
245 dbuf_clear(db);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
246 dbuf_destroy(db);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
247 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
248
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
249 void
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
250 dbuf_init(void)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
251 {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
252 uint64_t hsize = 1ULL << 16;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
253 dbuf_hash_table_t *h = &dbuf_hash_table;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
254 int i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
255
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
256 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
257 * The hash table is big enough to fill all of physical memory
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
258 * with an average 4K block size. The table will take up
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
259 * totalmem*sizeof(void*)/4K (i.e. 2MB/GB with 8-byte pointers).
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
260 */
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
261 while (hsize * 4096 < physmem * PAGESIZE)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
262 hsize <<= 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
263
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
264 retry:
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
265 h->hash_table_mask = hsize - 1;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
266 h->hash_table = kmem_zalloc(hsize * sizeof (void *), KM_NOSLEEP);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
267 if (h->hash_table == NULL) {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
268 /* XXX - we should really return an error instead of assert */
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
269 ASSERT(hsize > (1ULL << 10));
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
270 hsize >>= 1;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
271 goto retry;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
272 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
273
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
274 dbuf_cache = kmem_cache_create("dmu_buf_impl_t",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
275 sizeof (dmu_buf_impl_t),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
276 0, dbuf_cons, dbuf_dest, NULL, NULL, NULL, 0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
277
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
278 for (i = 0; i < DBUF_MUTEXES; i++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
279 mutex_init(&h->hash_mutexes[i], NULL, MUTEX_DEFAULT, NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
280 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
281
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
282 void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
283 dbuf_fini(void)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
284 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
285 dbuf_hash_table_t *h = &dbuf_hash_table;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
286 int i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
287
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
288 for (i = 0; i < DBUF_MUTEXES; i++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
289 mutex_destroy(&h->hash_mutexes[i]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
290 kmem_free(h->hash_table, (h->hash_table_mask + 1) * sizeof (void *));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
291 kmem_cache_destroy(dbuf_cache);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
292 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
293
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
294 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
295 * Other stuff.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
296 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
297
873
adefbfa5f42d 6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents: 789
diff changeset
298 #ifdef ZFS_DEBUG
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
299 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
300 dbuf_verify(dmu_buf_impl_t *db)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
301 {
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
302 dnode_t *dn;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
303 dbuf_dirty_record_t *dr;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
304
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
305 ASSERT(MUTEX_HELD(&db->db_mtx));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
306
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
307 if (!(zfs_flags & ZFS_DEBUG_DBUF_VERIFY))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
308 return;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
309
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
310 ASSERT(db->db_objset != NULL);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
311 DB_DNODE_ENTER(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
312 dn = DB_DNODE(db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
313 if (dn == NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
314 ASSERT(db->db_parent == NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
315 ASSERT(db->db_blkptr == NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
316 } else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
317 ASSERT3U(db->db.db_object, ==, dn->dn_object);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
318 ASSERT3P(db->db_objset, ==, dn->dn_objset);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
319 ASSERT3U(db->db_level, <, dn->dn_nlevels);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
320 ASSERT(db->db_blkid == DMU_BONUS_BLKID ||
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
321 db->db_blkid == DMU_SPILL_BLKID ||
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
322 !list_is_empty(&dn->dn_dbufs));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
323 }
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
324 if (db->db_blkid == DMU_BONUS_BLKID) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
325 ASSERT(dn != NULL);
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
326 ASSERT3U(db->db.db_size, >=, dn->dn_bonuslen);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
327 ASSERT3U(db->db.db_offset, ==, DMU_BONUS_BLKID);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
328 } else if (db->db_blkid == DMU_SPILL_BLKID) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
329 ASSERT(dn != NULL);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
330 ASSERT3U(db->db.db_size, >=, dn->dn_bonuslen);
13765
9410cf539b11 backout 3006: causes 3046 (panics after mounting root)
Richard Lowe <richlowe@richlowe.net>
parents: 13764
diff changeset
331 ASSERT3U(db->db.db_offset, ==, 0);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
332 } else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
333 ASSERT3U(db->db.db_offset, ==, db->db_blkid * db->db.db_size);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
334 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
335
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
336 for (dr = db->db_data_pending; dr != NULL; dr = dr->dr_next)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
337 ASSERT(dr->dr_dbuf == db);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
338
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
339 for (dr = db->db_last_dirty; dr != NULL; dr = dr->dr_next)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
340 ASSERT(dr->dr_dbuf == db);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
341
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7762
diff changeset
342 /*
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7762
diff changeset
343 * We can't assert that db_size matches dn_datablksz because it
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7762
diff changeset
344 * can be momentarily different when another thread is doing
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7762
diff changeset
345 * dnode_set_blksz().
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7762
diff changeset
346 */
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7762
diff changeset
347 if (db->db_level == 0 && db->db.db_object == DMU_META_DNODE_OBJECT) {
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
348 dr = db->db_data_pending;
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7762
diff changeset
349 /*
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7762
diff changeset
350 * It should only be modified in syncing context, so
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7762
diff changeset
351 * make sure we only have one copy of the data.
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7762
diff changeset
352 */
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7762
diff changeset
353 ASSERT(dr == NULL || dr->dt.dl.dr_data == db->db_buf);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
354 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
355
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
356 /* verify db->db_blkptr */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
357 if (db->db_blkptr) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
358 if (db->db_parent == dn->dn_dbuf) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
359 /* db is pointed to by the dnode */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
360 /* ASSERT3U(db->db_blkid, <, dn->dn_nblkptr); */
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9299
diff changeset
361 if (DMU_OBJECT_IS_SPECIAL(db->db.db_object))
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
362 ASSERT(db->db_parent == NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
363 else
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
364 ASSERT(db->db_parent != NULL);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
365 if (db->db_blkid != DMU_SPILL_BLKID)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
366 ASSERT3P(db->db_blkptr, ==,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
367 &dn->dn_phys->dn_blkptr[db->db_blkid]);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
368 } else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
369 /* db is pointed to by an indirect block */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
370 int epb = db->db_parent->db.db_size >> SPA_BLKPTRSHIFT;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
371 ASSERT3U(db->db_parent->db_level, ==, db->db_level+1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
372 ASSERT3U(db->db_parent->db.db_object, ==,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
373 db->db.db_object);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
374 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
375 * dnode_grow_indblksz() can make this fail if we don't
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
376 * have the struct_rwlock. XXX indblksz no longer
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
377 * grows. safe to do this now?
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
378 */
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
379 if (RW_WRITE_HELD(&dn->dn_struct_rwlock)) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
380 ASSERT3P(db->db_blkptr, ==,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
381 ((blkptr_t *)db->db_parent->db.db_data +
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
382 db->db_blkid % epb));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
383 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
384 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
385 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
386 if ((db->db_blkptr == NULL || BP_IS_HOLE(db->db_blkptr)) &&
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
387 (db->db_buf == NULL || db->db_buf->b_data) &&
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
388 db->db.db_data && db->db_blkid != DMU_BONUS_BLKID &&
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
389 db->db_state != DB_FILL && !dn->dn_free_txg) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
390 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
391 * If the blkptr isn't set but they have nonzero data,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
392 * it had better be dirty, otherwise we'll lose that
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
393 * data when we evict this buffer.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
394 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
395 if (db->db_dirtycnt == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
396 uint64_t *buf = db->db.db_data;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
397 int i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
398
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
399 for (i = 0; i < db->db.db_size >> 3; i++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
400 ASSERT(buf[i] == 0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
401 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
402 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
403 }
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
404 DB_DNODE_EXIT(db);
873
adefbfa5f42d 6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents: 789
diff changeset
405 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
406 #endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
407
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
408 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
409 dbuf_update_data(dmu_buf_impl_t *db)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
410 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
411 ASSERT(MUTEX_HELD(&db->db_mtx));
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
412 if (db->db_level == 0 && db->db_user_data_ptr_ptr) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
413 ASSERT(!refcount_is_zero(&db->db_holds));
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
414 *db->db_user_data_ptr_ptr = db->db.db_data;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
415 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
416 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
417
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
418 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
419 dbuf_set_data(dmu_buf_impl_t *db, arc_buf_t *buf)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
420 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
421 ASSERT(MUTEX_HELD(&db->db_mtx));
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
422 ASSERT(db->db_buf == NULL || !arc_has_callback(db->db_buf));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
423 db->db_buf = buf;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
424 if (buf != NULL) {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
425 ASSERT(buf->b_data != NULL);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
426 db->db.db_data = buf->b_data;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
427 if (!arc_released(buf))
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
428 arc_set_callback(buf, dbuf_do_evict, db);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
429 dbuf_update_data(db);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
430 } else {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
431 dbuf_evict_user(db);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
432 db->db.db_data = NULL;
7872
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
433 if (db->db_state != DB_NOFILL)
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
434 db->db_state = DB_UNCACHED;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
435 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
436 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
437
11539
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
438 /*
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
439 * Loan out an arc_buf for read. Return the loaned arc_buf.
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
440 */
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
441 arc_buf_t *
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
442 dbuf_loan_arcbuf(dmu_buf_impl_t *db)
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
443 {
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
444 arc_buf_t *abuf;
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
445
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
446 mutex_enter(&db->db_mtx);
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
447 if (arc_released(db->db_buf) || refcount_count(&db->db_holds) > 1) {
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
448 int blksz = db->db.db_size;
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
449 spa_t *spa;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
450
11539
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
451 mutex_exit(&db->db_mtx);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
452 DB_GET_SPA(&spa, db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
453 abuf = arc_loan_buf(spa, blksz);
11539
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
454 bcopy(db->db.db_data, abuf->b_data, blksz);
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
455 } else {
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
456 abuf = db->db_buf;
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
457 arc_loan_inuse_buf(abuf, db);
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
458 dbuf_set_data(db, NULL);
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
459 mutex_exit(&db->db_mtx);
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
460 }
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
461 return (abuf);
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
462 }
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
463
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
464 uint64_t
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
465 dbuf_whichblock(dnode_t *dn, uint64_t offset)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
466 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
467 if (dn->dn_datablkshift) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
468 return (offset >> dn->dn_datablkshift);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
469 } else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
470 ASSERT3U(offset, <, dn->dn_datablksz);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
471 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
472 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
473 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
474
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
475 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
476 dbuf_read_done(zio_t *zio, arc_buf_t *buf, void *vdb)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
477 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
478 dmu_buf_impl_t *db = vdb;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
479
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
480 mutex_enter(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
481 ASSERT3U(db->db_state, ==, DB_READ);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
482 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
483 * All reads are synchronous, so we must have a hold on the dbuf
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
484 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
485 ASSERT(refcount_count(&db->db_holds) > 0);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
486 ASSERT(db->db_buf == NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
487 ASSERT(db->db.db_data == NULL);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
488 if (db->db_level == 0 && db->db_freed_in_flight) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
489 /* we were freed in flight; disregard any error */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
490 arc_release(buf, db);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
491 bzero(buf->b_data, db->db.db_size);
3093
71525e4187d5 6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents: 2986
diff changeset
492 arc_buf_freeze(buf);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
493 db->db_freed_in_flight = FALSE;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
494 dbuf_set_data(db, buf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
495 db->db_state = DB_CACHED;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
496 } else if (zio == NULL || zio->io_error == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
497 dbuf_set_data(db, buf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
498 db->db_state = DB_CACHED;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
499 } else {
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
500 ASSERT(db->db_blkid != DMU_BONUS_BLKID);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
501 ASSERT3P(db->db_buf, ==, NULL);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
502 VERIFY(arc_buf_remove_ref(buf, db) == 1);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
503 db->db_state = DB_UNCACHED;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
504 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
505 cv_broadcast(&db->db_changed);
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
506 dbuf_rele_and_unlock(db, NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
507 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
508
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
509 static void
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
510 dbuf_read_impl(dmu_buf_impl_t *db, zio_t *zio, uint32_t *flags)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
511 {
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
512 dnode_t *dn;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
513 spa_t *spa;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
514 zbookmark_t zb;
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
515 uint32_t aflags = ARC_NOWAIT;
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
516 arc_buf_t *pbuf;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
517
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
518 DB_DNODE_ENTER(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
519 dn = DB_DNODE(db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
520 ASSERT(!refcount_is_zero(&db->db_holds));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
521 /* We need the struct_rwlock to prevent db_blkptr from changing. */
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
522 ASSERT(RW_LOCK_HELD(&dn->dn_struct_rwlock));
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
523 ASSERT(MUTEX_HELD(&db->db_mtx));
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
524 ASSERT(db->db_state == DB_UNCACHED);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
525 ASSERT(db->db_buf == NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
526
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
527 if (db->db_blkid == DMU_BONUS_BLKID) {
9299
8809e849f63e 6783818 Incremental stream receive panics system
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 8746
diff changeset
528 int bonuslen = MIN(dn->dn_bonuslen, dn->dn_phys->dn_bonuslen);
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
529
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
530 ASSERT3U(bonuslen, <=, db->db.db_size);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
531 db->db.db_data = zio_buf_alloc(DN_MAX_BONUSLEN);
8582
df9361868dbe 6748019 ARC/L2ARC metadata accounting for arc_size
Brendan Gregg - Sun Microsystems <Brendan.Gregg@Sun.COM>
parents: 7872
diff changeset
532 arc_space_consume(DN_MAX_BONUSLEN, ARC_SPACE_OTHER);
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
533 if (bonuslen < DN_MAX_BONUSLEN)
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
534 bzero(db->db.db_data, DN_MAX_BONUSLEN);
9299
8809e849f63e 6783818 Incremental stream receive panics system
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 8746
diff changeset
535 if (bonuslen)
8809e849f63e 6783818 Incremental stream receive panics system
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 8746
diff changeset
536 bcopy(DN_BONUS(dn->dn_phys), db->db.db_data, bonuslen);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
537 DB_DNODE_EXIT(db);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
538 dbuf_update_data(db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
539 db->db_state = DB_CACHED;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
540 mutex_exit(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
541 return;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
542 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
543
7385
f69ff8507427 6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7332
diff changeset
544 /*
f69ff8507427 6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7332
diff changeset
545 * Recheck BP_IS_HOLE() after dnode_block_freed() in case dnode_sync()
f69ff8507427 6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7332
diff changeset
546 * processes the delete record and clears the bp while we are waiting
f69ff8507427 6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7332
diff changeset
547 * for the dn_mtx (resulting in a "no" from block_freed).
f69ff8507427 6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7332
diff changeset
548 */
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
549 if (db->db_blkptr == NULL || BP_IS_HOLE(db->db_blkptr) ||
7385
f69ff8507427 6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7332
diff changeset
550 (db->db_level == 0 && (dnode_block_freed(dn, db->db_blkid) ||
f69ff8507427 6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7332
diff changeset
551 BP_IS_HOLE(db->db_blkptr)))) {
3290
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 3093
diff changeset
552 arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db);
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 3093
diff changeset
553
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
554 dbuf_set_data(db, arc_buf_alloc(dn->dn_objset->os_spa,
3290
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 3093
diff changeset
555 db->db.db_size, db, type));
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
556 DB_DNODE_EXIT(db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
557 bzero(db->db.db_data, db->db.db_size);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
558 db->db_state = DB_CACHED;
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
559 *flags |= DB_RF_CACHED;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
560 mutex_exit(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
561 return;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
562 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
563
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
564 spa = dn->dn_objset->os_spa;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
565 DB_DNODE_EXIT(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
566
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
567 db->db_state = DB_READ;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
568 mutex_exit(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
569
7237
f47d41541b14 PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents: 7046
diff changeset
570 if (DBUF_IS_L2CACHEABLE(db))
f47d41541b14 PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents: 7046
diff changeset
571 aflags |= ARC_L2CACHE;
f47d41541b14 PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents: 7046
diff changeset
572
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
573 SET_BOOKMARK(&zb, db->db_objset->os_dsl_dataset ?
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
574 db->db_objset->os_dsl_dataset->ds_object : DMU_META_OBJSET,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
575 db->db.db_object, db->db_level, db->db_blkid);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
576
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
577 dbuf_add_ref(db, NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
578 /* ZIO_FLAG_CANFAIL callers have to check the parent zio's error */
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
579
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
580 if (db->db_parent)
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
581 pbuf = db->db_parent->db_buf;
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
582 else
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
583 pbuf = db->db_objset->os_phys_buf;
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
584
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
585 (void) dsl_read(zio, spa, db->db_blkptr, pbuf,
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
586 dbuf_read_done, db, ZIO_PRIORITY_SYNC_READ,
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
587 (*flags & DB_RF_CANFAIL) ? ZIO_FLAG_CANFAIL : ZIO_FLAG_MUSTSUCCEED,
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
588 &aflags, &zb);
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
589 if (aflags & ARC_CACHED)
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
590 *flags |= DB_RF_CACHED;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
591 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
592
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
593 int
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
594 dbuf_read(dmu_buf_impl_t *db, zio_t *zio, uint32_t flags)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
595 {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
596 int err = 0;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
597 int havepzio = (zio != NULL);
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
598 int prefetch;
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
599 dnode_t *dn;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
600
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
601 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
602 * We don't have to hold the mutex to check db_state because it
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
603 * can't be freed while we have a hold on the buffer.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
604 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
605 ASSERT(!refcount_is_zero(&db->db_holds));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
606
7872
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
607 if (db->db_state == DB_NOFILL)
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
608 return (EIO);
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
609
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
610 DB_DNODE_ENTER(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
611 dn = DB_DNODE(db);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
612 if ((flags & DB_RF_HAVESTRUCT) == 0)
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
613 rw_enter(&dn->dn_struct_rwlock, RW_READER);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
614
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
615 prefetch = db->db_level == 0 && db->db_blkid != DMU_BONUS_BLKID &&
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
616 (flags & DB_RF_NOPREFETCH) == 0 && dn != NULL &&
7237
f47d41541b14 PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents: 7046
diff changeset
617 DBUF_IS_CACHEABLE(db);
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
618
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
619 mutex_enter(&db->db_mtx);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
620 if (db->db_state == DB_CACHED) {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
621 mutex_exit(&db->db_mtx);
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
622 if (prefetch)
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
623 dmu_zfetch(&dn->dn_zfetch, db->db.db_offset,
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
624 db->db.db_size, TRUE);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
625 if ((flags & DB_RF_HAVESTRUCT) == 0)
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
626 rw_exit(&dn->dn_struct_rwlock);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
627 DB_DNODE_EXIT(db);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
628 } else if (db->db_state == DB_UNCACHED) {
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
629 spa_t *spa = dn->dn_objset->os_spa;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
630
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
631 if (zio == NULL)
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
632 zio = zio_root(spa, NULL, NULL, ZIO_FLAG_CANFAIL);
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
633 dbuf_read_impl(db, zio, &flags);
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
634
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
635 /* dbuf_read_impl has dropped db_mtx for us */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
636
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
637 if (prefetch)
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
638 dmu_zfetch(&dn->dn_zfetch, db->db.db_offset,
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
639 db->db.db_size, flags & DB_RF_CACHED);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
640
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
641 if ((flags & DB_RF_HAVESTRUCT) == 0)
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
642 rw_exit(&dn->dn_struct_rwlock);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
643 DB_DNODE_EXIT(db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
644
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
645 if (!havepzio)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
646 err = zio_wait(zio);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
647 } else {
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
648 mutex_exit(&db->db_mtx);
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
649 if (prefetch)
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
650 dmu_zfetch(&dn->dn_zfetch, db->db.db_offset,
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
651 db->db.db_size, TRUE);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
652 if ((flags & DB_RF_HAVESTRUCT) == 0)
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
653 rw_exit(&dn->dn_struct_rwlock);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
654 DB_DNODE_EXIT(db);
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
655
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
656 mutex_enter(&db->db_mtx);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
657 if ((flags & DB_RF_NEVERWAIT) == 0) {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
658 while (db->db_state == DB_READ ||
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
659 db->db_state == DB_FILL) {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
660 ASSERT(db->db_state == DB_READ ||
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
661 (flags & DB_RF_HAVESTRUCT) == 0);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
662 cv_wait(&db->db_changed, &db->db_mtx);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
663 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
664 if (db->db_state == DB_UNCACHED)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
665 err = EIO;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
666 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
667 mutex_exit(&db->db_mtx);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
668 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
669
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
670 ASSERT(err || havepzio || db->db_state == DB_CACHED);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
671 return (err);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
672 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
673
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
674 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
675 dbuf_noread(dmu_buf_impl_t *db)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
676 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
677 ASSERT(!refcount_is_zero(&db->db_holds));
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
678 ASSERT(db->db_blkid != DMU_BONUS_BLKID);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
679 mutex_enter(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
680 while (db->db_state == DB_READ || db->db_state == DB_FILL)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
681 cv_wait(&db->db_changed, &db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
682 if (db->db_state == DB_UNCACHED) {
3290
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 3093
diff changeset
683 arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
684 spa_t *spa;
3290
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 3093
diff changeset
685
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
686 ASSERT(db->db_buf == NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
687 ASSERT(db->db.db_data == NULL);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
688 DB_GET_SPA(&spa, db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
689 dbuf_set_data(db, arc_buf_alloc(spa, db->db.db_size, db, type));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
690 db->db_state = DB_FILL;
7872
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
691 } else if (db->db_state == DB_NOFILL) {
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
692 dbuf_set_data(db, NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
693 } else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
694 ASSERT3U(db->db_state, ==, DB_CACHED);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
695 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
696 mutex_exit(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
697 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
698
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
699 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
700 * This is our just-in-time copy function. It makes a copy of
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
701 * buffers, that have been modified in a previous transaction
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
702 * group, before we modify them in the current active group.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
703 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
704 * This function is used in two places: when we are dirtying a
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
705 * buffer for the first time in a txg, and when we are freeing
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
706 * a range in a dnode that includes this buffer.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
707 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
708 * Note that when we are called from dbuf_free_range() we do
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
709 * not put a hold on the buffer, we just traverse the active
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
710 * dbuf list for the dnode.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
711 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
712 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
713 dbuf_fix_old_data(dmu_buf_impl_t *db, uint64_t txg)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
714 {
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
715 dbuf_dirty_record_t *dr = db->db_last_dirty;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
716
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
717 ASSERT(MUTEX_HELD(&db->db_mtx));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
718 ASSERT(db->db.db_data != NULL);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
719 ASSERT(db->db_level == 0);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
720 ASSERT(db->db.db_object != DMU_META_DNODE_OBJECT);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
721
3711
2226ffbe7873 6526196 ZFS: assertion failed: zp->z_phys->zp_links > zp_is_dir
maybee
parents: 3689
diff changeset
722 if (dr == NULL ||
2226ffbe7873 6526196 ZFS: assertion failed: zp->z_phys->zp_links > zp_is_dir
maybee
parents: 3689
diff changeset
723 (dr->dt.dl.dr_data !=
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
724 ((db->db_blkid == DMU_BONUS_BLKID) ? db->db.db_data : db->db_buf)))
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
725 return;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
726
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
727 /*
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
728 * If the last dirty record for this dbuf has not yet synced
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
729 * and its referencing the dbuf data, either:
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
730 * reset the reference to point to a new copy,
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
731 * or (if there a no active holders)
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
732 * just null out the current db_data pointer.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
733 */
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
734 ASSERT(dr->dr_txg >= txg - 2);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
735 if (db->db_blkid == DMU_BONUS_BLKID) {
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
736 /* Note that the data bufs here are zio_bufs */
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
737 dr->dt.dl.dr_data = zio_buf_alloc(DN_MAX_BONUSLEN);
8582
df9361868dbe 6748019 ARC/L2ARC metadata accounting for arc_size
Brendan Gregg - Sun Microsystems <Brendan.Gregg@Sun.COM>
parents: 7872
diff changeset
738 arc_space_consume(DN_MAX_BONUSLEN, ARC_SPACE_OTHER);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
739 bcopy(db->db.db_data, dr->dt.dl.dr_data, DN_MAX_BONUSLEN);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
740 } else if (refcount_count(&db->db_holds) > db->db_dirtycnt) {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
741 int size = db->db.db_size;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
742 arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
743 spa_t *spa;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
744
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
745 DB_GET_SPA(&spa, db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
746 dr->dt.dl.dr_data = arc_buf_alloc(spa, size, db, type);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
747 bcopy(db->db.db_data, dr->dt.dl.dr_data->b_data, size);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
748 } else {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
749 dbuf_set_data(db, NULL);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
750 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
751 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
752
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
753 void
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
754 dbuf_unoverride(dbuf_dirty_record_t *dr)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
755 {
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
756 dmu_buf_impl_t *db = dr->dr_dbuf;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
757 blkptr_t *bp = &dr->dt.dl.dr_overridden_by;
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
758 uint64_t txg = dr->dr_txg;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
759
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
760 ASSERT(MUTEX_HELD(&db->db_mtx));
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
761 ASSERT(dr->dt.dl.dr_override_state != DR_IN_DMU_SYNC);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
762 ASSERT(db->db_level == 0);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
763
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
764 if (db->db_blkid == DMU_BONUS_BLKID ||
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
765 dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN)
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
766 return;
2237
45affe88ed99 6416482 filebench oltp workload hangs in zfs
maybee
parents: 2082
diff changeset
767
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
768 ASSERT(db->db_data_pending != dr);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
769
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
770 /* free this block */
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
771 if (!BP_IS_HOLE(bp)) {
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
772 spa_t *spa;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
773
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
774 DB_GET_SPA(&spa, db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
775 zio_free(spa, txg, bp);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
776 }
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
777 dr->dt.dl.dr_override_state = DR_NOT_OVERRIDDEN;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
778 /*
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
779 * Release the already-written buffer, so we leave it in
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
780 * a consistent dirty state. Note that all callers are
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
781 * modifying the buffer, so they will immediately do
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
782 * another (redundant) arc_release(). Therefore, leave
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
783 * the buf thawed to save the effort of freezing &
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
784 * immediately re-thawing it.
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
785 */
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
786 arc_release(dr->dt.dl.dr_data, db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
787 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
788
6992
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
789 /*
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
790 * Evict (if its unreferenced) or clear (if its referenced) any level-0
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
791 * data blocks in the free range, so that any future readers will find
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
792 * empty blocks. Also, if we happen accross any level-1 dbufs in the
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
793 * range that have not already been marked dirty, mark them dirty so
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
794 * they stay in memory.
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
795 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
796 void
6992
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
797 dbuf_free_range(dnode_t *dn, uint64_t start, uint64_t end, dmu_tx_t *tx)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
798 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
799 dmu_buf_impl_t *db, *db_next;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
800 uint64_t txg = tx->tx_txg;
6992
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
801 int epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
802 uint64_t first_l1 = start >> epbs;
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
803 uint64_t last_l1 = end >> epbs;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
804
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
805 if (end > dn->dn_maxblkid && (end != DMU_SPILL_BLKID)) {
6992
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
806 end = dn->dn_maxblkid;
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
807 last_l1 = end >> epbs;
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
808 }
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
809 dprintf_dnode(dn, "start=%llu end=%llu\n", start, end);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
810 mutex_enter(&dn->dn_dbufs_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
811 for (db = list_head(&dn->dn_dbufs); db; db = db_next) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
812 db_next = list_next(&dn->dn_dbufs, db);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
813 ASSERT(db->db_blkid != DMU_BONUS_BLKID);
6992
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
814
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
815 if (db->db_level == 1 &&
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
816 db->db_blkid >= first_l1 && db->db_blkid <= last_l1) {
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
817 mutex_enter(&db->db_mtx);
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
818 if (db->db_last_dirty &&
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
819 db->db_last_dirty->dr_txg < txg) {
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
820 dbuf_add_ref(db, FTAG);
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
821 mutex_exit(&db->db_mtx);
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
822 dbuf_will_dirty(db, tx);
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
823 dbuf_rele(db, FTAG);
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
824 } else {
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
825 mutex_exit(&db->db_mtx);
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
826 }
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
827 }
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
828
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
829 if (db->db_level != 0)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
830 continue;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
831 dprintf_dbuf(db, "found buf %s\n", "");
6992
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
832 if (db->db_blkid < start || db->db_blkid > end)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
833 continue;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
834
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
835 /* found a level 0 buffer in the range */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
836 if (dbuf_undirty(db, tx))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
837 continue;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
838
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
839 mutex_enter(&db->db_mtx);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
840 if (db->db_state == DB_UNCACHED ||
7872
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
841 db->db_state == DB_NOFILL ||
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
842 db->db_state == DB_EVICTING) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
843 ASSERT(db->db.db_data == NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
844 mutex_exit(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
845 continue;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
846 }
1596
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
847 if (db->db_state == DB_READ || db->db_state == DB_FILL) {
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
848 /* will be handled in dbuf_read_done or dbuf_rele */
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
849 db->db_freed_in_flight = TRUE;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
850 mutex_exit(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
851 continue;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
852 }
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
853 if (refcount_count(&db->db_holds) == 0) {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
854 ASSERT(db->db_buf);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
855 dbuf_clear(db);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
856 continue;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
857 }
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
858 /* The dbuf is referenced */
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
859
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
860 if (db->db_last_dirty != NULL) {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
861 dbuf_dirty_record_t *dr = db->db_last_dirty;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
862
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
863 if (dr->dr_txg == txg) {
2688
12e2ad22b970 6447701 ZFS hangs when iSCSI Target attempts to initialize its backing store
maybee
parents: 2417
diff changeset
864 /*
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
865 * This buffer is "in-use", re-adjust the file
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
866 * size to reflect that this buffer may
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
867 * contain new data when we sync.
2688
12e2ad22b970 6447701 ZFS hangs when iSCSI Target attempts to initialize its backing store
maybee
parents: 2417
diff changeset
868 */
12178
93ec1371f750 6939983 assertion failed: zap_count(os, DMU_USERUSED_OBJECT, &count) != 0||count == 0, in dsl_dataset.c
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11935
diff changeset
869 if (db->db_blkid != DMU_SPILL_BLKID &&
93ec1371f750 6939983 assertion failed: zap_count(os, DMU_USERUSED_OBJECT, &count) != 0||count == 0, in dsl_dataset.c
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11935
diff changeset
870 db->db_blkid > dn->dn_maxblkid)
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
871 dn->dn_maxblkid = db->db_blkid;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
872 dbuf_unoverride(dr);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
873 } else {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
874 /*
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
875 * This dbuf is not dirty in the open context.
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
876 * Either uncache it (if its not referenced in
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
877 * the open context) or reset its contents to
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
878 * empty.
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
879 */
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
880 dbuf_fix_old_data(db, txg);
2688
12e2ad22b970 6447701 ZFS hangs when iSCSI Target attempts to initialize its backing store
maybee
parents: 2417
diff changeset
881 }
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
882 }
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
883 /* clear the contents if its cached */
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
884 if (db->db_state == DB_CACHED) {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
885 ASSERT(db->db.db_data != NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
886 arc_release(db->db_buf, db);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
887 bzero(db->db.db_data, db->db.db_size);
3093
71525e4187d5 6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents: 2986
diff changeset
888 arc_buf_freeze(db->db_buf);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
889 }
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
890
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
891 mutex_exit(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
892 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
893 mutex_exit(&dn->dn_dbufs_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
894 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
895
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
896 static int
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
897 dbuf_block_freeable(dmu_buf_impl_t *db)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
898 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
899 dsl_dataset_t *ds = db->db_objset->os_dsl_dataset;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
900 uint64_t birth_txg = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
901
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
902 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
903 * We don't need any locking to protect db_blkptr:
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
904 * If it's syncing, then db_last_dirty will be set
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
905 * so we'll ignore db_blkptr.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
906 */
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
907 ASSERT(MUTEX_HELD(&db->db_mtx));
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
908 if (db->db_last_dirty)
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
909 birth_txg = db->db_last_dirty->dr_txg;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
910 else if (db->db_blkptr)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
911 birth_txg = db->db_blkptr->blk_birth;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
912
12587
16aef3d16470 6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents: 12450
diff changeset
913 /*
16aef3d16470 6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents: 12450
diff changeset
914 * If we don't exist or are in a snapshot, we can't be freed.
16aef3d16470 6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents: 12450
diff changeset
915 * Don't pass the bp to dsl_dataset_block_freeable() since we
16aef3d16470 6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents: 12450
diff changeset
916 * are holding the db_mtx lock and might deadlock if we are
16aef3d16470 6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents: 12450
diff changeset
917 * prefetching a dedup-ed block.
16aef3d16470 6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents: 12450
diff changeset
918 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
919 if (birth_txg)
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
920 return (ds == NULL ||
12587
16aef3d16470 6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents: 12450
diff changeset
921 dsl_dataset_block_freeable(ds, NULL, birth_txg));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
922 else
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
923 return (FALSE);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
924 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
925
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
926 void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
927 dbuf_new_size(dmu_buf_impl_t *db, int size, dmu_tx_t *tx)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
928 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
929 arc_buf_t *buf, *obuf;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
930 int osize = db->db.db_size;
3290
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 3093
diff changeset
931 arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
932 dnode_t *dn;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
933
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
934 ASSERT(db->db_blkid != DMU_BONUS_BLKID);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
935
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
936 DB_DNODE_ENTER(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
937 dn = DB_DNODE(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
938
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
939 /* XXX does *this* func really need the lock? */
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
940 ASSERT(RW_WRITE_HELD(&dn->dn_struct_rwlock));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
941
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
942 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
943 * This call to dbuf_will_dirty() with the dn_struct_rwlock held
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
944 * is OK, because there can be no other references to the db
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
945 * when we are changing its size, so no concurrent DB_FILL can
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
946 * be happening.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
947 */
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
948 /*
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
949 * XXX we should be doing a dbuf_read, checking the return
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
950 * value and returning that up to our callers
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
951 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
952 dbuf_will_dirty(db, tx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
953
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
954 /* create the data buffer for the new block */
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
955 buf = arc_buf_alloc(dn->dn_objset->os_spa, size, db, type);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
956
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
957 /* copy old block data to the new block */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
958 obuf = db->db_buf;
1491
bdcb30e07e7d 6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents: 1199
diff changeset
959 bcopy(obuf->b_data, buf->b_data, MIN(osize, size));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
960 /* zero the remainder */
1491
bdcb30e07e7d 6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents: 1199
diff changeset
961 if (size > osize)
bdcb30e07e7d 6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents: 1199
diff changeset
962 bzero((uint8_t *)buf->b_data + osize, size - osize);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
963
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
964 mutex_enter(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
965 dbuf_set_data(db, buf);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
966 VERIFY(arc_buf_remove_ref(obuf, db) == 1);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
967 db->db.db_size = size;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
968
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
969 if (db->db_level == 0) {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
970 ASSERT3U(db->db_last_dirty->dr_txg, ==, tx->tx_txg);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
971 db->db_last_dirty->dt.dl.dr_data = buf;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
972 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
973 mutex_exit(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
974
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
975 dnode_willuse_space(dn, size-osize, tx);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
976 DB_DNODE_EXIT(db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
977 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
978
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
979 void
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
980 dbuf_release_bp(dmu_buf_impl_t *db)
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
981 {
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
982 objset_t *os;
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
983 zbookmark_t zb;
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
984
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
985 DB_GET_OBJSET(&os, db);
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
986 ASSERT(dsl_pool_sync_context(dmu_objset_pool(os)));
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
987 ASSERT(arc_released(os->os_phys_buf) ||
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
988 list_link_active(&os->os_dsl_dataset->ds_synced_link));
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
989 ASSERT(db->db_parent == NULL || arc_released(db->db_parent->db_buf));
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
990
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
991 zb.zb_objset = os->os_dsl_dataset ?
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
992 os->os_dsl_dataset->ds_object : 0;
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
993 zb.zb_object = db->db.db_object;
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
994 zb.zb_level = db->db_level;
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
995 zb.zb_blkid = db->db_blkid;
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
996 (void) arc_release_bp(db->db_buf, db,
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
997 db->db_blkptr, os->os_spa, &zb);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
998 }
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
999
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1000 dbuf_dirty_record_t *
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1001 dbuf_dirty(dmu_buf_impl_t *db, dmu_tx_t *tx)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1002 {
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1003 dnode_t *dn;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1004 objset_t *os;
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1005 dbuf_dirty_record_t **drp, *dr;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1006 int drop_struct_lock = FALSE;
7467
4106f22dda16 6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7385
diff changeset
1007 boolean_t do_free_accounting = B_FALSE;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1008 int txgoff = tx->tx_txg & TXG_MASK;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1009
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1010 ASSERT(tx->tx_txg != 0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1011 ASSERT(!refcount_is_zero(&db->db_holds));
873
adefbfa5f42d 6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents: 789
diff changeset
1012 DMU_TX_DIRTY_BUF(tx, db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1013
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1014 DB_DNODE_ENTER(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1015 dn = DB_DNODE(db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1016 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1017 * Shouldn't dirty a regular buffer in syncing context. Private
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1018 * objects may be dirtied in syncing context, but only if they
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1019 * were already pre-dirtied in open context.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1020 */
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1021 ASSERT(!dmu_tx_is_syncing(tx) ||
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1022 BP_IS_HOLE(dn->dn_objset->os_rootbp) ||
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9299
diff changeset
1023 DMU_OBJECT_IS_SPECIAL(dn->dn_object) ||
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9299
diff changeset
1024 dn->dn_objset->os_dsl_dataset == NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1025 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1026 * We make this assert for private objects as well, but after we
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1027 * check if we're already dirty. They are allowed to re-dirty
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1028 * in syncing context.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1029 */
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1030 ASSERT(dn->dn_object == DMU_META_DNODE_OBJECT ||
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1031 dn->dn_dirtyctx == DN_UNDIRTIED || dn->dn_dirtyctx ==
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1032 (dmu_tx_is_syncing(tx) ? DN_DIRTY_SYNC : DN_DIRTY_OPEN));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1033
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1034 mutex_enter(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1035 /*
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1036 * XXX make this true for indirects too? The problem is that
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1037 * transactions created with dmu_tx_create_assigned() from
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1038 * syncing context don't bother holding ahead.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1039 */
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1040 ASSERT(db->db_level != 0 ||
7872
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1041 db->db_state == DB_CACHED || db->db_state == DB_FILL ||
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1042 db->db_state == DB_NOFILL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1043
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1044 mutex_enter(&dn->dn_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1045 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1046 * Don't set dirtyctx to SYNC if we're just modifying this as we
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1047 * initialize the objset.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1048 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1049 if (dn->dn_dirtyctx == DN_UNDIRTIED &&
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1050 !BP_IS_HOLE(dn->dn_objset->os_rootbp)) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1051 dn->dn_dirtyctx =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1052 (dmu_tx_is_syncing(tx) ? DN_DIRTY_SYNC : DN_DIRTY_OPEN);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1053 ASSERT(dn->dn_dirtyctx_firstset == NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1054 dn->dn_dirtyctx_firstset = kmem_alloc(1, KM_SLEEP);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1055 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1056 mutex_exit(&dn->dn_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1057
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1058 if (db->db_blkid == DMU_SPILL_BLKID)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1059 dn->dn_have_spill = B_TRUE;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1060
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1061 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1062 * If this buffer is already dirty, we're done.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1063 */
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1064 drp = &db->db_last_dirty;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1065 ASSERT(*drp == NULL || (*drp)->dr_txg <= tx->tx_txg ||
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1066 db->db.db_object == DMU_META_DNODE_OBJECT);
5370
eb153afce98e 6618868 ASSERT: di->dr_txg == tx->tx_txg (0x148 == 0x147), dbuf.c, line 1088
bonwick
parents: 4944
diff changeset
1067 while ((dr = *drp) != NULL && dr->dr_txg > tx->tx_txg)
eb153afce98e 6618868 ASSERT: di->dr_txg == tx->tx_txg (0x148 == 0x147), dbuf.c, line 1088
bonwick
parents: 4944
diff changeset
1068 drp = &dr->dr_next;
eb153afce98e 6618868 ASSERT: di->dr_txg == tx->tx_txg (0x148 == 0x147), dbuf.c, line 1088
bonwick
parents: 4944
diff changeset
1069 if (dr && dr->dr_txg == tx->tx_txg) {
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1070 DB_DNODE_EXIT(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1071
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1072 if (db->db_level == 0 && db->db_blkid != DMU_BONUS_BLKID) {
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1073 /*
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1074 * If this buffer has already been written out,
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1075 * we now need to reset its state.
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1076 */
5370
eb153afce98e 6618868 ASSERT: di->dr_txg == tx->tx_txg (0x148 == 0x147), dbuf.c, line 1088
bonwick
parents: 4944
diff changeset
1077 dbuf_unoverride(dr);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
1078 if (db->db.db_object != DMU_META_DNODE_OBJECT &&
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
1079 db->db_state != DB_NOFILL)
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1080 arc_buf_thaw(db->db_buf);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1081 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1082 mutex_exit(&db->db_mtx);
5370
eb153afce98e 6618868 ASSERT: di->dr_txg == tx->tx_txg (0x148 == 0x147), dbuf.c, line 1088
bonwick
parents: 4944
diff changeset
1083 return (dr);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1084 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1085
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1086 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1087 * Only valid if not already dirty.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1088 */
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9299
diff changeset
1089 ASSERT(dn->dn_object == 0 ||
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9299
diff changeset
1090 dn->dn_dirtyctx == DN_UNDIRTIED || dn->dn_dirtyctx ==
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1091 (dmu_tx_is_syncing(tx) ? DN_DIRTY_SYNC : DN_DIRTY_OPEN));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1092
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1093 ASSERT3U(dn->dn_nlevels, >, db->db_level);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1094 ASSERT((dn->dn_phys->dn_nlevels == 0 && db->db_level == 0) ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1095 dn->dn_phys->dn_nlevels > db->db_level ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1096 dn->dn_next_nlevels[txgoff] > db->db_level ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1097 dn->dn_next_nlevels[(tx->tx_txg-1) & TXG_MASK] > db->db_level ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1098 dn->dn_next_nlevels[(tx->tx_txg-2) & TXG_MASK] > db->db_level);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1099
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1100 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1101 * We should only be dirtying in syncing context if it's the
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9299
diff changeset
1102 * mos or we're initializing the os or it's a special object.
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9299
diff changeset
1103 * However, we are allowed to dirty in syncing context provided
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9299
diff changeset
1104 * we already dirtied it in open context. Hence we must make
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9299
diff changeset
1105 * this assertion only if we're not already dirty.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1106 */
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1107 os = dn->dn_objset;
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9299
diff changeset
1108 ASSERT(!dmu_tx_is_syncing(tx) || DMU_OBJECT_IS_SPECIAL(dn->dn_object) ||
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9299
diff changeset
1109 os->os_dsl_dataset == NULL || BP_IS_HOLE(os->os_rootbp));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1110 ASSERT(db->db.db_size != 0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1111
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1112 dprintf_dbuf(db, "size=%llx\n", (u_longlong_t)db->db.db_size);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1113
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1114 if (db->db_blkid != DMU_BONUS_BLKID) {
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
1115 /*
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
1116 * Update the accounting.
7467
4106f22dda16 6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7385
diff changeset
1117 * Note: we delay "free accounting" until after we drop
4106f22dda16 6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7385
diff changeset
1118 * the db_mtx. This keeps us from grabbing other locks
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
1119 * (and possibly deadlocking) in bp_get_dsize() while
7467
4106f22dda16 6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7385
diff changeset
1120 * also holding the db_mtx.
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
1121 */
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
1122 dnode_willuse_space(dn, db->db.db_size, tx);
7467
4106f22dda16 6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7385
diff changeset
1123 do_free_accounting = dbuf_block_freeable(db);
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
1124 }
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
1125
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1126 /*
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1127 * If this buffer is dirty in an old transaction group we need
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1128 * to make a copy of it so that the changes we make in this
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1129 * transaction group won't leak out when we sync the older txg.
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1130 */
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1131 dr = kmem_zalloc(sizeof (dbuf_dirty_record_t), KM_SLEEP);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1132 if (db->db_level == 0) {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1133 void *data_old = db->db_buf;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1134
7872
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1135 if (db->db_state != DB_NOFILL) {
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1136 if (db->db_blkid == DMU_BONUS_BLKID) {
7872
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1137 dbuf_fix_old_data(db, tx->tx_txg);
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1138 data_old = db->db.db_data;
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1139 } else if (db->db.db_object != DMU_META_DNODE_OBJECT) {
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1140 /*
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1141 * Release the data buffer from the cache so
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1142 * that we can modify it without impacting
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1143 * possible other users of this cached data
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1144 * block. Note that indirect blocks and
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1145 * private objects are not released until the
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1146 * syncing state (since they are only modified
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1147 * then).
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1148 */
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1149 arc_release(db->db_buf, db);
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1150 dbuf_fix_old_data(db, tx->tx_txg);
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1151 data_old = db->db_buf;
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1152 }
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1153 ASSERT(data_old != NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1154 }
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1155 dr->dt.dl.dr_data = data_old;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1156 } else {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1157 mutex_init(&dr->dt.di.dr_mtx, NULL, MUTEX_DEFAULT, NULL);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1158 list_create(&dr->dt.di.dr_children,
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1159 sizeof (dbuf_dirty_record_t),
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1160 offsetof(dbuf_dirty_record_t, dr_dirty_node));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1161 }
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1162 dr->dr_dbuf = db;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1163 dr->dr_txg = tx->tx_txg;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1164 dr->dr_next = *drp;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1165 *drp = dr;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1166
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1167 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1168 * We could have been freed_in_flight between the dbuf_noread
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1169 * and dbuf_dirty. We win, as though the dbuf_noread() had
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1170 * happened after the free.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1171 */
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1172 if (db->db_level == 0 && db->db_blkid != DMU_BONUS_BLKID &&
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1173 db->db_blkid != DMU_SPILL_BLKID) {
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1174 mutex_enter(&dn->dn_mtx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1175 dnode_clear_range(dn, db->db_blkid, 1, tx);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1176 mutex_exit(&dn->dn_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1177 db->db_freed_in_flight = FALSE;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1178 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1179
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1180 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1181 * This buffer is now part of this txg
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1182 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1183 dbuf_add_ref(db, (void *)(uintptr_t)tx->tx_txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1184 db->db_dirtycnt += 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1185 ASSERT3U(db->db_dirtycnt, <=, 3);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1186
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1187 mutex_exit(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1188
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1189 if (db->db_blkid == DMU_BONUS_BLKID ||
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1190 db->db_blkid == DMU_SPILL_BLKID) {
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1191 mutex_enter(&dn->dn_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1192 ASSERT(!list_link_active(&dr->dr_dirty_node));
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1193 list_insert_tail(&dn->dn_dirty_records[txgoff], dr);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1194 mutex_exit(&dn->dn_mtx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1195 dnode_setdirty(dn, tx);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1196 DB_DNODE_EXIT(db);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1197 return (dr);
7467
4106f22dda16 6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7385
diff changeset
1198 } else if (do_free_accounting) {
4106f22dda16 6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7385
diff changeset
1199 blkptr_t *bp = db->db_blkptr;
4106f22dda16 6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7385
diff changeset
1200 int64_t willfree = (bp && !BP_IS_HOLE(bp)) ?
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
1201 bp_get_dsize(os->os_spa, bp) : db->db.db_size;
7467
4106f22dda16 6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7385
diff changeset
1202 /*
4106f22dda16 6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7385
diff changeset
1203 * This is only a guess -- if the dbuf is dirty
4106f22dda16 6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7385
diff changeset
1204 * in a previous txg, we don't know how much
4106f22dda16 6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7385
diff changeset
1205 * space it will use on disk yet. We should
4106f22dda16 6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7385
diff changeset
1206 * really have the struct_rwlock to access
4106f22dda16 6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7385
diff changeset
1207 * db_blkptr, but since this is just a guess,
4106f22dda16 6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7385
diff changeset
1208 * it's OK if we get an odd answer.
4106f22dda16 6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7385
diff changeset
1209 */
12587
16aef3d16470 6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents: 12450
diff changeset
1210 ddt_prefetch(os->os_spa, bp);
7467
4106f22dda16 6737405 ZFS deadlock when trying to add storage
Mark Maybee <Mark.Maybee@Sun.COM>
parents: 7385
diff changeset
1211 dnode_willuse_space(dn, -willfree, tx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1212 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1213
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1214 if (!RW_WRITE_HELD(&dn->dn_struct_rwlock)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1215 rw_enter(&dn->dn_struct_rwlock, RW_READER);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1216 drop_struct_lock = TRUE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1217 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1218
7332
396f25bd1f34 6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents: 7237
diff changeset
1219 if (db->db_level == 0) {
396f25bd1f34 6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents: 7237
diff changeset
1220 dnode_new_blkid(dn, db->db_blkid, tx, drop_struct_lock);
396f25bd1f34 6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents: 7237
diff changeset
1221 ASSERT(dn->dn_maxblkid >= db->db_blkid);
396f25bd1f34 6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents: 7237
diff changeset
1222 }
396f25bd1f34 6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents: 7237
diff changeset
1223
2688
12e2ad22b970 6447701 ZFS hangs when iSCSI Target attempts to initialize its backing store
maybee
parents: 2417
diff changeset
1224 if (db->db_level+1 < dn->dn_nlevels) {
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1225 dmu_buf_impl_t *parent = db->db_parent;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1226 dbuf_dirty_record_t *di;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1227 int parent_held = FALSE;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1228
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1229 if (db->db_parent == NULL || db->db_parent == dn->dn_dbuf) {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1230 int epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1231
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1232 parent = dbuf_hold_level(dn, db->db_level+1,
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1233 db->db_blkid >> epbs, FTAG);
12411
3e9af067a727 6911391 panic in dmu_tx_count_write()
John Harres <John.Harres@Sun.COM>
parents: 12296
diff changeset
1234 ASSERT(parent != NULL);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1235 parent_held = TRUE;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1236 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1237 if (drop_struct_lock)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1238 rw_exit(&dn->dn_struct_rwlock);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1239 ASSERT3U(db->db_level+1, ==, parent->db_level);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1240 di = dbuf_dirty(parent, tx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1241 if (parent_held)
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1242 dbuf_rele(parent, FTAG);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1243
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1244 mutex_enter(&db->db_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1245 /* possible race with dbuf_undirty() */
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1246 if (db->db_last_dirty == dr ||
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1247 dn->dn_object == DMU_META_DNODE_OBJECT) {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1248 mutex_enter(&di->dt.di.dr_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1249 ASSERT3U(di->dr_txg, ==, tx->tx_txg);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1250 ASSERT(!list_link_active(&dr->dr_dirty_node));
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1251 list_insert_tail(&di->dt.di.dr_children, dr);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1252 mutex_exit(&di->dt.di.dr_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1253 dr->dr_parent = di;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1254 }
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1255 mutex_exit(&db->db_mtx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1256 } else {
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1257 ASSERT(db->db_level+1 == dn->dn_nlevels);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1258 ASSERT(db->db_blkid < dn->dn_nblkptr);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1259 ASSERT(db->db_parent == NULL || db->db_parent == dn->dn_dbuf);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1260 mutex_enter(&dn->dn_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1261 ASSERT(!list_link_active(&dr->dr_dirty_node));
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1262 list_insert_tail(&dn->dn_dirty_records[txgoff], dr);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1263 mutex_exit(&dn->dn_mtx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1264 if (drop_struct_lock)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1265 rw_exit(&dn->dn_struct_rwlock);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1266 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1267
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1268 dnode_setdirty(dn, tx);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1269 DB_DNODE_EXIT(db);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1270 return (dr);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1271 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1272
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1273 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1274 dbuf_undirty(dmu_buf_impl_t *db, dmu_tx_t *tx)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1275 {
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1276 dnode_t *dn;
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1277 uint64_t txg = tx->tx_txg;
5688
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 5370
diff changeset
1278 dbuf_dirty_record_t *dr, **drp;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1279
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1280 ASSERT(txg != 0);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1281 ASSERT(db->db_blkid != DMU_BONUS_BLKID);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1282
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1283 mutex_enter(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1284 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1285 * If this buffer is not dirty, we're done.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1286 */
5688
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 5370
diff changeset
1287 for (drp = &db->db_last_dirty; (dr = *drp) != NULL; drp = &dr->dr_next)
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1288 if (dr->dr_txg <= txg)
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1289 break;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1290 if (dr == NULL || dr->dr_txg < txg) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1291 mutex_exit(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1292 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1293 }
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1294 ASSERT(dr->dr_txg == txg);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
1295 ASSERT(dr->dr_dbuf == db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1296
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1297 DB_DNODE_ENTER(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1298 dn = DB_DNODE(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1299
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1300 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1301 * If this buffer is currently held, we cannot undirty
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1302 * it, since one of the current holders may be in the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1303 * middle of an update. Note that users of dbuf_undirty()
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1304 * should not place a hold on the dbuf before the call.
13298
c234f438c0d3 764 panic in zfs:dbuf_sync_list
Gordon Ross <gwr@nexenta.com>
parents: 13026
diff changeset
1305 * Also note: we can get here with a spill block, so
c234f438c0d3 764 panic in zfs:dbuf_sync_list
Gordon Ross <gwr@nexenta.com>
parents: 13026
diff changeset
1306 * test for that similar to how dbuf_dirty does.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1307 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1308 if (refcount_count(&db->db_holds) > db->db_dirtycnt) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1309 mutex_exit(&db->db_mtx);
2688
12e2ad22b970 6447701 ZFS hangs when iSCSI Target attempts to initialize its backing store
maybee
parents: 2417
diff changeset
1310 /* Make sure we don't toss this buffer at sync phase */
13298
c234f438c0d3 764 panic in zfs:dbuf_sync_list
Gordon Ross <gwr@nexenta.com>
parents: 13026
diff changeset
1311 if (db->db_blkid != DMU_SPILL_BLKID) {
c234f438c0d3 764 panic in zfs:dbuf_sync_list
Gordon Ross <gwr@nexenta.com>
parents: 13026
diff changeset
1312 mutex_enter(&dn->dn_mtx);
c234f438c0d3 764 panic in zfs:dbuf_sync_list
Gordon Ross <gwr@nexenta.com>
parents: 13026
diff changeset
1313 dnode_clear_range(dn, db->db_blkid, 1, tx);
c234f438c0d3 764 panic in zfs:dbuf_sync_list
Gordon Ross <gwr@nexenta.com>
parents: 13026
diff changeset
1314 mutex_exit(&dn->dn_mtx);
c234f438c0d3 764 panic in zfs:dbuf_sync_list
Gordon Ross <gwr@nexenta.com>
parents: 13026
diff changeset
1315 }
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1316 DB_DNODE_EXIT(db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1317 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1318 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1319
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1320 dprintf_dbuf(db, "size=%llx\n", (u_longlong_t)db->db.db_size);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1321
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1322 ASSERT(db->db.db_size != 0);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1323
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1324 /* XXX would be nice to fix up dn_towrite_space[] */
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1325
5688
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 5370
diff changeset
1326 *drp = dr->dr_next;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1327
13298
c234f438c0d3 764 panic in zfs:dbuf_sync_list
Gordon Ross <gwr@nexenta.com>
parents: 13026
diff changeset
1328 /*
c234f438c0d3 764 panic in zfs:dbuf_sync_list
Gordon Ross <gwr@nexenta.com>
parents: 13026
diff changeset
1329 * Note that there are three places in dbuf_dirty()
c234f438c0d3 764 panic in zfs:dbuf_sync_list
Gordon Ross <gwr@nexenta.com>
parents: 13026
diff changeset
1330 * where this dirty record may be put on a list.
c234f438c0d3 764 panic in zfs:dbuf_sync_list
Gordon Ross <gwr@nexenta.com>
parents: 13026
diff changeset
1331 * Make sure to do a list_remove corresponding to
c234f438c0d3 764 panic in zfs:dbuf_sync_list
Gordon Ross <gwr@nexenta.com>
parents: 13026
diff changeset
1332 * every one of those list_insert calls.
c234f438c0d3 764 panic in zfs:dbuf_sync_list
Gordon Ross <gwr@nexenta.com>
parents: 13026
diff changeset
1333 */
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1334 if (dr->dr_parent) {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1335 mutex_enter(&dr->dr_parent->dt.di.dr_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1336 list_remove(&dr->dr_parent->dt.di.dr_children, dr);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1337 mutex_exit(&dr->dr_parent->dt.di.dr_mtx);
13298
c234f438c0d3 764 panic in zfs:dbuf_sync_list
Gordon Ross <gwr@nexenta.com>
parents: 13026
diff changeset
1338 } else if (db->db_blkid == DMU_SPILL_BLKID ||
c234f438c0d3 764 panic in zfs:dbuf_sync_list
Gordon Ross <gwr@nexenta.com>
parents: 13026
diff changeset
1339 db->db_level+1 == dn->dn_nlevels) {
6992
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6245
diff changeset
1340 ASSERT(db->db_blkptr == NULL || db->db_parent == dn->dn_dbuf);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1341 mutex_enter(&dn->dn_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1342 list_remove(&dn->dn_dirty_records[txg & TXG_MASK], dr);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1343 mutex_exit(&dn->dn_mtx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1344 }
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1345 DB_DNODE_EXIT(db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1346
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1347 if (db->db_level == 0) {
7872
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1348 if (db->db_state != DB_NOFILL) {
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1349 dbuf_unoverride(dr);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1350
7872
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1351 ASSERT(db->db_buf != NULL);
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1352 ASSERT(dr->dt.dl.dr_data != NULL);
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1353 if (dr->dt.dl.dr_data != db->db_buf)
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1354 VERIFY(arc_buf_remove_ref(dr->dt.dl.dr_data,
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1355 db) == 1);
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1356 }
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1357 } else {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1358 ASSERT(db->db_buf != NULL);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1359 ASSERT(list_head(&dr->dt.di.dr_children) == NULL);
4831
41ec732c6d9f 6584470 zdb needs to initialize the bpl_lock mutex
gw25295
parents: 4506
diff changeset
1360 mutex_destroy(&dr->dt.di.dr_mtx);
41ec732c6d9f 6584470 zdb needs to initialize the bpl_lock mutex
gw25295
parents: 4506
diff changeset
1361 list_destroy(&dr->dt.di.dr_children);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1362 }
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1363 kmem_free(dr, sizeof (dbuf_dirty_record_t));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1364
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1365 ASSERT(db->db_dirtycnt > 0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1366 db->db_dirtycnt -= 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1367
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1368 if (refcount_remove(&db->db_holds, (void *)(uintptr_t)txg) == 0) {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1369 arc_buf_t *buf = db->db_buf;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1370
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
1371 ASSERT(db->db_state == DB_NOFILL || arc_released(buf));
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1372 dbuf_set_data(db, NULL);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1373 VERIFY(arc_buf_remove_ref(buf, db) == 1);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1374 dbuf_evict(db);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1375 return (1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1376 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1377
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1378 mutex_exit(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1379 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1380 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1381
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1382 #pragma weak dmu_buf_will_dirty = dbuf_will_dirty
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1383 void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1384 dbuf_will_dirty(dmu_buf_impl_t *db, dmu_tx_t *tx)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1385 {
6245
1a2a7cfb9f26 6429205 each zpool needs to monitor its throughput and throttle heavy writers
maybee
parents: 5688
diff changeset
1386 int rf = DB_RF_MUST_SUCCEED | DB_RF_NOPREFETCH;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1387
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1388 ASSERT(tx->tx_txg != 0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1389 ASSERT(!refcount_is_zero(&db->db_holds));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1390
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1391 DB_DNODE_ENTER(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1392 if (RW_WRITE_HELD(&DB_DNODE(db)->dn_struct_rwlock))
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1393 rf |= DB_RF_HAVESTRUCT;
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1394 DB_DNODE_EXIT(db);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1395 (void) dbuf_read(db, NULL, rf);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1396 (void) dbuf_dirty(db, tx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1397 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1398
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1399 void
7872
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1400 dmu_buf_will_not_fill(dmu_buf_t *db_fake, dmu_tx_t *tx)
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1401 {
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1402 dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake;
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1403
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1404 db->db_state = DB_NOFILL;
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1405
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1406 dmu_buf_will_fill(db_fake, tx);
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1407 }
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1408
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1409 void
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1410 dmu_buf_will_fill(dmu_buf_t *db_fake, dmu_tx_t *tx)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1411 {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1412 dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1413
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1414 ASSERT(db->db_blkid != DMU_BONUS_BLKID);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1415 ASSERT(tx->tx_txg != 0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1416 ASSERT(db->db_level == 0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1417 ASSERT(!refcount_is_zero(&db->db_holds));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1418
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1419 ASSERT(db->db.db_object != DMU_META_DNODE_OBJECT ||
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1420 dmu_tx_private_ok(tx));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1421
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1422 dbuf_noread(db);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1423 (void) dbuf_dirty(db, tx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1424 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1425
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1426 #pragma weak dmu_buf_fill_done = dbuf_fill_done
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1427 /* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1428 void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1429 dbuf_fill_done(dmu_buf_impl_t *db, dmu_tx_t *tx)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1430 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1431 mutex_enter(&db->db_mtx);
873
adefbfa5f42d 6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents: 789
diff changeset
1432 DBUF_VERIFY(db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1433
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1434 if (db->db_state == DB_FILL) {
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1435 if (db->db_level == 0 && db->db_freed_in_flight) {
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1436 ASSERT(db->db_blkid != DMU_BONUS_BLKID);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1437 /* we were freed while filling */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1438 /* XXX dbuf_undirty? */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1439 bzero(db->db.db_data, db->db.db_size);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1440 db->db_freed_in_flight = FALSE;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1441 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1442 db->db_state = DB_CACHED;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1443 cv_broadcast(&db->db_changed);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1444 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1445 mutex_exit(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1446 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1447
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1448 /*
9412
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1449 * Directly assign a provided arc buf to a given dbuf if it's not referenced
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1450 * by anybody except our caller. Otherwise copy arcbuf's contents to dbuf.
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1451 */
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1452 void
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1453 dbuf_assign_arcbuf(dmu_buf_impl_t *db, arc_buf_t *buf, dmu_tx_t *tx)
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1454 {
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1455 ASSERT(!refcount_is_zero(&db->db_holds));
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1456 ASSERT(db->db_blkid != DMU_BONUS_BLKID);
9412
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1457 ASSERT(db->db_level == 0);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1458 ASSERT(DBUF_GET_BUFC_TYPE(db) == ARC_BUFC_DATA);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1459 ASSERT(buf != NULL);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1460 ASSERT(arc_buf_size(buf) == db->db.db_size);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1461 ASSERT(tx->tx_txg != 0);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1462
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1463 arc_return_buf(buf, db);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1464 ASSERT(arc_released(buf));
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1465
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1466 mutex_enter(&db->db_mtx);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1467
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1468 while (db->db_state == DB_READ || db->db_state == DB_FILL)
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1469 cv_wait(&db->db_changed, &db->db_mtx);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1470
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1471 ASSERT(db->db_state == DB_CACHED || db->db_state == DB_UNCACHED);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1472
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1473 if (db->db_state == DB_CACHED &&
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1474 refcount_count(&db->db_holds) - 1 > db->db_dirtycnt) {
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1475 mutex_exit(&db->db_mtx);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1476 (void) dbuf_dirty(db, tx);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1477 bcopy(buf->b_data, db->db.db_data, db->db.db_size);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1478 VERIFY(arc_buf_remove_ref(buf, db) == 1);
11539
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
1479 xuio_stat_wbuf_copied();
9412
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1480 return;
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1481 }
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1482
11539
10d35fc3d7fd 6873106 Need a mechanism to share buffers between fs modules
chunli zhang - Sun Microsystems - Irvine United States <Chunli.Zhang@Sun.COM>
parents: 10922
diff changeset
1483 xuio_stat_wbuf_nocopy();
9412
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1484 if (db->db_state == DB_CACHED) {
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1485 dbuf_dirty_record_t *dr = db->db_last_dirty;
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1486
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1487 ASSERT(db->db_buf != NULL);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1488 if (dr != NULL && dr->dr_txg == tx->tx_txg) {
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1489 ASSERT(dr->dt.dl.dr_data == db->db_buf);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1490 if (!arc_released(db->db_buf)) {
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1491 ASSERT(dr->dt.dl.dr_override_state ==
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1492 DR_OVERRIDDEN);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1493 arc_release(db->db_buf, db);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1494 }
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1495 dr->dt.dl.dr_data = buf;
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1496 VERIFY(arc_buf_remove_ref(db->db_buf, db) == 1);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1497 } else if (dr == NULL || dr->dt.dl.dr_data != db->db_buf) {
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1498 arc_release(db->db_buf, db);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1499 VERIFY(arc_buf_remove_ref(db->db_buf, db) == 1);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1500 }
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1501 db->db_buf = NULL;
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1502 }
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1503 ASSERT(db->db_buf == NULL);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1504 dbuf_set_data(db, buf);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1505 db->db_state = DB_FILL;
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1506 mutex_exit(&db->db_mtx);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1507 (void) dbuf_dirty(db, tx);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1508 dbuf_fill_done(db, tx);
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1509 }
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1510
4aefd8704ce0 6717022 ZFS DMU needs zero-copy support
Aleksandr Guzovskiy <Aleksandr.Guzovskiy@Sun.COM>
parents: 9396
diff changeset
1511 /*
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1512 * "Clear" the contents of this dbuf. This will mark the dbuf
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1513 * EVICTING and clear *most* of its references. Unfortunetely,
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1514 * when we are not holding the dn_dbufs_mtx, we can't clear the
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1515 * entry in the dn_dbufs list. We have to wait until dbuf_destroy()
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1516 * in this case. For callers from the DMU we will usually see:
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1517 * dbuf_clear()->arc_buf_evict()->dbuf_do_evict()->dbuf_destroy()
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1518 * For the arc callback, we will usually see:
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1519 * dbuf_do_evict()->dbuf_clear();dbuf_destroy()
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1520 * Sometimes, though, we will get a mix of these two:
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1521 * DMU: dbuf_clear()->arc_buf_evict()
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1522 * ARC: dbuf_do_evict()->dbuf_destroy()
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1523 */
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1524 void
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1525 dbuf_clear(dmu_buf_impl_t *db)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1526 {
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1527 dnode_t *dn;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1528 dmu_buf_impl_t *parent = db->db_parent;
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1529 dmu_buf_impl_t *dndb;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1530 int dbuf_gone = FALSE;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1531
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1532 ASSERT(MUTEX_HELD(&db->db_mtx));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1533 ASSERT(refcount_is_zero(&db->db_holds));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1534
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1535 dbuf_evict_user(db);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1536
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1537 if (db->db_state == DB_CACHED) {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1538 ASSERT(db->db.db_data != NULL);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1539 if (db->db_blkid == DMU_BONUS_BLKID) {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1540 zio_buf_free(db->db.db_data, DN_MAX_BONUSLEN);
8582
df9361868dbe 6748019 ARC/L2ARC metadata accounting for arc_size
Brendan Gregg - Sun Microsystems <Brendan.Gregg@Sun.COM>
parents: 7872
diff changeset
1541 arc_space_return(DN_MAX_BONUSLEN, ARC_SPACE_OTHER);
4309
3dfde0f4662d 6542676 ARC needs to track meta-data memory overhead
maybee
parents: 3897
diff changeset
1542 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1543 db->db.db_data = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1544 db->db_state = DB_UNCACHED;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1545 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1546
7872
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
1547 ASSERT(db->db_state == DB_UNCACHED || db->db_state == DB_NOFILL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1548 ASSERT(db->db_data_pending == NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1549
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1550 db->db_state = DB_EVICTING;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1551 db->db_blkptr = NULL;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1552
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1553 DB_DNODE_ENTER(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1554 dn = DB_DNODE(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1555 dndb = dn->dn_dbuf;
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1556 if (db->db_blkid != DMU_BONUS_BLKID && MUTEX_HELD(&dn->dn_dbufs_mtx)) {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1557 list_remove(&dn->dn_dbufs, db);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1558 (void) atomic_dec_32_nv(&dn->dn_dbufs_count);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1559 membar_producer();
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1560 DB_DNODE_EXIT(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1561 /*
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1562 * Decrementing the dbuf count means that the hold corresponding
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1563 * to the removed dbuf is no longer discounted in dnode_move(),
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1564 * so the dnode cannot be moved until after we release the hold.
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1565 * The membar_producer() ensures visibility of the decremented
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1566 * value in dnode_move(), since DB_DNODE_EXIT doesn't actually
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1567 * release any lock.
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1568 */
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1569 dnode_rele(dn, db);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1570 db->db_dnode_handle = NULL;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1571 } else {
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1572 DB_DNODE_EXIT(db);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1573 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1574
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1575 if (db->db_buf)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1576 dbuf_gone = arc_buf_evict(db->db_buf);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1577
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1578 if (!dbuf_gone)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1579 mutex_exit(&db->db_mtx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1580
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1581 /*
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1582 * If this dbuf is referenced from an indirect dbuf,
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1583 * decrement the ref count on the indirect dbuf.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1584 */
1596
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1585 if (parent && parent != dndb)
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1586 dbuf_rele(parent, db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1587 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1588
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1589 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1590 dbuf_findbp(dnode_t *dn, int level, uint64_t blkid, int fail_sparse,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1591 dmu_buf_impl_t **parentp, blkptr_t **bpp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1592 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1593 int nlevels, epbs;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1594
2417
694d5de97348 6444346 zfs promote fails in zone
ahrens
parents: 2391
diff changeset
1595 *parentp = NULL;
694d5de97348 6444346 zfs promote fails in zone
ahrens
parents: 2391
diff changeset
1596 *bpp = NULL;
694d5de97348 6444346 zfs promote fails in zone
ahrens
parents: 2391
diff changeset
1597
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1598 ASSERT(blkid != DMU_BONUS_BLKID);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1599
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1600 if (blkid == DMU_SPILL_BLKID) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1601 mutex_enter(&dn->dn_mtx);
12178
93ec1371f750 6939983 assertion failed: zap_count(os, DMU_USERUSED_OBJECT, &count) != 0||count == 0, in dsl_dataset.c
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11935
diff changeset
1602 if (dn->dn_have_spill &&
93ec1371f750 6939983 assertion failed: zap_count(os, DMU_USERUSED_OBJECT, &count) != 0||count == 0, in dsl_dataset.c
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11935
diff changeset
1603 (dn->dn_phys->dn_flags & DNODE_FLAG_SPILL_BLKPTR))
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1604 *bpp = &dn->dn_phys->dn_spill;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1605 else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1606 *bpp = NULL;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1607 dbuf_add_ref(dn->dn_dbuf, NULL);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1608 *parentp = dn->dn_dbuf;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1609 mutex_exit(&dn->dn_mtx);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1610 return (0);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1611 }
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1612
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1613 if (dn->dn_phys->dn_nlevels == 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1614 nlevels = 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1615 else
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1616 nlevels = dn->dn_phys->dn_nlevels;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1617
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1618 epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1619
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1620 ASSERT3U(level * epbs, <, 64);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1621 ASSERT(RW_LOCK_HELD(&dn->dn_struct_rwlock));
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1622 if (level >= nlevels ||
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1623 (blkid > (dn->dn_phys->dn_maxblkid >> (level * epbs)))) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1624 /* the buffer has no parent yet */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1625 return (ENOENT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1626 } else if (level < nlevels-1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1627 /* this block is referenced from an indirect block */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1628 int err = dbuf_hold_impl(dn, level+1,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1629 blkid >> epbs, fail_sparse, NULL, parentp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1630 if (err)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1631 return (err);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1632 err = dbuf_read(*parentp, NULL,
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1633 (DB_RF_HAVESTRUCT | DB_RF_NOPREFETCH | DB_RF_CANFAIL));
1596
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1634 if (err) {
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1635 dbuf_rele(*parentp, NULL);
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1636 *parentp = NULL;
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1637 return (err);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1638 }
1596
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1639 *bpp = ((blkptr_t *)(*parentp)->db.db_data) +
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1640 (blkid & ((1ULL << epbs) - 1));
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1641 return (0);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1642 } else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1643 /* the block is referenced from the dnode */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1644 ASSERT3U(level, ==, nlevels-1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1645 ASSERT(dn->dn_phys->dn_nblkptr == 0 ||
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1646 blkid < dn->dn_phys->dn_nblkptr);
1596
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1647 if (dn->dn_dbuf) {
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1648 dbuf_add_ref(dn->dn_dbuf, NULL);
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1649 *parentp = dn->dn_dbuf;
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1650 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1651 *bpp = &dn->dn_phys->dn_blkptr[blkid];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1652 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1653 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1654 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1655
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1656 static dmu_buf_impl_t *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1657 dbuf_create(dnode_t *dn, uint8_t level, uint64_t blkid,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1658 dmu_buf_impl_t *parent, blkptr_t *blkptr)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1659 {
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9653
diff changeset
1660 objset_t *os = dn->dn_objset;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1661 dmu_buf_impl_t *db, *odb;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1662
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1663 ASSERT(RW_LOCK_HELD(&dn->dn_struct_rwlock));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1664 ASSERT(dn->dn_type != DMU_OT_NONE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1665
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1666 db = kmem_cache_alloc(dbuf_cache, KM_SLEEP);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1667
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1668 db->db_objset = os;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1669 db->db.db_object = dn->dn_object;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1670 db->db_level = level;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1671 db->db_blkid = blkid;
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1672 db->db_last_dirty = NULL;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1673 db->db_dirtycnt = 0;
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1674 db->db_dnode_handle = dn->dn_handle;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1675 db->db_parent = parent;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1676 db->db_blkptr = blkptr;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1677
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1678 db->db_user_ptr = NULL;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1679 db->db_user_data_ptr_ptr = NULL;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1680 db->db_evict_func = NULL;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1681 db->db_immediate_evict = 0;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1682 db->db_freed_in_flight = 0;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1683
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1684 if (blkid == DMU_BONUS_BLKID) {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1685 ASSERT3P(parent, ==, dn->dn_dbuf);
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
1686 db->db.db_size = DN_MAX_BONUSLEN -
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
1687 (dn->dn_nblkptr-1) * sizeof (blkptr_t);
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
1688 ASSERT3U(db->db.db_size, >=, dn->dn_bonuslen);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1689 db->db.db_offset = DMU_BONUS_BLKID;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1690 db->db_state = DB_UNCACHED;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1691 /* the bonus dbuf is not placed in the hash table */
8582
df9361868dbe 6748019 ARC/L2ARC metadata accounting for arc_size
Brendan Gregg - Sun Microsystems <Brendan.Gregg@Sun.COM>
parents: 7872
diff changeset
1692 arc_space_consume(sizeof (dmu_buf_impl_t), ARC_SPACE_OTHER);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1693 return (db);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1694 } else if (blkid == DMU_SPILL_BLKID) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1695 db->db.db_size = (blkptr != NULL) ?
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1696 BP_GET_LSIZE(blkptr) : SPA_MINBLOCKSIZE;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1697 db->db.db_offset = 0;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1698 } else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1699 int blocksize =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1700 db->db_level ? 1<<dn->dn_indblkshift : dn->dn_datablksz;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1701 db->db.db_size = blocksize;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1702 db->db.db_offset = db->db_blkid * blocksize;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1703 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1704
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1705 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1706 * Hold the dn_dbufs_mtx while we get the new dbuf
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1707 * in the hash table *and* added to the dbufs list.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1708 * This prevents a possible deadlock with someone
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1709 * trying to look up this dbuf before its added to the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1710 * dn_dbufs list.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1711 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1712 mutex_enter(&dn->dn_dbufs_mtx);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1713 db->db_state = DB_EVICTING;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1714 if ((odb = dbuf_hash_insert(db)) != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1715 /* someone else inserted it first */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1716 kmem_cache_free(dbuf_cache, db);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1717 mutex_exit(&dn->dn_dbufs_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1718 return (odb);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1719 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1720 list_insert_head(&dn->dn_dbufs, db);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1721 db->db_state = DB_UNCACHED;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1722 mutex_exit(&dn->dn_dbufs_mtx);
8582
df9361868dbe 6748019 ARC/L2ARC metadata accounting for arc_size
Brendan Gregg - Sun Microsystems <Brendan.Gregg@Sun.COM>
parents: 7872
diff changeset
1723 arc_space_consume(sizeof (dmu_buf_impl_t), ARC_SPACE_OTHER);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1724
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1725 if (parent && parent != dn->dn_dbuf)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1726 dbuf_add_ref(parent, db);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1727
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1728 ASSERT(dn->dn_object == DMU_META_DNODE_OBJECT ||
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1729 refcount_count(&dn->dn_holds) > 0);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1730 (void) refcount_add(&dn->dn_holds, db);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1731 (void) atomic_inc_32_nv(&dn->dn_dbufs_count);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1732
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1733 dprintf_dbuf(db, "db=%p\n", db);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1734
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1735 return (db);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1736 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1737
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1738 static int
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1739 dbuf_do_evict(void *private)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1740 {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1741 arc_buf_t *buf = private;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1742 dmu_buf_impl_t *db = buf->b_private;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1743
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1744 if (!MUTEX_HELD(&db->db_mtx))
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1745 mutex_enter(&db->db_mtx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1746
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1747 ASSERT(refcount_is_zero(&db->db_holds));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1748
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1749 if (db->db_state != DB_EVICTING) {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1750 ASSERT(db->db_state == DB_CACHED);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1751 DBUF_VERIFY(db);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1752 db->db_buf = NULL;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1753 dbuf_evict(db);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1754 } else {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1755 mutex_exit(&db->db_mtx);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1756 dbuf_destroy(db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1757 }
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1758 return (0);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1759 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1760
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1761 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1762 dbuf_destroy(dmu_buf_impl_t *db)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1763 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1764 ASSERT(refcount_is_zero(&db->db_holds));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1765
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1766 if (db->db_blkid != DMU_BONUS_BLKID) {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1767 /*
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1768 * If this dbuf is still on the dn_dbufs list,
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1769 * remove it from that list.
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1770 */
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1771 if (db->db_dnode_handle != NULL) {
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1772 dnode_t *dn;
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
1773
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1774 DB_DNODE_ENTER(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1775 dn = DB_DNODE(db);
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
1776 mutex_enter(&dn->dn_dbufs_mtx);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1777 list_remove(&dn->dn_dbufs, db);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1778 (void) atomic_dec_32_nv(&dn->dn_dbufs_count);
1596
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1779 mutex_exit(&dn->dn_dbufs_mtx);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1780 DB_DNODE_EXIT(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1781 /*
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1782 * Decrementing the dbuf count means that the hold
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1783 * corresponding to the removed dbuf is no longer
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1784 * discounted in dnode_move(), so the dnode cannot be
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1785 * moved until after we release the hold.
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1786 */
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1787 dnode_rele(dn, db);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1788 db->db_dnode_handle = NULL;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1789 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1790 dbuf_hash_remove(db);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1791 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1792 db->db_parent = NULL;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1793 db->db_buf = NULL;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1794
4312
4fef416ca8cb 6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents: 4309
diff changeset
1795 ASSERT(!list_link_active(&db->db_link));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1796 ASSERT(db->db.db_data == NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1797 ASSERT(db->db_hash_next == NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1798 ASSERT(db->db_blkptr == NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1799 ASSERT(db->db_data_pending == NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1800
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1801 kmem_cache_free(dbuf_cache, db);
8582
df9361868dbe 6748019 ARC/L2ARC metadata accounting for arc_size
Brendan Gregg - Sun Microsystems <Brendan.Gregg@Sun.COM>
parents: 7872
diff changeset
1802 arc_space_return(sizeof (dmu_buf_impl_t), ARC_SPACE_OTHER);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1803 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1804
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1805 void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1806 dbuf_prefetch(dnode_t *dn, uint64_t blkid)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1807 {
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
1808 dmu_buf_impl_t *db = NULL;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1809 blkptr_t *bp = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1810
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1811 ASSERT(blkid != DMU_BONUS_BLKID);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1812 ASSERT(RW_LOCK_HELD(&dn->dn_struct_rwlock));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1813
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1814 if (dnode_block_freed(dn, blkid))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1815 return;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1816
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1817 /* dbuf_find() returns with db_mtx held */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1818 if (db = dbuf_find(dn, 0, blkid)) {
13026
8a1c615ca92b 6958471 assertion failed: BP_GET_DEDUP(zio->io_bp), file: ../../common/fs/zfs/arc.c, line: 3257
George Wilson <George.Wilson@Sun.COM>
parents: 12684
diff changeset
1819 /*
8a1c615ca92b 6958471 assertion failed: BP_GET_DEDUP(zio->io_bp), file: ../../common/fs/zfs/arc.c, line: 3257
George Wilson <George.Wilson@Sun.COM>
parents: 12684
diff changeset
1820 * This dbuf is already in the cache. We assume that
8a1c615ca92b 6958471 assertion failed: BP_GET_DEDUP(zio->io_bp), file: ../../common/fs/zfs/arc.c, line: 3257
George Wilson <George.Wilson@Sun.COM>
parents: 12684
diff changeset
1821 * it is already CACHED, or else about to be either
8a1c615ca92b 6958471 assertion failed: BP_GET_DEDUP(zio->io_bp), file: ../../common/fs/zfs/arc.c, line: 3257
George Wilson <George.Wilson@Sun.COM>
parents: 12684
diff changeset
1822 * read or filled.
8a1c615ca92b 6958471 assertion failed: BP_GET_DEDUP(zio->io_bp), file: ../../common/fs/zfs/arc.c, line: 3257
George Wilson <George.Wilson@Sun.COM>
parents: 12684
diff changeset
1823 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1824 mutex_exit(&db->db_mtx);
13026
8a1c615ca92b 6958471 assertion failed: BP_GET_DEDUP(zio->io_bp), file: ../../common/fs/zfs/arc.c, line: 3257
George Wilson <George.Wilson@Sun.COM>
parents: 12684
diff changeset
1825 return;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1826 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1827
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
1828 if (dbuf_findbp(dn, 0, blkid, TRUE, &db, &bp) == 0) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1829 if (bp && !BP_IS_HOLE(bp)) {
12450
c77e20e4e046 6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents: 12411
diff changeset
1830 int priority = dn->dn_type == DMU_OT_DDT_ZAP ?
c77e20e4e046 6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents: 12411
diff changeset
1831 ZIO_PRIORITY_DDT_PREFETCH : ZIO_PRIORITY_ASYNC_READ;
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
1832 arc_buf_t *pbuf;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
1833 dsl_dataset_t *ds = dn->dn_objset->os_dsl_dataset;
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
1834 uint32_t aflags = ARC_NOWAIT | ARC_PREFETCH;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1835 zbookmark_t zb;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
1836
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
1837 SET_BOOKMARK(&zb, ds ? ds->ds_object : DMU_META_OBJSET,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
1838 dn->dn_object, 0, blkid);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1839
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
1840 if (db)
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
1841 pbuf = db->db_buf;
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
1842 else
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
1843 pbuf = dn->dn_objset->os_phys_buf;
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
1844
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
1845 (void) dsl_read(NULL, dn->dn_objset->os_spa,
12450
c77e20e4e046 6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents: 12411
diff changeset
1846 bp, pbuf, NULL, NULL, priority,
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1847 ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE,
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
1848 &aflags, &zb);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1849 }
2391
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
1850 if (db)
2fa3fd1db808 6447377 ZFS prefetch is inconsistant
maybee
parents: 2237
diff changeset
1851 dbuf_rele(db, NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1852 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1853 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1854
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1855 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1856 * Returns with db_holds incremented, and db_mtx not held.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1857 * Note: dn_struct_rwlock must be held.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1858 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1859 int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1860 dbuf_hold_impl(dnode_t *dn, uint8_t level, uint64_t blkid, int fail_sparse,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1861 void *tag, dmu_buf_impl_t **dbp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1862 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1863 dmu_buf_impl_t *db, *parent = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1864
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1865 ASSERT(blkid != DMU_BONUS_BLKID);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1866 ASSERT(RW_LOCK_HELD(&dn->dn_struct_rwlock));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1867 ASSERT3U(dn->dn_nlevels, >, level);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1868
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1869 *dbp = NULL;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1870 top:
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1871 /* dbuf_find() returns with db_mtx held */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1872 db = dbuf_find(dn, level, blkid);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1873
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1874 if (db == NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1875 blkptr_t *bp = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1876 int err;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1877
1596
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1878 ASSERT3P(parent, ==, NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1879 err = dbuf_findbp(dn, level, blkid, fail_sparse, &parent, &bp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1880 if (fail_sparse) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1881 if (err == 0 && bp && BP_IS_HOLE(bp))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1882 err = ENOENT;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1883 if (err) {
1596
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1884 if (parent)
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1885 dbuf_rele(parent, NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1886 return (err);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1887 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1888 }
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1889 if (err && err != ENOENT)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1890 return (err);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1891 db = dbuf_create(dn, level, blkid, parent, bp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1892 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1893
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1894 if (db->db_buf && refcount_is_zero(&db->db_holds)) {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1895 arc_buf_add_ref(db->db_buf, db);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1896 if (db->db_buf->b_data == NULL) {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1897 dbuf_clear(db);
1596
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1898 if (parent) {
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1899 dbuf_rele(parent, NULL);
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1900 parent = NULL;
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1901 }
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1902 goto top;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1903 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1904 ASSERT3P(db->db.db_data, ==, db->db_buf->b_data);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1905 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1906
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1907 ASSERT(db->db_buf == NULL || arc_referenced(db->db_buf));
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1908
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1909 /*
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1910 * If this buffer is currently syncing out, and we are are
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1911 * still referencing it from db_data, we need to make a copy
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1912 * of it in case we decide we want to dirty it again in this txg.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1913 */
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1914 if (db->db_level == 0 && db->db_blkid != DMU_BONUS_BLKID &&
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1915 dn->dn_object != DMU_META_DNODE_OBJECT &&
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1916 db->db_state == DB_CACHED && db->db_data_pending) {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1917 dbuf_dirty_record_t *dr = db->db_data_pending;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1918
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1919 if (dr->dt.dl.dr_data == db->db_buf) {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1920 arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1921
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1922 dbuf_set_data(db,
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1923 arc_buf_alloc(dn->dn_objset->os_spa,
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1924 db->db.db_size, db, type));
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1925 bcopy(dr->dt.dl.dr_data->b_data, db->db.db_data,
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1926 db->db.db_size);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
1927 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1928 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1929
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1930 (void) refcount_add(&db->db_holds, tag);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1931 dbuf_update_data(db);
873
adefbfa5f42d 6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents: 789
diff changeset
1932 DBUF_VERIFY(db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1933 mutex_exit(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1934
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1935 /* NOTE: we can't rele the parent until after we drop the db_mtx */
1596
2e2377ccbf85 6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents: 1544
diff changeset
1936 if (parent)
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1937 dbuf_rele(parent, NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1938
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1939 ASSERT3P(DB_DNODE(db), ==, dn);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1940 ASSERT3U(db->db_blkid, ==, blkid);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1941 ASSERT3U(db->db_level, ==, level);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1942 *dbp = db;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1943
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1944 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1945 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1946
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1947 dmu_buf_impl_t *
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1948 dbuf_hold(dnode_t *dn, uint64_t blkid, void *tag)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1949 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1950 dmu_buf_impl_t *db;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1951 int err = dbuf_hold_impl(dn, 0, blkid, FALSE, tag, &db);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1952 return (err ? NULL : db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1953 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1954
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1955 dmu_buf_impl_t *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1956 dbuf_hold_level(dnode_t *dn, int level, uint64_t blkid, void *tag)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1957 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1958 dmu_buf_impl_t *db;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1959 int err = dbuf_hold_impl(dn, level, blkid, FALSE, tag, &db);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1960 return (err ? NULL : db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1961 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1962
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
1963 void
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1964 dbuf_create_bonus(dnode_t *dn)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1965 {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1966 ASSERT(RW_WRITE_HELD(&dn->dn_struct_rwlock));
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1967
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
1968 ASSERT(dn->dn_bonus == NULL);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1969 dn->dn_bonus = dbuf_create(dn, 0, DMU_BONUS_BLKID, dn->dn_dbuf, NULL);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1970 }
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1971
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1972 int
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1973 dbuf_spill_set_blksz(dmu_buf_t *db_fake, uint64_t blksz, dmu_tx_t *tx)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1974 {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1975 dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake;
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1976 dnode_t *dn;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1977
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1978 if (db->db_blkid != DMU_SPILL_BLKID)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1979 return (ENOTSUP);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1980 if (blksz == 0)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1981 blksz = SPA_MINBLOCKSIZE;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1982 if (blksz > SPA_MAXBLOCKSIZE)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1983 blksz = SPA_MAXBLOCKSIZE;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1984 else
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1985 blksz = P2ROUNDUP(blksz, SPA_MINBLOCKSIZE);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1986
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1987 DB_DNODE_ENTER(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1988 dn = DB_DNODE(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1989 rw_enter(&dn->dn_struct_rwlock, RW_WRITER);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1990 dbuf_new_size(db, blksz, tx);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1991 rw_exit(&dn->dn_struct_rwlock);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
1992 DB_DNODE_EXIT(db);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1993
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1994 return (0);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1995 }
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1996
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1997 void
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1998 dbuf_rm_spill(dnode_t *dn, dmu_tx_t *tx)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
1999 {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2000 dbuf_free_range(dn, DMU_SPILL_BLKID, DMU_SPILL_BLKID, tx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2001 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2002
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2003 #pragma weak dmu_buf_add_ref = dbuf_add_ref
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2004 void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2005 dbuf_add_ref(dmu_buf_impl_t *db, void *tag)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2006 {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2007 int64_t holds = refcount_add(&db->db_holds, tag);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2008 ASSERT(holds > 1);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2009 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2010
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2011 /*
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2012 * If you call dbuf_rele() you had better not be referencing the dnode handle
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2013 * unless you have some other direct or indirect hold on the dnode. (An indirect
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2014 * hold is a hold on one of the dnode's dbufs, including the bonus buffer.)
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2015 * Without that, the dbuf_rele() could lead to a dnode_rele() followed by the
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2016 * dnode's parent dbuf evicting its dnode handles.
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2017 */
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2018 #pragma weak dmu_buf_rele = dbuf_rele
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2019 void
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2020 dbuf_rele(dmu_buf_impl_t *db, void *tag)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2021 {
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2022 mutex_enter(&db->db_mtx);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2023 dbuf_rele_and_unlock(db, tag);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2024 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2025
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2026 /*
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2027 * dbuf_rele() for an already-locked dbuf. This is necessary to allow
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2028 * db_dirtycnt and db_holds to be updated atomically.
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2029 */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2030 void
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2031 dbuf_rele_and_unlock(dmu_buf_impl_t *db, void *tag)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2032 {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2033 int64_t holds;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2034
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2035 ASSERT(MUTEX_HELD(&db->db_mtx));
873
adefbfa5f42d 6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents: 789
diff changeset
2036 DBUF_VERIFY(db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2037
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2038 /*
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2039 * Remove the reference to the dbuf before removing its hold on the
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2040 * dnode so we can guarantee in dnode_move() that a referenced bonus
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2041 * buffer has a corresponding dnode hold.
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2042 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2043 holds = refcount_remove(&db->db_holds, tag);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2044 ASSERT(holds >= 0);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2045
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2046 /*
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2047 * We can't freeze indirects if there is a possibility that they
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2048 * may be modified in the current syncing context.
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2049 */
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2050 if (db->db_buf && holds == (db->db_level == 0 ? db->db_dirtycnt : 0))
3093
71525e4187d5 6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents: 2986
diff changeset
2051 arc_buf_freeze(db->db_buf);
71525e4187d5 6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents: 2986
diff changeset
2052
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2053 if (holds == db->db_dirtycnt &&
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2054 db->db_level == 0 && db->db_immediate_evict)
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2055 dbuf_evict_user(db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2056
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2057 if (holds == 0) {
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2058 if (db->db_blkid == DMU_BONUS_BLKID) {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2059 mutex_exit(&db->db_mtx);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2060
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2061 /*
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2062 * If the dnode moves here, we cannot cross this barrier
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2063 * until the move completes.
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2064 */
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2065 DB_DNODE_ENTER(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2066 (void) atomic_dec_32_nv(&DB_DNODE(db)->dn_dbufs_count);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2067 DB_DNODE_EXIT(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2068 /*
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2069 * The bonus buffer's dnode hold is no longer discounted
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2070 * in dnode_move(). The dnode cannot move until after
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2071 * the dnode_rele().
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2072 */
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2073 dnode_rele(DB_DNODE(db), db);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2074 } else if (db->db_buf == NULL) {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2075 /*
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2076 * This is a special case: we never associated this
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2077 * dbuf with any data allocated from the ARC.
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2078 */
7872
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
2079 ASSERT(db->db_state == DB_UNCACHED ||
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
2080 db->db_state == DB_NOFILL);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2081 dbuf_evict(db);
3093
71525e4187d5 6490569 verify arc bufs are not modified when they shouldn't be
ahrens
parents: 2986
diff changeset
2082 } else if (arc_released(db->db_buf)) {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2083 arc_buf_t *buf = db->db_buf;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2084 /*
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2085 * This dbuf has anonymous data associated with it.
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2086 */
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2087 dbuf_set_data(db, NULL);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2088 VERIFY(arc_buf_remove_ref(buf, db) == 1);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2089 dbuf_evict(db);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2090 } else {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2091 VERIFY(arc_buf_remove_ref(db->db_buf, db) == 0);
7237
f47d41541b14 PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents: 7046
diff changeset
2092 if (!DBUF_IS_CACHEABLE(db))
f47d41541b14 PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents: 7046
diff changeset
2093 dbuf_clear(db);
f47d41541b14 PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents: 7046
diff changeset
2094 else
f47d41541b14 PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents: 7046
diff changeset
2095 mutex_exit(&db->db_mtx);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2096 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2097 } else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2098 mutex_exit(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2099 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2100 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2101
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2102 #pragma weak dmu_buf_refcount = dbuf_refcount
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2103 uint64_t
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2104 dbuf_refcount(dmu_buf_impl_t *db)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2105 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2106 return (refcount_count(&db->db_holds));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2107 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2108
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2109 void *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2110 dmu_buf_set_user(dmu_buf_t *db_fake, void *user_ptr, void *user_data_ptr_ptr,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2111 dmu_buf_evict_func_t *evict_func)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2112 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2113 return (dmu_buf_update_user(db_fake, NULL, user_ptr,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2114 user_data_ptr_ptr, evict_func));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2115 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2116
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2117 void *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2118 dmu_buf_set_user_ie(dmu_buf_t *db_fake, void *user_ptr, void *user_data_ptr_ptr,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2119 dmu_buf_evict_func_t *evict_func)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2120 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2121 dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2122
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2123 db->db_immediate_evict = TRUE;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2124 return (dmu_buf_update_user(db_fake, NULL, user_ptr,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2125 user_data_ptr_ptr, evict_func));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2126 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2127
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2128 void *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2129 dmu_buf_update_user(dmu_buf_t *db_fake, void *old_user_ptr, void *user_ptr,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2130 void *user_data_ptr_ptr, dmu_buf_evict_func_t *evict_func)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2131 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2132 dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2133 ASSERT(db->db_level == 0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2134
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2135 ASSERT((user_ptr == NULL) == (evict_func == NULL));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2136
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2137 mutex_enter(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2138
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2139 if (db->db_user_ptr == old_user_ptr) {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2140 db->db_user_ptr = user_ptr;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2141 db->db_user_data_ptr_ptr = user_data_ptr_ptr;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2142 db->db_evict_func = evict_func;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2143
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2144 dbuf_update_data(db);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2145 } else {
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2146 old_user_ptr = db->db_user_ptr;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2147 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2148
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2149 mutex_exit(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2150 return (old_user_ptr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2151 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2152
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2153 void *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2154 dmu_buf_get_user(dmu_buf_t *db_fake)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2155 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2156 dmu_buf_impl_t *db = (dmu_buf_impl_t *)db_fake;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2157 ASSERT(!refcount_is_zero(&db->db_holds));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2158
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2159 return (db->db_user_ptr);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2160 }
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2161
9653
a70048a304d1 6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents: 9412
diff changeset
2162 boolean_t
a70048a304d1 6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents: 9412
diff changeset
2163 dmu_buf_freeable(dmu_buf_t *dbuf)
a70048a304d1 6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents: 9412
diff changeset
2164 {
a70048a304d1 6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents: 9412
diff changeset
2165 boolean_t res = B_FALSE;
a70048a304d1 6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents: 9412
diff changeset
2166 dmu_buf_impl_t *db = (dmu_buf_impl_t *)dbuf;
a70048a304d1 6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents: 9412
diff changeset
2167
a70048a304d1 6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents: 9412
diff changeset
2168 if (db->db_blkptr)
a70048a304d1 6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents: 9412
diff changeset
2169 res = dsl_dataset_block_freeable(db->db_objset->os_dsl_dataset,
12450
c77e20e4e046 6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents: 12411
diff changeset
2170 db->db_blkptr, db->db_blkptr->blk_birth);
9653
a70048a304d1 6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents: 9412
diff changeset
2171
a70048a304d1 6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents: 9412
diff changeset
2172 return (res);
a70048a304d1 6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents: 9412
diff changeset
2173 }
a70048a304d1 6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents: 9412
diff changeset
2174
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2175 static void
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2176 dbuf_check_blkptr(dnode_t *dn, dmu_buf_impl_t *db)
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2177 {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2178 /* ASSERT(dmu_tx_is_syncing(tx) */
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2179 ASSERT(MUTEX_HELD(&db->db_mtx));
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2180
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2181 if (db->db_blkptr != NULL)
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2182 return;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2183
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2184 if (db->db_blkid == DMU_SPILL_BLKID) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2185 db->db_blkptr = &dn->dn_phys->dn_spill;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2186 BP_ZERO(db->db_blkptr);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2187 return;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2188 }
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2189 if (db->db_level == dn->dn_phys->dn_nlevels-1) {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2190 /*
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2191 * This buffer was allocated at a time when there was
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2192 * no available blkptrs from the dnode, or it was
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2193 * inappropriate to hook it in (i.e., nlevels mis-match).
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2194 */
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2195 ASSERT(db->db_blkid < dn->dn_phys->dn_nblkptr);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2196 ASSERT(db->db_parent == NULL);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2197 db->db_parent = dn->dn_dbuf;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2198 db->db_blkptr = &dn->dn_phys->dn_blkptr[db->db_blkid];
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2199 DBUF_VERIFY(db);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2200 } else {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2201 dmu_buf_impl_t *parent = db->db_parent;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2202 int epbs = dn->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2203
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2204 ASSERT(dn->dn_phys->dn_nlevels > 1);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2205 if (parent == NULL) {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2206 mutex_exit(&db->db_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2207 rw_enter(&dn->dn_struct_rwlock, RW_READER);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2208 (void) dbuf_hold_impl(dn, db->db_level+1,
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2209 db->db_blkid >> epbs, FALSE, db, &parent);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2210 rw_exit(&dn->dn_struct_rwlock);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2211 mutex_enter(&db->db_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2212 db->db_parent = parent;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2213 }
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2214 db->db_blkptr = (blkptr_t *)parent->db.db_data +
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2215 (db->db_blkid & ((1ULL << epbs) - 1));
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2216 DBUF_VERIFY(db);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2217 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2218 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2219
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2220 static void
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2221 dbuf_sync_indirect(dbuf_dirty_record_t *dr, dmu_tx_t *tx)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2222 {
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2223 dmu_buf_impl_t *db = dr->dr_dbuf;
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2224 dnode_t *dn;
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2225 zio_t *zio;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2226
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2227 ASSERT(dmu_tx_is_syncing(tx));
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2228
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2229 dprintf_dbuf_bp(db, db->db_blkptr, "blkptr=%p", db->db_blkptr);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2230
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2231 mutex_enter(&db->db_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2232
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2233 ASSERT(db->db_level > 0);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2234 DBUF_VERIFY(db);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2235
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2236 if (db->db_buf == NULL) {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2237 mutex_exit(&db->db_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2238 (void) dbuf_read(db, NULL, DB_RF_MUST_SUCCEED);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2239 mutex_enter(&db->db_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2240 }
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2241 ASSERT3U(db->db_state, ==, DB_CACHED);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2242 ASSERT(db->db_buf != NULL);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2243
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2244 DB_DNODE_ENTER(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2245 dn = DB_DNODE(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2246 ASSERT3U(db->db.db_size, ==, 1<<dn->dn_phys->dn_indblkshift);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2247 dbuf_check_blkptr(dn, db);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2248 DB_DNODE_EXIT(db);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2249
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2250 db->db_data_pending = dr;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2251
3897
278bade789ba 6437750 panic: db->db_buf==0||arc_referenced(db->db_buf), file: dbuf.c,line:1539
maybee
parents: 3882
diff changeset
2252 mutex_exit(&db->db_mtx);
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
2253 dbuf_write(dr, db->db_buf, tx);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2254
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2255 zio = dr->dr_zio;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2256 mutex_enter(&dr->dt.di.dr_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2257 dbuf_sync_list(&dr->dt.di.dr_children, tx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2258 ASSERT(list_head(&dr->dt.di.dr_children) == NULL);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2259 mutex_exit(&dr->dt.di.dr_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2260 zio_nowait(zio);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2261 }
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2262
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2263 static void
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2264 dbuf_sync_leaf(dbuf_dirty_record_t *dr, dmu_tx_t *tx)
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2265 {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2266 arc_buf_t **datap = &dr->dt.dl.dr_data;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2267 dmu_buf_impl_t *db = dr->dr_dbuf;
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2268 dnode_t *dn;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2269 objset_t *os;
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2270 uint64_t txg = tx->tx_txg;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2271
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2272 ASSERT(dmu_tx_is_syncing(tx));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2273
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2274 dprintf_dbuf_bp(db, db->db_blkptr, "blkptr=%p", db->db_blkptr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2275
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2276 mutex_enter(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2277 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2278 * To be synced, we must be dirtied. But we
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2279 * might have been freed after the dirty.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2280 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2281 if (db->db_state == DB_UNCACHED) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2282 /* This buffer has been freed since it was dirtied */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2283 ASSERT(db->db.db_data == NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2284 } else if (db->db_state == DB_FILL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2285 /* This buffer was freed and is now being re-filled */
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2286 ASSERT(db->db.db_data != dr->dt.dl.dr_data);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2287 } else {
7872
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
2288 ASSERT(db->db_state == DB_CACHED || db->db_state == DB_NOFILL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2289 }
873
adefbfa5f42d 6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents: 789
diff changeset
2290 DBUF_VERIFY(db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2291
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2292 DB_DNODE_ENTER(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2293 dn = DB_DNODE(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2294
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2295 if (db->db_blkid == DMU_SPILL_BLKID) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2296 mutex_enter(&dn->dn_mtx);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2297 dn->dn_phys->dn_flags |= DNODE_FLAG_SPILL_BLKPTR;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2298 mutex_exit(&dn->dn_mtx);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2299 }
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2300
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2301 /*
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2302 * If this is a bonus buffer, simply copy the bonus data into the
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2303 * dnode. It will be written out when the dnode is synced (and it
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2304 * will be synced, since it must have been dirty for dbuf_sync to
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2305 * be called).
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2306 */
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2307 if (db->db_blkid == DMU_BONUS_BLKID) {
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2308 dbuf_dirty_record_t **drp;
4944
96d96f8de974 6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents: 4831
diff changeset
2309
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2310 ASSERT(*datap != NULL);
13765
9410cf539b11 backout 3006: causes 3046 (panics after mounting root)
Richard Lowe <richlowe@richlowe.net>
parents: 13764
diff changeset
2311 ASSERT3U(db->db_level, ==, 0);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2312 ASSERT3U(dn->dn_phys->dn_bonuslen, <=, DN_MAX_BONUSLEN);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2313 bcopy(*datap, DN_BONUS(dn->dn_phys), dn->dn_phys->dn_bonuslen);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2314 DB_DNODE_EXIT(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2315
4309
3dfde0f4662d 6542676 ARC needs to track meta-data memory overhead
maybee
parents: 3897
diff changeset
2316 if (*datap != db->db.db_data) {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2317 zio_buf_free(*datap, DN_MAX_BONUSLEN);
8582
df9361868dbe 6748019 ARC/L2ARC metadata accounting for arc_size
Brendan Gregg - Sun Microsystems <Brendan.Gregg@Sun.COM>
parents: 7872
diff changeset
2318 arc_space_return(DN_MAX_BONUSLEN, ARC_SPACE_OTHER);
4309
3dfde0f4662d 6542676 ARC needs to track meta-data memory overhead
maybee
parents: 3897
diff changeset
2319 }
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2320 db->db_data_pending = NULL;
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2321 drp = &db->db_last_dirty;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2322 while (*drp != dr)
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2323 drp = &(*drp)->dr_next;
5688
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 5370
diff changeset
2324 ASSERT(dr->dr_next == NULL);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2325 ASSERT(dr->dr_dbuf == db);
5688
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 5370
diff changeset
2326 *drp = dr->dr_next;
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2327 kmem_free(dr, sizeof (dbuf_dirty_record_t));
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2328 ASSERT(db->db_dirtycnt > 0);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2329 db->db_dirtycnt -= 1;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2330 dbuf_rele_and_unlock(db, (void *)(uintptr_t)txg);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2331 return;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2332 }
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1491
diff changeset
2333
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2334 os = dn->dn_objset;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2335
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2336 /*
4312
4fef416ca8cb 6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents: 4309
diff changeset
2337 * This function may have dropped the db_mtx lock allowing a dmu_sync
4fef416ca8cb 6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents: 4309
diff changeset
2338 * operation to sneak in. As a result, we need to ensure that we
4fef416ca8cb 6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents: 4309
diff changeset
2339 * don't check the dr_override_state until we have returned from
4fef416ca8cb 6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents: 4309
diff changeset
2340 * dbuf_check_blkptr.
4fef416ca8cb 6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents: 4309
diff changeset
2341 */
4fef416ca8cb 6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents: 4309
diff changeset
2342 dbuf_check_blkptr(dn, db);
4fef416ca8cb 6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents: 4309
diff changeset
2343
4fef416ca8cb 6523336 panic dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN, file: ../../ common/fs/zfs/dbuf.c line: 2195
gw25295
parents: 4309
diff changeset
2344 /*
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2345 * If this buffer is in the middle of an immediate write,
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2346 * wait for the synchronous IO to complete.
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2347 */
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2348 while (dr->dt.dl.dr_override_state == DR_IN_DMU_SYNC) {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2349 ASSERT(dn->dn_object != DMU_META_DNODE_OBJECT);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2350 cv_wait(&db->db_changed, &db->db_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2351 ASSERT(dr->dt.dl.dr_override_state != DR_NOT_OVERRIDDEN);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2352 }
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2353
8746
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2354 if (db->db_state != DB_NOFILL &&
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2355 dn->dn_object != DMU_META_DNODE_OBJECT &&
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2356 refcount_count(&db->db_holds) > 1 &&
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2357 dr->dt.dl.dr_override_state != DR_OVERRIDDEN &&
8746
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2358 *datap == db->db_buf) {
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2359 /*
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2360 * If this buffer is currently "in use" (i.e., there
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2361 * are active holds and db_data still references it),
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2362 * then make a copy before we start the write so that
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2363 * any modifications from the open txg will not leak
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2364 * into this write.
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2365 *
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2366 * NOTE: this copy does not need to be made for
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2367 * objects only modified in the syncing context (e.g.
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2368 * DNONE_DNODE blocks).
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2369 */
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2370 int blksz = arc_buf_size(*datap);
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2371 arc_buf_contents_t type = DBUF_GET_BUFC_TYPE(db);
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2372 *datap = arc_buf_alloc(os->os_spa, blksz, db, type);
e1d96ca6808c 6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 8582
diff changeset
2373 bcopy(db->db.db_data, (*datap)->b_data, blksz);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2374 }
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2375 db->db_data_pending = dr;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2376
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2377 mutex_exit(&db->db_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2378
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
2379 dbuf_write(dr, *datap, tx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2380
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2381 ASSERT(!list_link_active(&dr->dr_dirty_node));
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2382 if (dn->dn_object == DMU_META_DNODE_OBJECT) {
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2383 list_insert_tail(&dn->dn_dirty_records[txg&TXG_MASK], dr);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2384 DB_DNODE_EXIT(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2385 } else {
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2386 /*
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2387 * Although zio_nowait() does not "wait for an IO", it does
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2388 * initiate the IO. If this is an empty write it seems plausible
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2389 * that the IO could actually be completed before the nowait
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2390 * returns. We need to DB_DNODE_EXIT() first in case
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2391 * zio_nowait() invalidates the dbuf.
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2392 */
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2393 DB_DNODE_EXIT(db);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2394 zio_nowait(dr->dr_zio);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2395 }
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2396 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2397
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2398 void
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2399 dbuf_sync_list(list_t *list, dmu_tx_t *tx)
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2400 {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2401 dbuf_dirty_record_t *dr;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2402
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2403 while (dr = list_head(list)) {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2404 if (dr->dr_zio != NULL) {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2405 /*
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2406 * If we find an already initialized zio then we
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2407 * are processing the meta-dnode, and we have finished.
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2408 * The dbufs for all dnodes are put back on the list
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2409 * during processing, so that we can zio_wait()
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2410 * these IOs after initiating all child IOs.
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2411 */
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2412 ASSERT3U(dr->dr_dbuf->db.db_object, ==,
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2413 DMU_META_DNODE_OBJECT);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2414 break;
1163
4ba797920cc2 6343073 buf[i] == 0 assertion failure when running zvol_pstress
maybee
parents: 982
diff changeset
2415 }
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2416 list_remove(list, dr);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2417 if (dr->dr_dbuf->db_level > 0)
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2418 dbuf_sync_indirect(dr, tx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2419 else
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2420 dbuf_sync_leaf(dr, tx);
1163
4ba797920cc2 6343073 buf[i] == 0 assertion failure when running zvol_pstress
maybee
parents: 982
diff changeset
2421 }
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2422 }
1163
4ba797920cc2 6343073 buf[i] == 0 assertion failure when running zvol_pstress
maybee
parents: 982
diff changeset
2423
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2424 /* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2425 static void
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2426 dbuf_write_ready(zio_t *zio, arc_buf_t *buf, void *vdb)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2427 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2428 dmu_buf_impl_t *db = vdb;
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2429 dnode_t *dn;
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7467
diff changeset
2430 blkptr_t *bp = zio->io_bp;
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2431 blkptr_t *bp_orig = &zio->io_bp_orig;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2432 spa_t *spa = zio->io_spa;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2433 int64_t delta;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2434 uint64_t fill = 0;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2435 int i;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2436
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7467
diff changeset
2437 ASSERT(db->db_blkptr == bp);
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7467
diff changeset
2438
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2439 DB_DNODE_ENTER(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2440 dn = DB_DNODE(db);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2441 delta = bp_get_dsize_sync(spa, bp) - bp_get_dsize_sync(spa, bp_orig);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2442 dnode_diduse_space(dn, delta - zio->io_prev_space_delta);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2443 zio->io_prev_space_delta = delta;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2444
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7467
diff changeset
2445 if (BP_IS_HOLE(bp)) {
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2446 ASSERT(bp->blk_fill == 0);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2447 DB_DNODE_EXIT(db);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2448 return;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2449 }
2237
45affe88ed99 6416482 filebench oltp workload hangs in zfs
maybee
parents: 2082
diff changeset
2450
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2451 ASSERT((db->db_blkid != DMU_SPILL_BLKID &&
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2452 BP_GET_TYPE(bp) == dn->dn_type) ||
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2453 (db->db_blkid == DMU_SPILL_BLKID &&
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2454 BP_GET_TYPE(bp) == dn->dn_bonustype));
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7467
diff changeset
2455 ASSERT(BP_GET_LEVEL(bp) == db->db_level);
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7467
diff changeset
2456
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2457 mutex_enter(&db->db_mtx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2458
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2459 #ifdef ZFS_DEBUG
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2460 if (db->db_blkid == DMU_SPILL_BLKID) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2461 ASSERT(dn->dn_phys->dn_flags & DNODE_FLAG_SPILL_BLKPTR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2462 ASSERT(!(BP_IS_HOLE(db->db_blkptr)) &&
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2463 db->db_blkptr == &dn->dn_phys->dn_spill);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2464 }
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2465 #endif
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2466
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2467 if (db->db_level == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2468 mutex_enter(&dn->dn_mtx);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2469 if (db->db_blkid > dn->dn_phys->dn_maxblkid &&
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2470 db->db_blkid != DMU_SPILL_BLKID)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2471 dn->dn_phys->dn_maxblkid = db->db_blkid;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2472 mutex_exit(&dn->dn_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2473
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2474 if (dn->dn_type == DMU_OT_DNODE) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2475 dnode_phys_t *dnp = db->db.db_data;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2476 for (i = db->db.db_size >> DNODE_SHIFT; i > 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2477 i--, dnp++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2478 if (dnp->dn_type != DMU_OT_NONE)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2479 fill++;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2480 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2481 } else {
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2482 fill = 1;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2483 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2484 } else {
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7467
diff changeset
2485 blkptr_t *ibp = db->db.db_data;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2486 ASSERT3U(db->db.db_size, ==, 1<<dn->dn_phys->dn_indblkshift);
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7467
diff changeset
2487 for (i = db->db.db_size >> SPA_BLKPTRSHIFT; i > 0; i--, ibp++) {
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7467
diff changeset
2488 if (BP_IS_HOLE(ibp))
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2489 continue;
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7467
diff changeset
2490 fill += ibp->blk_fill;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2491 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2492 }
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2493 DB_DNODE_EXIT(db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2494
7754
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7467
diff changeset
2495 bp->blk_fill = fill;
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2496
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2497 mutex_exit(&db->db_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2498 }
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2499
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2500 /* ARGSUSED */
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2501 static void
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2502 dbuf_write_done(zio_t *zio, arc_buf_t *buf, void *vdb)
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2503 {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2504 dmu_buf_impl_t *db = vdb;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2505 blkptr_t *bp = zio->io_bp;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2506 blkptr_t *bp_orig = &zio->io_bp_orig;
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2507 uint64_t txg = zio->io_txg;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2508 dbuf_dirty_record_t **drp, *dr;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2509
13765
9410cf539b11 backout 3006: causes 3046 (panics after mounting root)
Richard Lowe <richlowe@richlowe.net>
parents: 13764
diff changeset
2510 ASSERT3U(zio->io_error, ==, 0);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2511 ASSERT(db->db_blkptr == bp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2512
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2513 if (zio->io_flags & ZIO_FLAG_IO_REWRITE) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2514 ASSERT(BP_EQUAL(bp, bp_orig));
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2515 } else {
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2516 objset_t *os;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2517 dsl_dataset_t *ds;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2518 dmu_tx_t *tx;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2519
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2520 DB_GET_OBJSET(&os, db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2521 ds = os->os_dsl_dataset;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2522 tx = os->os_synctx;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2523
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2524 (void) dsl_dataset_block_kill(ds, bp_orig, tx, B_TRUE);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2525 dsl_dataset_block_born(ds, bp, tx);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2526 }
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2527
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2528 mutex_enter(&db->db_mtx);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2529
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2530 DBUF_VERIFY(db);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2531
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2532 drp = &db->db_last_dirty;
5688
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 5370
diff changeset
2533 while ((dr = *drp) != db->db_data_pending)
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 5370
diff changeset
2534 drp = &dr->dr_next;
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 5370
diff changeset
2535 ASSERT(!list_link_active(&dr->dr_dirty_node));
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 5370
diff changeset
2536 ASSERT(dr->dr_txg == txg);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2537 ASSERT(dr->dr_dbuf == db);
5688
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 5370
diff changeset
2538 ASSERT(dr->dr_next == NULL);
c0b02c8fd2c0 6640580 spa_get_random() is insanely slow in userland
bonwick
parents: 5370
diff changeset
2539 *drp = dr->dr_next;
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2540
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2541 #ifdef ZFS_DEBUG
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2542 if (db->db_blkid == DMU_SPILL_BLKID) {
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2543 dnode_t *dn;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2544
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2545 DB_DNODE_ENTER(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2546 dn = DB_DNODE(db);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2547 ASSERT(dn->dn_phys->dn_flags & DNODE_FLAG_SPILL_BLKPTR);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2548 ASSERT(!(BP_IS_HOLE(db->db_blkptr)) &&
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2549 db->db_blkptr == &dn->dn_phys->dn_spill);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2550 DB_DNODE_EXIT(db);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2551 }
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2552 #endif
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2553
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2554 if (db->db_level == 0) {
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2555 ASSERT(db->db_blkid != DMU_BONUS_BLKID);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2556 ASSERT(dr->dt.dl.dr_override_state == DR_NOT_OVERRIDDEN);
7872
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
2557 if (db->db_state != DB_NOFILL) {
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
2558 if (dr->dt.dl.dr_data != db->db_buf)
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
2559 VERIFY(arc_buf_remove_ref(dr->dt.dl.dr_data,
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
2560 db) == 1);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2561 else if (!arc_released(db->db_buf))
7872
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
2562 arc_set_callback(db->db_buf, dbuf_do_evict, db);
40a9434212f6 6646775 Speed up the dumpifying process for zvols
Tim Haley <Tim.Haley@Sun.COM>
parents: 7837
diff changeset
2563 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2564 } else {
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2565 dnode_t *dn;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2566
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2567 DB_DNODE_ENTER(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2568 dn = DB_DNODE(db);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2569 ASSERT(list_head(&dr->dt.di.dr_children) == NULL);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2570 ASSERT3U(db->db.db_size, ==, 1<<dn->dn_phys->dn_indblkshift);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2571 if (!BP_IS_HOLE(db->db_blkptr)) {
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2572 int epbs =
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2573 dn->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT;
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2574 ASSERT3U(BP_GET_LSIZE(db->db_blkptr), ==,
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2575 db->db.db_size);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2576 ASSERT3U(dn->dn_phys->dn_maxblkid
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2577 >> (db->db_level * epbs), >=, db->db_blkid);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2578 arc_set_callback(db->db_buf, dbuf_do_evict, db);
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2579 }
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2580 DB_DNODE_EXIT(db);
4831
41ec732c6d9f 6584470 zdb needs to initialize the bpl_lock mutex
gw25295
parents: 4506
diff changeset
2581 mutex_destroy(&dr->dt.di.dr_mtx);
41ec732c6d9f 6584470 zdb needs to initialize the bpl_lock mutex
gw25295
parents: 4506
diff changeset
2582 list_destroy(&dr->dt.di.dr_children);
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2583 }
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2584 kmem_free(dr, sizeof (dbuf_dirty_record_t));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2585
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2586 cv_broadcast(&db->db_changed);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2587 ASSERT(db->db_dirtycnt > 0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2588 db->db_dirtycnt -= 1;
3547
e396e0a440b1 6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents: 3290
diff changeset
2589 db->db_data_pending = NULL;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2590 dbuf_rele_and_unlock(db, (void *)(uintptr_t)txg);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2591 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2592
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2593 static void
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2594 dbuf_write_nofill_ready(zio_t *zio)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2595 {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2596 dbuf_write_ready(zio, NULL, zio->io_private);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2597 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2598
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2599 static void
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2600 dbuf_write_nofill_done(zio_t *zio)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2601 {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2602 dbuf_write_done(zio, NULL, zio->io_private);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2603 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2604
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2605 static void
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2606 dbuf_write_override_ready(zio_t *zio)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2607 {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2608 dbuf_dirty_record_t *dr = zio->io_private;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2609 dmu_buf_impl_t *db = dr->dr_dbuf;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2610
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2611 dbuf_write_ready(zio, NULL, db);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2612 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2613
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2614 static void
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2615 dbuf_write_override_done(zio_t *zio)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2616 {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2617 dbuf_dirty_record_t *dr = zio->io_private;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2618 dmu_buf_impl_t *db = dr->dr_dbuf;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2619 blkptr_t *obp = &dr->dt.dl.dr_overridden_by;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2620
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2621 mutex_enter(&db->db_mtx);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2622 if (!BP_EQUAL(zio->io_bp, obp)) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2623 if (!BP_IS_HOLE(obp))
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2624 dsl_free(spa_get_dsl(zio->io_spa), zio->io_txg, obp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2625 arc_release(dr->dt.dl.dr_data, db);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2626 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2627 mutex_exit(&db->db_mtx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2628
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2629 dbuf_write_done(zio, NULL, db);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2630 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2631
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2632 static void
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2633 dbuf_write(dbuf_dirty_record_t *dr, arc_buf_t *data, dmu_tx_t *tx)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2634 {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2635 dmu_buf_impl_t *db = dr->dr_dbuf;
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2636 dnode_t *dn;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2637 objset_t *os;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2638 dmu_buf_impl_t *parent = db->db_parent;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2639 uint64_t txg = tx->tx_txg;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2640 zbookmark_t zb;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2641 zio_prop_t zp;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2642 zio_t *zio;
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2643 int wp_flag = 0;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2644
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2645 DB_DNODE_ENTER(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2646 dn = DB_DNODE(db);
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2647 os = dn->dn_objset;
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2648
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2649 if (db->db_state != DB_NOFILL) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2650 if (db->db_level > 0 || dn->dn_type == DMU_OT_DNODE) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2651 /*
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2652 * Private object buffers are released here rather
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2653 * than in dbuf_dirty() since they are only modified
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2654 * in the syncing context and we don't want the
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2655 * overhead of making multiple copies of the data.
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2656 */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2657 if (BP_IS_HOLE(db->db_blkptr)) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2658 arc_buf_thaw(data);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2659 } else {
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12178
diff changeset
2660 dbuf_release_bp(db);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2661 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2662 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2663 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2664
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2665 if (parent != dn->dn_dbuf) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2666 ASSERT(parent && parent->db_data_pending);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2667 ASSERT(db->db_level == parent->db_level-1);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2668 ASSERT(arc_released(parent->db_buf));
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2669 zio = parent->db_data_pending->dr_zio;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2670 } else {
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2671 ASSERT((db->db_level == dn->dn_phys->dn_nlevels-1 &&
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2672 db->db_blkid != DMU_SPILL_BLKID) ||
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2673 (db->db_blkid == DMU_SPILL_BLKID && db->db_level == 0));
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2674 if (db->db_blkid != DMU_SPILL_BLKID)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2675 ASSERT3P(db->db_blkptr, ==,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2676 &dn->dn_phys->dn_blkptr[db->db_blkid]);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2677 zio = dn->dn_zio;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2678 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2679
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2680 ASSERT(db->db_level == 0 || data == db->db_buf);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2681 ASSERT3U(db->db_blkptr->blk_birth, <=, txg);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2682 ASSERT(zio);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2683
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2684 SET_BOOKMARK(&zb, os->os_dsl_dataset ?
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2685 os->os_dsl_dataset->ds_object : DMU_META_OBJSET,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2686 db->db.db_object, db->db_level, db->db_blkid);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2687
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2688 if (db->db_blkid == DMU_SPILL_BLKID)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2689 wp_flag = WP_SPILL;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2690 wp_flag |= (db->db_state == DB_NOFILL) ? WP_NOFILL : 0;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2691
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11609
diff changeset
2692 dmu_write_policy(os, dn, db->db_level, wp_flag, &zp);
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12587
diff changeset
2693 DB_DNODE_EXIT(db);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2694
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2695 if (db->db_level == 0 && dr->dt.dl.dr_override_state == DR_OVERRIDDEN) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2696 ASSERT(db->db_state != DB_NOFILL);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2697 dr->dr_zio = zio_write(zio, os->os_spa, txg,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2698 db->db_blkptr, data->b_data, arc_buf_size(data), &zp,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2699 dbuf_write_override_ready, dbuf_write_override_done, dr,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2700 ZIO_PRIORITY_ASYNC_WRITE, ZIO_FLAG_MUSTSUCCEED, &zb);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2701 mutex_enter(&db->db_mtx);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2702 dr->dt.dl.dr_override_state = DR_NOT_OVERRIDDEN;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2703 zio_write_override(dr->dr_zio, &dr->dt.dl.dr_overridden_by,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2704 dr->dt.dl.dr_copies);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2705 mutex_exit(&db->db_mtx);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2706 } else if (db->db_state == DB_NOFILL) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2707 ASSERT(zp.zp_checksum == ZIO_CHECKSUM_OFF);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2708 dr->dr_zio = zio_write(zio, os->os_spa, txg,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2709 db->db_blkptr, NULL, db->db.db_size, &zp,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2710 dbuf_write_nofill_ready, dbuf_write_nofill_done, db,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2711 ZIO_PRIORITY_ASYNC_WRITE,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2712 ZIO_FLAG_MUSTSUCCEED | ZIO_FLAG_NODATA, &zb);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2713 } else {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2714 ASSERT(arc_released(data));
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2715 dr->dr_zio = arc_write(zio, os->os_spa, txg,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2716 db->db_blkptr, data, DBUF_IS_L2CACHEABLE(db), &zp,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2717 dbuf_write_ready, dbuf_write_done, db,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2718 ZIO_PRIORITY_ASYNC_WRITE, ZIO_FLAG_MUSTSUCCEED, &zb);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10298
diff changeset
2719 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2720 }