Mercurial > illumos > illumos-gate
annotate usr/src/uts/common/fs/zfs/dnode.c @ 13973:4972ab336f54
3464 zfs synctask code needs restructuring
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Approved by: Garrett D'Amore <garrett@damore.org>
author | Matthew Ahrens <mahrens@delphix.com> |
---|---|
date | Thu, 28 Feb 2013 12:44:05 -0800 |
parents | e3a9ae14a119 |
children | d7059eb1884c |
rev | line source |
---|---|
789 | 1 /* |
2 * CDDL HEADER START | |
3 * | |
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:
1402
diff
changeset
|
5 * Common Development and Distribution License (the "License"). |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
1402
diff
changeset
|
6 * You may not use this file except in compliance with the License. |
789 | 7 * |
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | |
9 * or http://www.opensolaris.org/os/licensing. | |
10 * See the License for the specific language governing permissions | |
11 * and limitations under the License. | |
12 * | |
13 * When distributing Covered Code, include this CDDL HEADER in each | |
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. | |
15 * If applicable, add the following below this CDDL HEADER, with the | |
16 * fields enclosed by brackets "[]" replaced with your own identifying | |
17 * information: Portions Copyright [yyyy] [name of copyright owner] | |
18 * | |
19 * CDDL HEADER END | |
20 */ | |
21 /* | |
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:
11958
diff
changeset
|
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12684
diff
changeset
|
23 * Copyright (c) 2012 by Delphix. All rights reserved. |
789 | 24 */ |
25 | |
26 #include <sys/zfs_context.h> | |
27 #include <sys/dbuf.h> | |
28 #include <sys/dnode.h> | |
29 #include <sys/dmu.h> | |
30 #include <sys/dmu_impl.h> | |
31 #include <sys/dmu_tx.h> | |
32 #include <sys/dmu_objset.h> | |
33 #include <sys/dsl_dir.h> | |
34 #include <sys/dsl_dataset.h> | |
35 #include <sys/spa.h> | |
36 #include <sys/zio.h> | |
37 #include <sys/dmu_zfetch.h> | |
38 | |
39 static int free_range_compar(const void *node1, const void *node2); | |
40 | |
41 static kmem_cache_t *dnode_cache; | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
42 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
43 * Define DNODE_STATS to turn on statistic gathering. By default, it is only |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
44 * turned on when DEBUG is also defined. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
45 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
46 #ifdef DEBUG |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
47 #define DNODE_STATS |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
48 #endif /* DEBUG */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
49 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
50 #ifdef DNODE_STATS |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
51 #define DNODE_STAT_ADD(stat) ((stat)++) |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
52 #else |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
53 #define DNODE_STAT_ADD(stat) /* nothing */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
54 #endif /* DNODE_STATS */ |
789 | 55 |
56 static dnode_phys_t dnode_phys_zero; | |
57 | |
58 int zfs_default_bs = SPA_MINBLOCKSHIFT; | |
59 int zfs_default_ibs = DN_MAX_INDBLKSHIFT; | |
60 | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
61 static kmem_cbrc_t dnode_move(void *, void *, size_t, void *); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
62 |
789 | 63 /* ARGSUSED */ |
64 static int | |
65 dnode_cons(void *arg, void *unused, int kmflag) | |
66 { | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
67 dnode_t *dn = arg; |
789 | 68 int i; |
69 | |
70 rw_init(&dn->dn_struct_rwlock, NULL, RW_DEFAULT, NULL); | |
71 mutex_init(&dn->dn_mtx, NULL, MUTEX_DEFAULT, NULL); | |
72 mutex_init(&dn->dn_dbufs_mtx, NULL, MUTEX_DEFAULT, NULL); | |
8214
d7abf7c1f1c1
6747934 Some locking variables are not properly initialized or destroyed
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
7754
diff
changeset
|
73 cv_init(&dn->dn_notxholds, NULL, CV_DEFAULT, NULL); |
d7abf7c1f1c1
6747934 Some locking variables are not properly initialized or destroyed
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
7754
diff
changeset
|
74 |
13973
4972ab336f54
3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents:
13805
diff
changeset
|
75 /* |
4972ab336f54
3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents:
13805
diff
changeset
|
76 * Every dbuf has a reference, and dropping a tracked reference is |
4972ab336f54
3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents:
13805
diff
changeset
|
77 * O(number of references), so don't track dn_holds. |
4972ab336f54
3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents:
13805
diff
changeset
|
78 */ |
4972ab336f54
3464 zfs synctask code needs restructuring
Matthew Ahrens <mahrens@delphix.com>
parents:
13805
diff
changeset
|
79 refcount_create_untracked(&dn->dn_holds); |
789 | 80 refcount_create(&dn->dn_tx_holds); |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
81 list_link_init(&dn->dn_link); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
82 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
83 bzero(&dn->dn_next_nblkptr[0], sizeof (dn->dn_next_nblkptr)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
84 bzero(&dn->dn_next_nlevels[0], sizeof (dn->dn_next_nlevels)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
85 bzero(&dn->dn_next_indblkshift[0], sizeof (dn->dn_next_indblkshift)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
86 bzero(&dn->dn_next_bonustype[0], sizeof (dn->dn_next_bonustype)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
87 bzero(&dn->dn_rm_spillblk[0], sizeof (dn->dn_rm_spillblk)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
88 bzero(&dn->dn_next_bonuslen[0], sizeof (dn->dn_next_bonuslen)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
89 bzero(&dn->dn_next_blksz[0], sizeof (dn->dn_next_blksz)); |
789 | 90 |
91 for (i = 0; i < TXG_SIZE; i++) { | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
92 list_link_init(&dn->dn_dirty_link[i]); |
789 | 93 avl_create(&dn->dn_ranges[i], free_range_compar, |
94 sizeof (free_range_t), | |
95 offsetof(struct free_range, fr_node)); | |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
96 list_create(&dn->dn_dirty_records[i], |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
97 sizeof (dbuf_dirty_record_t), |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
98 offsetof(dbuf_dirty_record_t, dr_dirty_node)); |
789 | 99 } |
100 | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
101 dn->dn_allocated_txg = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
102 dn->dn_free_txg = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
103 dn->dn_assigned_txg = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
104 dn->dn_dirtyctx = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
105 dn->dn_dirtyctx_firstset = NULL; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
106 dn->dn_bonus = NULL; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
107 dn->dn_have_spill = B_FALSE; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
108 dn->dn_zio = NULL; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
109 dn->dn_oldused = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
110 dn->dn_oldflags = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
111 dn->dn_olduid = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
112 dn->dn_oldgid = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
113 dn->dn_newuid = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
114 dn->dn_newgid = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
115 dn->dn_id_flags = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
116 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
117 dn->dn_dbufs_count = 0; |
789 | 118 list_create(&dn->dn_dbufs, sizeof (dmu_buf_impl_t), |
119 offsetof(dmu_buf_impl_t, db_link)); | |
120 | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
121 dn->dn_moved = 0; |
789 | 122 return (0); |
123 } | |
124 | |
125 /* ARGSUSED */ | |
126 static void | |
127 dnode_dest(void *arg, void *unused) | |
128 { | |
129 int i; | |
130 dnode_t *dn = arg; | |
131 | |
132 rw_destroy(&dn->dn_struct_rwlock); | |
133 mutex_destroy(&dn->dn_mtx); | |
134 mutex_destroy(&dn->dn_dbufs_mtx); | |
8214
d7abf7c1f1c1
6747934 Some locking variables are not properly initialized or destroyed
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
7754
diff
changeset
|
135 cv_destroy(&dn->dn_notxholds); |
789 | 136 refcount_destroy(&dn->dn_holds); |
137 refcount_destroy(&dn->dn_tx_holds); | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
138 ASSERT(!list_link_active(&dn->dn_link)); |
789 | 139 |
140 for (i = 0; i < TXG_SIZE; i++) { | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
141 ASSERT(!list_link_active(&dn->dn_dirty_link[i])); |
789 | 142 avl_destroy(&dn->dn_ranges[i]); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
143 list_destroy(&dn->dn_dirty_records[i]); |
13805
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
144 ASSERT0(dn->dn_next_nblkptr[i]); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
145 ASSERT0(dn->dn_next_nlevels[i]); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
146 ASSERT0(dn->dn_next_indblkshift[i]); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
147 ASSERT0(dn->dn_next_bonustype[i]); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
148 ASSERT0(dn->dn_rm_spillblk[i]); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
149 ASSERT0(dn->dn_next_bonuslen[i]); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
150 ASSERT0(dn->dn_next_blksz[i]); |
789 | 151 } |
152 | |
13805
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
153 ASSERT0(dn->dn_allocated_txg); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
154 ASSERT0(dn->dn_free_txg); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
155 ASSERT0(dn->dn_assigned_txg); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
156 ASSERT0(dn->dn_dirtyctx); |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
157 ASSERT3P(dn->dn_dirtyctx_firstset, ==, NULL); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
158 ASSERT3P(dn->dn_bonus, ==, NULL); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
159 ASSERT(!dn->dn_have_spill); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
160 ASSERT3P(dn->dn_zio, ==, NULL); |
13805
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
161 ASSERT0(dn->dn_oldused); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
162 ASSERT0(dn->dn_oldflags); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
163 ASSERT0(dn->dn_olduid); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
164 ASSERT0(dn->dn_oldgid); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
165 ASSERT0(dn->dn_newuid); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
166 ASSERT0(dn->dn_newgid); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
167 ASSERT0(dn->dn_id_flags); |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
168 |
13805
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
169 ASSERT0(dn->dn_dbufs_count); |
789 | 170 list_destroy(&dn->dn_dbufs); |
171 } | |
172 | |
173 void | |
174 dnode_init(void) | |
175 { | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
176 ASSERT(dnode_cache == NULL); |
789 | 177 dnode_cache = kmem_cache_create("dnode_t", |
178 sizeof (dnode_t), | |
179 0, dnode_cons, dnode_dest, NULL, NULL, NULL, 0); | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
180 kmem_cache_set_move(dnode_cache, dnode_move); |
789 | 181 } |
182 | |
183 void | |
184 dnode_fini(void) | |
185 { | |
186 kmem_cache_destroy(dnode_cache); | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
187 dnode_cache = NULL; |
789 | 188 } |
189 | |
190 | |
873
adefbfa5f42d
6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents:
789
diff
changeset
|
191 #ifdef ZFS_DEBUG |
789 | 192 void |
193 dnode_verify(dnode_t *dn) | |
194 { | |
195 int drop_struct_lock = FALSE; | |
196 | |
197 ASSERT(dn->dn_phys); | |
198 ASSERT(dn->dn_objset); | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
199 ASSERT(dn->dn_handle->dnh_dnode == dn); |
789 | 200 |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12684
diff
changeset
|
201 ASSERT(DMU_OT_IS_VALID(dn->dn_phys->dn_type)); |
789 | 202 |
203 if (!(zfs_flags & ZFS_DEBUG_DNODE_VERIFY)) | |
204 return; | |
205 | |
206 if (!RW_WRITE_HELD(&dn->dn_struct_rwlock)) { | |
207 rw_enter(&dn->dn_struct_rwlock, RW_READER); | |
208 drop_struct_lock = TRUE; | |
209 } | |
210 if (dn->dn_phys->dn_type != DMU_OT_NONE || dn->dn_allocated_txg != 0) { | |
211 int i; | |
212 ASSERT3U(dn->dn_indblkshift, >=, 0); | |
213 ASSERT3U(dn->dn_indblkshift, <=, SPA_MAXBLOCKSHIFT); | |
214 if (dn->dn_datablkshift) { | |
215 ASSERT3U(dn->dn_datablkshift, >=, SPA_MINBLOCKSHIFT); | |
216 ASSERT3U(dn->dn_datablkshift, <=, SPA_MAXBLOCKSHIFT); | |
217 ASSERT3U(1<<dn->dn_datablkshift, ==, dn->dn_datablksz); | |
218 } | |
219 ASSERT3U(dn->dn_nlevels, <=, 30); | |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12684
diff
changeset
|
220 ASSERT(DMU_OT_IS_VALID(dn->dn_type)); |
789 | 221 ASSERT3U(dn->dn_nblkptr, >=, 1); |
222 ASSERT3U(dn->dn_nblkptr, <=, DN_MAX_NBLKPTR); | |
223 ASSERT3U(dn->dn_bonuslen, <=, DN_MAX_BONUSLEN); | |
224 ASSERT3U(dn->dn_datablksz, ==, | |
225 dn->dn_datablkszsec << SPA_MINBLOCKSHIFT); | |
226 ASSERT3U(ISP2(dn->dn_datablksz), ==, dn->dn_datablkshift != 0); | |
227 ASSERT3U((dn->dn_nblkptr - 1) * sizeof (blkptr_t) + | |
228 dn->dn_bonuslen, <=, DN_MAX_BONUSLEN); | |
229 for (i = 0; i < TXG_SIZE; i++) { | |
230 ASSERT3U(dn->dn_next_nlevels[i], <=, dn->dn_nlevels); | |
231 } | |
232 } | |
233 if (dn->dn_phys->dn_type != DMU_OT_NONE) | |
234 ASSERT3U(dn->dn_phys->dn_nlevels, <=, dn->dn_nlevels); | |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
235 ASSERT(DMU_OBJECT_IS_SPECIAL(dn->dn_object) || dn->dn_dbuf != NULL); |
789 | 236 if (dn->dn_dbuf != NULL) { |
237 ASSERT3P(dn->dn_phys, ==, | |
238 (dnode_phys_t *)dn->dn_dbuf->db.db_data + | |
239 (dn->dn_object % (dn->dn_dbuf->db.db_size >> DNODE_SHIFT))); | |
240 } | |
241 if (drop_struct_lock) | |
242 rw_exit(&dn->dn_struct_rwlock); | |
873
adefbfa5f42d
6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents:
789
diff
changeset
|
243 } |
789 | 244 #endif |
245 | |
246 void | |
247 dnode_byteswap(dnode_phys_t *dnp) | |
248 { | |
249 uint64_t *buf64 = (void*)&dnp->dn_blkptr; | |
250 int i; | |
251 | |
252 if (dnp->dn_type == DMU_OT_NONE) { | |
253 bzero(dnp, sizeof (dnode_phys_t)); | |
254 return; | |
255 } | |
256 | |
257 dnp->dn_datablkszsec = BSWAP_16(dnp->dn_datablkszsec); | |
258 dnp->dn_bonuslen = BSWAP_16(dnp->dn_bonuslen); | |
259 dnp->dn_maxblkid = BSWAP_64(dnp->dn_maxblkid); | |
2082 | 260 dnp->dn_used = BSWAP_64(dnp->dn_used); |
789 | 261 |
262 /* | |
263 * dn_nblkptr is only one byte, so it's OK to read it in either | |
264 * byte order. We can't read dn_bouslen. | |
265 */ | |
266 ASSERT(dnp->dn_indblkshift <= SPA_MAXBLOCKSHIFT); | |
267 ASSERT(dnp->dn_nblkptr <= DN_MAX_NBLKPTR); | |
268 for (i = 0; i < dnp->dn_nblkptr * sizeof (blkptr_t)/8; i++) | |
269 buf64[i] = BSWAP_64(buf64[i]); | |
270 | |
271 /* | |
272 * OK to check dn_bonuslen for zero, because it won't matter if | |
273 * we have the wrong byte order. This is necessary because the | |
274 * dnode dnode is smaller than a regular dnode. | |
275 */ | |
276 if (dnp->dn_bonuslen != 0) { | |
277 /* | |
278 * Note that the bonus length calculated here may be | |
279 * longer than the actual bonus buffer. This is because | |
280 * we always put the bonus buffer after the last block | |
281 * pointer (instead of packing it against the end of the | |
282 * dnode buffer). | |
283 */ | |
284 int off = (dnp->dn_nblkptr-1) * sizeof (blkptr_t); | |
285 size_t len = DN_MAX_BONUSLEN - off; | |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12684
diff
changeset
|
286 ASSERT(DMU_OT_IS_VALID(dnp->dn_bonustype)); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12684
diff
changeset
|
287 dmu_object_byteswap_t byteswap = |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12684
diff
changeset
|
288 DMU_OT_BYTESWAP(dnp->dn_bonustype); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12684
diff
changeset
|
289 dmu_ot_byteswap[byteswap].ob_func(dnp->dn_bonus + off, len); |
789 | 290 } |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
291 |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
292 /* Swap SPILL block if we have one */ |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
293 if (dnp->dn_flags & DNODE_FLAG_SPILL_BLKPTR) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
294 byteswap_uint64_array(&dnp->dn_spill, sizeof (blkptr_t)); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
295 |
789 | 296 } |
297 | |
298 void | |
299 dnode_buf_byteswap(void *vbuf, size_t size) | |
300 { | |
301 dnode_phys_t *buf = vbuf; | |
302 int i; | |
303 | |
304 ASSERT3U(sizeof (dnode_phys_t), ==, (1<<DNODE_SHIFT)); | |
305 ASSERT((size & (sizeof (dnode_phys_t)-1)) == 0); | |
306 | |
307 size >>= DNODE_SHIFT; | |
308 for (i = 0; i < size; i++) { | |
309 dnode_byteswap(buf); | |
310 buf++; | |
311 } | |
312 } | |
313 | |
314 static int | |
315 free_range_compar(const void *node1, const void *node2) | |
316 { | |
317 const free_range_t *rp1 = node1; | |
318 const free_range_t *rp2 = node2; | |
319 | |
320 if (rp1->fr_blkid < rp2->fr_blkid) | |
321 return (-1); | |
322 else if (rp1->fr_blkid > rp2->fr_blkid) | |
323 return (1); | |
324 else return (0); | |
325 } | |
326 | |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
327 void |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
328 dnode_setbonuslen(dnode_t *dn, int newsize, dmu_tx_t *tx) |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
329 { |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
330 ASSERT3U(refcount_count(&dn->dn_holds), >=, 1); |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
331 |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
332 dnode_setdirty(dn, tx); |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
333 rw_enter(&dn->dn_struct_rwlock, RW_WRITER); |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
334 ASSERT3U(newsize, <=, DN_MAX_BONUSLEN - |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
335 (dn->dn_nblkptr-1) * sizeof (blkptr_t)); |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
336 dn->dn_bonuslen = newsize; |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
337 if (newsize == 0) |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
338 dn->dn_next_bonuslen[tx->tx_txg & TXG_MASK] = DN_ZERO_BONUSLEN; |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
339 else |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
340 dn->dn_next_bonuslen[tx->tx_txg & TXG_MASK] = dn->dn_bonuslen; |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
341 rw_exit(&dn->dn_struct_rwlock); |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
342 } |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
343 |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
344 void |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
345 dnode_setbonus_type(dnode_t *dn, dmu_object_type_t newtype, dmu_tx_t *tx) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
346 { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
347 ASSERT3U(refcount_count(&dn->dn_holds), >=, 1); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
348 dnode_setdirty(dn, tx); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
349 rw_enter(&dn->dn_struct_rwlock, RW_WRITER); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
350 dn->dn_bonustype = newtype; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
351 dn->dn_next_bonustype[tx->tx_txg & TXG_MASK] = dn->dn_bonustype; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
352 rw_exit(&dn->dn_struct_rwlock); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
353 } |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
354 |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
355 void |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
356 dnode_rm_spill(dnode_t *dn, dmu_tx_t *tx) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
357 { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
358 ASSERT3U(refcount_count(&dn->dn_holds), >=, 1); |
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:
11958
diff
changeset
|
359 ASSERT(RW_WRITE_HELD(&dn->dn_struct_rwlock)); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
360 dnode_setdirty(dn, tx); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
361 dn->dn_rm_spillblk[tx->tx_txg&TXG_MASK] = DN_KILL_SPILLBLK; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
362 dn->dn_have_spill = B_FALSE; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
363 } |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
364 |
789 | 365 static void |
366 dnode_setdblksz(dnode_t *dn, int size) | |
367 { | |
13805
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
368 ASSERT0(P2PHASE(size, SPA_MINBLOCKSIZE)); |
789 | 369 ASSERT3U(size, <=, SPA_MAXBLOCKSIZE); |
370 ASSERT3U(size, >=, SPA_MINBLOCKSIZE); | |
371 ASSERT3U(size >> SPA_MINBLOCKSHIFT, <, | |
372 1<<(sizeof (dn->dn_phys->dn_datablkszsec) * 8)); | |
373 dn->dn_datablksz = size; | |
374 dn->dn_datablkszsec = size >> SPA_MINBLOCKSHIFT; | |
375 dn->dn_datablkshift = ISP2(size) ? highbit(size - 1) : 0; | |
376 } | |
377 | |
378 static dnode_t * | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9950
diff
changeset
|
379 dnode_create(objset_t *os, dnode_phys_t *dnp, dmu_buf_impl_t *db, |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
380 uint64_t object, dnode_handle_t *dnh) |
789 | 381 { |
382 dnode_t *dn = kmem_cache_alloc(dnode_cache, KM_SLEEP); | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
383 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
384 ASSERT(!POINTER_IS_VALID(dn->dn_objset)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
385 dn->dn_moved = 0; |
789 | 386 |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
387 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
388 * Defer setting dn_objset until the dnode is ready to be a candidate |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
389 * for the dnode_move() callback. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
390 */ |
789 | 391 dn->dn_object = object; |
392 dn->dn_dbuf = db; | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
393 dn->dn_handle = dnh; |
789 | 394 dn->dn_phys = dnp; |
395 | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
396 if (dnp->dn_datablkszsec) { |
789 | 397 dnode_setdblksz(dn, dnp->dn_datablkszsec << SPA_MINBLOCKSHIFT); |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
398 } else { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
399 dn->dn_datablksz = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
400 dn->dn_datablkszsec = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
401 dn->dn_datablkshift = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
402 } |
789 | 403 dn->dn_indblkshift = dnp->dn_indblkshift; |
404 dn->dn_nlevels = dnp->dn_nlevels; | |
405 dn->dn_type = dnp->dn_type; | |
406 dn->dn_nblkptr = dnp->dn_nblkptr; | |
407 dn->dn_checksum = dnp->dn_checksum; | |
408 dn->dn_compress = dnp->dn_compress; | |
409 dn->dn_bonustype = dnp->dn_bonustype; | |
410 dn->dn_bonuslen = dnp->dn_bonuslen; | |
411 dn->dn_maxblkid = dnp->dn_maxblkid; | |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
412 dn->dn_have_spill = ((dnp->dn_flags & DNODE_FLAG_SPILL_BLKPTR) != 0); |
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:
11958
diff
changeset
|
413 dn->dn_id_flags = 0; |
789 | 414 |
415 dmu_zfetch_init(&dn->dn_zfetch, dn); | |
416 | |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12684
diff
changeset
|
417 ASSERT(DMU_OT_IS_VALID(dn->dn_phys->dn_type)); |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
418 |
789 | 419 mutex_enter(&os->os_lock); |
420 list_insert_head(&os->os_dnodes, dn); | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
421 membar_producer(); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
422 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
423 * Everything else must be valid before assigning dn_objset makes the |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
424 * dnode eligible for dnode_move(). |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
425 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
426 dn->dn_objset = os; |
789 | 427 mutex_exit(&os->os_lock); |
428 | |
8582
df9361868dbe
6748019 ARC/L2ARC metadata accounting for arc_size
Brendan Gregg - Sun Microsystems <Brendan.Gregg@Sun.COM>
parents:
8214
diff
changeset
|
429 arc_space_consume(sizeof (dnode_t), ARC_SPACE_OTHER); |
789 | 430 return (dn); |
431 } | |
432 | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
433 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
434 * Caller must be holding the dnode handle, which is released upon return. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
435 */ |
789 | 436 static void |
437 dnode_destroy(dnode_t *dn) | |
438 { | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9950
diff
changeset
|
439 objset_t *os = dn->dn_objset; |
789 | 440 |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
441 ASSERT((dn->dn_id_flags & DN_ID_NEW_EXIST) == 0); |
2885 | 442 |
789 | 443 mutex_enter(&os->os_lock); |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
444 POINTER_INVALIDATE(&dn->dn_objset); |
789 | 445 list_remove(&os->os_dnodes, dn); |
446 mutex_exit(&os->os_lock); | |
447 | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
448 /* the dnode can no longer move, so we can release the handle */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
449 zrl_remove(&dn->dn_handle->dnh_zrlock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
450 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
451 dn->dn_allocated_txg = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
452 dn->dn_free_txg = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
453 dn->dn_assigned_txg = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
454 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
455 dn->dn_dirtyctx = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
456 if (dn->dn_dirtyctx_firstset != NULL) { |
789 | 457 kmem_free(dn->dn_dirtyctx_firstset, 1); |
458 dn->dn_dirtyctx_firstset = NULL; | |
459 } | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
460 if (dn->dn_bonus != NULL) { |
1544 | 461 mutex_enter(&dn->dn_bonus->db_mtx); |
462 dbuf_evict(dn->dn_bonus); | |
463 dn->dn_bonus = NULL; | |
464 } | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
465 dn->dn_zio = NULL; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
466 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
467 dn->dn_have_spill = B_FALSE; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
468 dn->dn_oldused = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
469 dn->dn_oldflags = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
470 dn->dn_olduid = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
471 dn->dn_oldgid = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
472 dn->dn_newuid = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
473 dn->dn_newgid = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
474 dn->dn_id_flags = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
475 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
476 dmu_zfetch_rele(&dn->dn_zfetch); |
789 | 477 kmem_cache_free(dnode_cache, dn); |
8582
df9361868dbe
6748019 ARC/L2ARC metadata accounting for arc_size
Brendan Gregg - Sun Microsystems <Brendan.Gregg@Sun.COM>
parents:
8214
diff
changeset
|
478 arc_space_return(sizeof (dnode_t), ARC_SPACE_OTHER); |
789 | 479 } |
480 | |
481 void | |
482 dnode_allocate(dnode_t *dn, dmu_object_type_t ot, int blocksize, int ibs, | |
1599 | 483 dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx) |
789 | 484 { |
485 int i; | |
486 | |
487 if (blocksize == 0) | |
488 blocksize = 1 << zfs_default_bs; | |
1402 | 489 else if (blocksize > SPA_MAXBLOCKSIZE) |
490 blocksize = SPA_MAXBLOCKSIZE; | |
491 else | |
492 blocksize = P2ROUNDUP(blocksize, SPA_MINBLOCKSIZE); | |
789 | 493 |
494 if (ibs == 0) | |
495 ibs = zfs_default_ibs; | |
496 | |
497 ibs = MIN(MAX(ibs, DN_MIN_INDBLKSHIFT), DN_MAX_INDBLKSHIFT); | |
498 | |
499 dprintf("os=%p obj=%llu txg=%llu blocksize=%d ibs=%d\n", dn->dn_objset, | |
500 dn->dn_object, tx->tx_txg, blocksize, ibs); | |
501 | |
502 ASSERT(dn->dn_type == DMU_OT_NONE); | |
503 ASSERT(bcmp(dn->dn_phys, &dnode_phys_zero, sizeof (dnode_phys_t)) == 0); | |
504 ASSERT(dn->dn_phys->dn_type == DMU_OT_NONE); | |
505 ASSERT(ot != DMU_OT_NONE); | |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12684
diff
changeset
|
506 ASSERT(DMU_OT_IS_VALID(ot)); |
789 | 507 ASSERT((bonustype == DMU_OT_NONE && bonuslen == 0) || |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
508 (bonustype == DMU_OT_SA && bonuslen == 0) || |
789 | 509 (bonustype != DMU_OT_NONE && bonuslen != 0)); |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12684
diff
changeset
|
510 ASSERT(DMU_OT_IS_VALID(bonustype)); |
789 | 511 ASSERT3U(bonuslen, <=, DN_MAX_BONUSLEN); |
512 ASSERT(dn->dn_type == DMU_OT_NONE); | |
13805
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
513 ASSERT0(dn->dn_maxblkid); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
514 ASSERT0(dn->dn_allocated_txg); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
515 ASSERT0(dn->dn_assigned_txg); |
789 | 516 ASSERT(refcount_is_zero(&dn->dn_tx_holds)); |
517 ASSERT3U(refcount_count(&dn->dn_holds), <=, 1); | |
518 ASSERT3P(list_head(&dn->dn_dbufs), ==, NULL); | |
519 | |
520 for (i = 0; i < TXG_SIZE; i++) { | |
13805
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
521 ASSERT0(dn->dn_next_nblkptr[i]); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
522 ASSERT0(dn->dn_next_nlevels[i]); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
523 ASSERT0(dn->dn_next_indblkshift[i]); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
524 ASSERT0(dn->dn_next_bonuslen[i]); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
525 ASSERT0(dn->dn_next_bonustype[i]); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
526 ASSERT0(dn->dn_rm_spillblk[i]); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
527 ASSERT0(dn->dn_next_blksz[i]); |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
528 ASSERT(!list_link_active(&dn->dn_dirty_link[i])); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
529 ASSERT3P(list_head(&dn->dn_dirty_records[i]), ==, NULL); |
13805
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
530 ASSERT0(avl_numnodes(&dn->dn_ranges[i])); |
789 | 531 } |
532 | |
533 dn->dn_type = ot; | |
534 dnode_setdblksz(dn, blocksize); | |
535 dn->dn_indblkshift = ibs; | |
536 dn->dn_nlevels = 1; | |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
537 if (bonustype == DMU_OT_SA) /* Maximize bonus space for SA */ |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
538 dn->dn_nblkptr = 1; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
539 else |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
540 dn->dn_nblkptr = 1 + |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
541 ((DN_MAX_BONUSLEN - bonuslen) >> SPA_BLKPTRSHIFT); |
789 | 542 dn->dn_bonustype = bonustype; |
543 dn->dn_bonuslen = bonuslen; | |
544 dn->dn_checksum = ZIO_CHECKSUM_INHERIT; | |
545 dn->dn_compress = ZIO_COMPRESS_INHERIT; | |
546 dn->dn_dirtyctx = 0; | |
547 | |
548 dn->dn_free_txg = 0; | |
549 if (dn->dn_dirtyctx_firstset) { | |
550 kmem_free(dn->dn_dirtyctx_firstset, 1); | |
551 dn->dn_dirtyctx_firstset = NULL; | |
552 } | |
553 | |
554 dn->dn_allocated_txg = tx->tx_txg; | |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
555 dn->dn_id_flags = 0; |
1599 | 556 |
789 | 557 dnode_setdirty(dn, tx); |
1599 | 558 dn->dn_next_indblkshift[tx->tx_txg & TXG_MASK] = ibs; |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
559 dn->dn_next_bonuslen[tx->tx_txg & TXG_MASK] = dn->dn_bonuslen; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
560 dn->dn_next_bonustype[tx->tx_txg & TXG_MASK] = dn->dn_bonustype; |
1599 | 561 dn->dn_next_blksz[tx->tx_txg & TXG_MASK] = dn->dn_datablksz; |
789 | 562 } |
563 | |
564 void | |
565 dnode_reallocate(dnode_t *dn, dmu_object_type_t ot, int blocksize, | |
566 dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx) | |
567 { | |
8986
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
568 int nblkptr; |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
569 |
789 | 570 ASSERT3U(blocksize, >=, SPA_MINBLOCKSIZE); |
571 ASSERT3U(blocksize, <=, SPA_MAXBLOCKSIZE); | |
13805
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
572 ASSERT0(blocksize % SPA_MINBLOCKSIZE); |
1544 | 573 ASSERT(dn->dn_object != DMU_META_DNODE_OBJECT || dmu_tx_private_ok(tx)); |
789 | 574 ASSERT(tx->tx_txg != 0); |
575 ASSERT((bonustype == DMU_OT_NONE && bonuslen == 0) || | |
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:
11958
diff
changeset
|
576 (bonustype != DMU_OT_NONE && bonuslen != 0) || |
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:
11958
diff
changeset
|
577 (bonustype == DMU_OT_SA && bonuslen == 0)); |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12684
diff
changeset
|
578 ASSERT(DMU_OT_IS_VALID(bonustype)); |
789 | 579 ASSERT3U(bonuslen, <=, DN_MAX_BONUSLEN); |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
580 |
1544 | 581 /* clean up any unreferenced dbufs */ |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
582 dnode_evict_dbufs(dn); |
1544 | 583 |
12432
222dd376dd6c
6952522 elpaso panics: assertion failed: refcount_is_zero(&dn->dn_holds), file: ../../common/fs/zfs/dnode.c
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
12411
diff
changeset
|
584 dn->dn_id_flags = 0; |
222dd376dd6c
6952522 elpaso panics: assertion failed: refcount_is_zero(&dn->dn_holds), file: ../../common/fs/zfs/dnode.c
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
12411
diff
changeset
|
585 |
8986
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
586 rw_enter(&dn->dn_struct_rwlock, RW_WRITER); |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
587 dnode_setdirty(dn, tx); |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
588 if (dn->dn_datablksz != blocksize) { |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
589 /* change blocksize */ |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
590 ASSERT(dn->dn_maxblkid == 0 && |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
591 (BP_IS_HOLE(&dn->dn_phys->dn_blkptr[0]) || |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
592 dnode_block_freed(dn, 0))); |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
593 dnode_setdblksz(dn, blocksize); |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
594 dn->dn_next_blksz[tx->tx_txg&TXG_MASK] = blocksize; |
789 | 595 } |
8986
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
596 if (dn->dn_bonuslen != bonuslen) |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
597 dn->dn_next_bonuslen[tx->tx_txg&TXG_MASK] = bonuslen; |
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:
11958
diff
changeset
|
598 |
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:
11958
diff
changeset
|
599 if (bonustype == DMU_OT_SA) /* Maximize bonus space for SA */ |
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:
11958
diff
changeset
|
600 nblkptr = 1; |
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:
11958
diff
changeset
|
601 else |
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:
11958
diff
changeset
|
602 nblkptr = 1 + ((DN_MAX_BONUSLEN - bonuslen) >> SPA_BLKPTRSHIFT); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
603 if (dn->dn_bonustype != bonustype) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
604 dn->dn_next_bonustype[tx->tx_txg&TXG_MASK] = bonustype; |
8644
10534c530688
6793373 assertion failed in dnode_reallocate: dn_nblkptr >= old_nblkptr
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8582
diff
changeset
|
605 if (dn->dn_nblkptr != nblkptr) |
10534c530688
6793373 assertion failed in dnode_reallocate: dn_nblkptr >= old_nblkptr
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8582
diff
changeset
|
606 dn->dn_next_nblkptr[tx->tx_txg&TXG_MASK] = nblkptr; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
607 if (dn->dn_phys->dn_flags & DNODE_FLAG_SPILL_BLKPTR) { |
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:
11958
diff
changeset
|
608 dbuf_rm_spill(dn, tx); |
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:
11958
diff
changeset
|
609 dnode_rm_spill(dn, tx); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
610 } |
789 | 611 rw_exit(&dn->dn_struct_rwlock); |
612 | |
613 /* change type */ | |
614 dn->dn_type = ot; | |
615 | |
616 /* change bonus size and type */ | |
617 mutex_enter(&dn->dn_mtx); | |
618 dn->dn_bonustype = bonustype; | |
619 dn->dn_bonuslen = bonuslen; | |
8644
10534c530688
6793373 assertion failed in dnode_reallocate: dn_nblkptr >= old_nblkptr
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8582
diff
changeset
|
620 dn->dn_nblkptr = nblkptr; |
789 | 621 dn->dn_checksum = ZIO_CHECKSUM_INHERIT; |
622 dn->dn_compress = ZIO_COMPRESS_INHERIT; | |
623 ASSERT3U(dn->dn_nblkptr, <=, DN_MAX_NBLKPTR); | |
624 | |
8644
10534c530688
6793373 assertion failed in dnode_reallocate: dn_nblkptr >= old_nblkptr
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8582
diff
changeset
|
625 /* fix up the bonus db_size */ |
10534c530688
6793373 assertion failed in dnode_reallocate: dn_nblkptr >= old_nblkptr
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8582
diff
changeset
|
626 if (dn->dn_bonus) { |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
627 dn->dn_bonus->db.db_size = |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
628 DN_MAX_BONUSLEN - (dn->dn_nblkptr-1) * sizeof (blkptr_t); |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
629 ASSERT(dn->dn_bonuslen <= dn->dn_bonus->db.db_size); |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
630 } |
3087 | 631 |
789 | 632 dn->dn_allocated_txg = tx->tx_txg; |
633 mutex_exit(&dn->dn_mtx); | |
634 } | |
635 | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
636 #ifdef DNODE_STATS |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
637 static struct { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
638 uint64_t dms_dnode_invalid; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
639 uint64_t dms_dnode_recheck1; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
640 uint64_t dms_dnode_recheck2; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
641 uint64_t dms_dnode_special; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
642 uint64_t dms_dnode_handle; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
643 uint64_t dms_dnode_rwlock; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
644 uint64_t dms_dnode_active; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
645 } dnode_move_stats; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
646 #endif /* DNODE_STATS */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
647 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
648 static void |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
649 dnode_move_impl(dnode_t *odn, dnode_t *ndn) |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
650 { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
651 int i; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
652 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
653 ASSERT(!RW_LOCK_HELD(&odn->dn_struct_rwlock)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
654 ASSERT(MUTEX_NOT_HELD(&odn->dn_mtx)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
655 ASSERT(MUTEX_NOT_HELD(&odn->dn_dbufs_mtx)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
656 ASSERT(!RW_LOCK_HELD(&odn->dn_zfetch.zf_rwlock)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
657 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
658 /* Copy fields. */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
659 ndn->dn_objset = odn->dn_objset; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
660 ndn->dn_object = odn->dn_object; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
661 ndn->dn_dbuf = odn->dn_dbuf; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
662 ndn->dn_handle = odn->dn_handle; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
663 ndn->dn_phys = odn->dn_phys; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
664 ndn->dn_type = odn->dn_type; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
665 ndn->dn_bonuslen = odn->dn_bonuslen; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
666 ndn->dn_bonustype = odn->dn_bonustype; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
667 ndn->dn_nblkptr = odn->dn_nblkptr; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
668 ndn->dn_checksum = odn->dn_checksum; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
669 ndn->dn_compress = odn->dn_compress; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
670 ndn->dn_nlevels = odn->dn_nlevels; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
671 ndn->dn_indblkshift = odn->dn_indblkshift; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
672 ndn->dn_datablkshift = odn->dn_datablkshift; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
673 ndn->dn_datablkszsec = odn->dn_datablkszsec; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
674 ndn->dn_datablksz = odn->dn_datablksz; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
675 ndn->dn_maxblkid = odn->dn_maxblkid; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
676 bcopy(&odn->dn_next_nblkptr[0], &ndn->dn_next_nblkptr[0], |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
677 sizeof (odn->dn_next_nblkptr)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
678 bcopy(&odn->dn_next_nlevels[0], &ndn->dn_next_nlevels[0], |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
679 sizeof (odn->dn_next_nlevels)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
680 bcopy(&odn->dn_next_indblkshift[0], &ndn->dn_next_indblkshift[0], |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
681 sizeof (odn->dn_next_indblkshift)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
682 bcopy(&odn->dn_next_bonustype[0], &ndn->dn_next_bonustype[0], |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
683 sizeof (odn->dn_next_bonustype)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
684 bcopy(&odn->dn_rm_spillblk[0], &ndn->dn_rm_spillblk[0], |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
685 sizeof (odn->dn_rm_spillblk)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
686 bcopy(&odn->dn_next_bonuslen[0], &ndn->dn_next_bonuslen[0], |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
687 sizeof (odn->dn_next_bonuslen)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
688 bcopy(&odn->dn_next_blksz[0], &ndn->dn_next_blksz[0], |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
689 sizeof (odn->dn_next_blksz)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
690 for (i = 0; i < TXG_SIZE; i++) { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
691 list_move_tail(&ndn->dn_dirty_records[i], |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
692 &odn->dn_dirty_records[i]); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
693 } |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
694 bcopy(&odn->dn_ranges[0], &ndn->dn_ranges[0], sizeof (odn->dn_ranges)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
695 ndn->dn_allocated_txg = odn->dn_allocated_txg; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
696 ndn->dn_free_txg = odn->dn_free_txg; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
697 ndn->dn_assigned_txg = odn->dn_assigned_txg; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
698 ndn->dn_dirtyctx = odn->dn_dirtyctx; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
699 ndn->dn_dirtyctx_firstset = odn->dn_dirtyctx_firstset; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
700 ASSERT(refcount_count(&odn->dn_tx_holds) == 0); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
701 refcount_transfer(&ndn->dn_holds, &odn->dn_holds); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
702 ASSERT(list_is_empty(&ndn->dn_dbufs)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
703 list_move_tail(&ndn->dn_dbufs, &odn->dn_dbufs); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
704 ndn->dn_dbufs_count = odn->dn_dbufs_count; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
705 ndn->dn_bonus = odn->dn_bonus; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
706 ndn->dn_have_spill = odn->dn_have_spill; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
707 ndn->dn_zio = odn->dn_zio; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
708 ndn->dn_oldused = odn->dn_oldused; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
709 ndn->dn_oldflags = odn->dn_oldflags; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
710 ndn->dn_olduid = odn->dn_olduid; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
711 ndn->dn_oldgid = odn->dn_oldgid; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
712 ndn->dn_newuid = odn->dn_newuid; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
713 ndn->dn_newgid = odn->dn_newgid; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
714 ndn->dn_id_flags = odn->dn_id_flags; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
715 dmu_zfetch_init(&ndn->dn_zfetch, NULL); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
716 list_move_tail(&ndn->dn_zfetch.zf_stream, &odn->dn_zfetch.zf_stream); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
717 ndn->dn_zfetch.zf_dnode = odn->dn_zfetch.zf_dnode; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
718 ndn->dn_zfetch.zf_stream_cnt = odn->dn_zfetch.zf_stream_cnt; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
719 ndn->dn_zfetch.zf_alloc_fail = odn->dn_zfetch.zf_alloc_fail; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
720 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
721 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
722 * Update back pointers. Updating the handle fixes the back pointer of |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
723 * every descendant dbuf as well as the bonus dbuf. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
724 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
725 ASSERT(ndn->dn_handle->dnh_dnode == odn); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
726 ndn->dn_handle->dnh_dnode = ndn; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
727 if (ndn->dn_zfetch.zf_dnode == odn) { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
728 ndn->dn_zfetch.zf_dnode = ndn; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
729 } |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
730 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
731 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
732 * Invalidate the original dnode by clearing all of its back pointers. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
733 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
734 odn->dn_dbuf = NULL; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
735 odn->dn_handle = NULL; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
736 list_create(&odn->dn_dbufs, sizeof (dmu_buf_impl_t), |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
737 offsetof(dmu_buf_impl_t, db_link)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
738 odn->dn_dbufs_count = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
739 odn->dn_bonus = NULL; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
740 odn->dn_zfetch.zf_dnode = NULL; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
741 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
742 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
743 * Set the low bit of the objset pointer to ensure that dnode_move() |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
744 * recognizes the dnode as invalid in any subsequent callback. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
745 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
746 POINTER_INVALIDATE(&odn->dn_objset); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
747 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
748 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
749 * Satisfy the destructor. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
750 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
751 for (i = 0; i < TXG_SIZE; i++) { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
752 list_create(&odn->dn_dirty_records[i], |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
753 sizeof (dbuf_dirty_record_t), |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
754 offsetof(dbuf_dirty_record_t, dr_dirty_node)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
755 odn->dn_ranges[i].avl_root = NULL; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
756 odn->dn_ranges[i].avl_numnodes = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
757 odn->dn_next_nlevels[i] = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
758 odn->dn_next_indblkshift[i] = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
759 odn->dn_next_bonustype[i] = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
760 odn->dn_rm_spillblk[i] = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
761 odn->dn_next_bonuslen[i] = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
762 odn->dn_next_blksz[i] = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
763 } |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
764 odn->dn_allocated_txg = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
765 odn->dn_free_txg = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
766 odn->dn_assigned_txg = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
767 odn->dn_dirtyctx = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
768 odn->dn_dirtyctx_firstset = NULL; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
769 odn->dn_have_spill = B_FALSE; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
770 odn->dn_zio = NULL; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
771 odn->dn_oldused = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
772 odn->dn_oldflags = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
773 odn->dn_olduid = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
774 odn->dn_oldgid = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
775 odn->dn_newuid = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
776 odn->dn_newgid = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
777 odn->dn_id_flags = 0; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
778 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
779 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
780 * Mark the dnode. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
781 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
782 ndn->dn_moved = 1; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
783 odn->dn_moved = (uint8_t)-1; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
784 } |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
785 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
786 #ifdef _KERNEL |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
787 /*ARGSUSED*/ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
788 static kmem_cbrc_t |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
789 dnode_move(void *buf, void *newbuf, size_t size, void *arg) |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
790 { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
791 dnode_t *odn = buf, *ndn = newbuf; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
792 objset_t *os; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
793 int64_t refcount; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
794 uint32_t dbufs; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
795 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
796 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
797 * The dnode is on the objset's list of known dnodes if the objset |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
798 * pointer is valid. We set the low bit of the objset pointer when |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
799 * freeing the dnode to invalidate it, and the memory patterns written |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
800 * by kmem (baddcafe and deadbeef) set at least one of the two low bits. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
801 * A newly created dnode sets the objset pointer last of all to indicate |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
802 * that the dnode is known and in a valid state to be moved by this |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
803 * function. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
804 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
805 os = odn->dn_objset; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
806 if (!POINTER_IS_VALID(os)) { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
807 DNODE_STAT_ADD(dnode_move_stats.dms_dnode_invalid); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
808 return (KMEM_CBRC_DONT_KNOW); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
809 } |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
810 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
811 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
812 * Ensure that the objset does not go away during the move. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
813 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
814 rw_enter(&os_lock, RW_WRITER); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
815 if (os != odn->dn_objset) { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
816 rw_exit(&os_lock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
817 DNODE_STAT_ADD(dnode_move_stats.dms_dnode_recheck1); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
818 return (KMEM_CBRC_DONT_KNOW); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
819 } |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
820 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
821 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
822 * If the dnode is still valid, then so is the objset. We know that no |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
823 * valid objset can be freed while we hold os_lock, so we can safely |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
824 * ensure that the objset remains in use. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
825 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
826 mutex_enter(&os->os_lock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
827 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
828 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
829 * Recheck the objset pointer in case the dnode was removed just before |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
830 * acquiring the lock. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
831 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
832 if (os != odn->dn_objset) { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
833 mutex_exit(&os->os_lock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
834 rw_exit(&os_lock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
835 DNODE_STAT_ADD(dnode_move_stats.dms_dnode_recheck2); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
836 return (KMEM_CBRC_DONT_KNOW); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
837 } |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
838 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
839 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
840 * At this point we know that as long as we hold os->os_lock, the dnode |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
841 * cannot be freed and fields within the dnode can be safely accessed. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
842 * The objset listing this dnode cannot go away as long as this dnode is |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
843 * on its list. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
844 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
845 rw_exit(&os_lock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
846 if (DMU_OBJECT_IS_SPECIAL(odn->dn_object)) { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
847 mutex_exit(&os->os_lock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
848 DNODE_STAT_ADD(dnode_move_stats.dms_dnode_special); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
849 return (KMEM_CBRC_NO); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
850 } |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
851 ASSERT(odn->dn_dbuf != NULL); /* only "special" dnodes have no parent */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
852 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
853 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
854 * Lock the dnode handle to prevent the dnode from obtaining any new |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
855 * holds. This also prevents the descendant dbufs and the bonus dbuf |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
856 * from accessing the dnode, so that we can discount their holds. The |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
857 * handle is safe to access because we know that while the dnode cannot |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
858 * go away, neither can its handle. Once we hold dnh_zrlock, we can |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
859 * safely move any dnode referenced only by dbufs. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
860 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
861 if (!zrl_tryenter(&odn->dn_handle->dnh_zrlock)) { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
862 mutex_exit(&os->os_lock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
863 DNODE_STAT_ADD(dnode_move_stats.dms_dnode_handle); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
864 return (KMEM_CBRC_LATER); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
865 } |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
866 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
867 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
868 * Ensure a consistent view of the dnode's holds and the dnode's dbufs. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
869 * We need to guarantee that there is a hold for every dbuf in order to |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
870 * determine whether the dnode is actively referenced. Falsely matching |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
871 * a dbuf to an active hold would lead to an unsafe move. It's possible |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
872 * that a thread already having an active dnode hold is about to add a |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
873 * dbuf, and we can't compare hold and dbuf counts while the add is in |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
874 * progress. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
875 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
876 if (!rw_tryenter(&odn->dn_struct_rwlock, RW_WRITER)) { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
877 zrl_exit(&odn->dn_handle->dnh_zrlock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
878 mutex_exit(&os->os_lock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
879 DNODE_STAT_ADD(dnode_move_stats.dms_dnode_rwlock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
880 return (KMEM_CBRC_LATER); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
881 } |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
882 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
883 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
884 * A dbuf may be removed (evicted) without an active dnode hold. In that |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
885 * case, the dbuf count is decremented under the handle lock before the |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
886 * dbuf's hold is released. This order ensures that if we count the hold |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
887 * after the dbuf is removed but before its hold is released, we will |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
888 * treat the unmatched hold as active and exit safely. If we count the |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
889 * hold before the dbuf is removed, the hold is discounted, and the |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
890 * removal is blocked until the move completes. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
891 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
892 refcount = refcount_count(&odn->dn_holds); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
893 ASSERT(refcount >= 0); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
894 dbufs = odn->dn_dbufs_count; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
895 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
896 /* We can't have more dbufs than dnode holds. */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
897 ASSERT3U(dbufs, <=, refcount); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
898 DTRACE_PROBE3(dnode__move, dnode_t *, odn, int64_t, refcount, |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
899 uint32_t, dbufs); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
900 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
901 if (refcount > dbufs) { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
902 rw_exit(&odn->dn_struct_rwlock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
903 zrl_exit(&odn->dn_handle->dnh_zrlock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
904 mutex_exit(&os->os_lock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
905 DNODE_STAT_ADD(dnode_move_stats.dms_dnode_active); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
906 return (KMEM_CBRC_LATER); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
907 } |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
908 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
909 rw_exit(&odn->dn_struct_rwlock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
910 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
911 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
912 * At this point we know that anyone with a hold on the dnode is not |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
913 * actively referencing it. The dnode is known and in a valid state to |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
914 * move. We're holding the locks needed to execute the critical section. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
915 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
916 dnode_move_impl(odn, ndn); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
917 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
918 list_link_replace(&odn->dn_link, &ndn->dn_link); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
919 /* If the dnode was safe to move, the refcount cannot have changed. */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
920 ASSERT(refcount == refcount_count(&ndn->dn_holds)); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
921 ASSERT(dbufs == ndn->dn_dbufs_count); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
922 zrl_exit(&ndn->dn_handle->dnh_zrlock); /* handle has moved */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
923 mutex_exit(&os->os_lock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
924 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
925 return (KMEM_CBRC_YES); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
926 } |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
927 #endif /* _KERNEL */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
928 |
789 | 929 void |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
930 dnode_special_close(dnode_handle_t *dnh) |
789 | 931 { |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
932 dnode_t *dn = dnh->dnh_dnode; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
933 |
1544 | 934 /* |
935 * Wait for final references to the dnode to clear. This can | |
936 * only happen if the arc is asyncronously evicting state that | |
937 * has a hold on this dnode while we are trying to evict this | |
938 * dnode. | |
939 */ | |
940 while (refcount_count(&dn->dn_holds) > 0) | |
941 delay(1); | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
942 zrl_add(&dnh->dnh_zrlock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
943 dnode_destroy(dn); /* implicit zrl_remove() */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
944 zrl_destroy(&dnh->dnh_zrlock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
945 dnh->dnh_dnode = NULL; |
789 | 946 } |
947 | |
948 dnode_t * | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
949 dnode_special_open(objset_t *os, dnode_phys_t *dnp, uint64_t object, |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
950 dnode_handle_t *dnh) |
789 | 951 { |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
952 dnode_t *dn = dnode_create(os, dnp, NULL, object, dnh); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
953 dnh->dnh_dnode = dn; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
954 zrl_init(&dnh->dnh_zrlock); |
873
adefbfa5f42d
6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents:
789
diff
changeset
|
955 DNODE_VERIFY(dn); |
789 | 956 return (dn); |
957 } | |
958 | |
959 static void | |
960 dnode_buf_pageout(dmu_buf_t *db, void *arg) | |
961 { | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
962 dnode_children_t *children_dnodes = arg; |
789 | 963 int i; |
964 int epb = db->db_size >> DNODE_SHIFT; | |
965 | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
966 ASSERT(epb == children_dnodes->dnc_count); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
967 |
789 | 968 for (i = 0; i < epb; i++) { |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
969 dnode_handle_t *dnh = &children_dnodes->dnc_children[i]; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
970 dnode_t *dn; |
789 | 971 |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
972 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
973 * The dnode handle lock guards against the dnode moving to |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
974 * another valid address, so there is no need here to guard |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
975 * against changes to or from NULL. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
976 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
977 if (dnh->dnh_dnode == NULL) { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
978 zrl_destroy(&dnh->dnh_zrlock); |
789 | 979 continue; |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
980 } |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
981 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
982 zrl_add(&dnh->dnh_zrlock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
983 dn = dnh->dnh_dnode; |
789 | 984 /* |
985 * If there are holds on this dnode, then there should | |
986 * be holds on the dnode's containing dbuf as well; thus | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
987 * it wouldn't be eligible for eviction and this function |
789 | 988 * would not have been called. |
989 */ | |
990 ASSERT(refcount_is_zero(&dn->dn_holds)); | |
991 ASSERT(refcount_is_zero(&dn->dn_tx_holds)); | |
992 | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
993 dnode_destroy(dn); /* implicit zrl_remove() */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
994 zrl_destroy(&dnh->dnh_zrlock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
995 dnh->dnh_dnode = NULL; |
789 | 996 } |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
997 kmem_free(children_dnodes, sizeof (dnode_children_t) + |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
998 (epb - 1) * sizeof (dnode_handle_t)); |
789 | 999 } |
1000 | |
1001 /* | |
1544 | 1002 * errors: |
1003 * EINVAL - invalid object number. | |
1004 * EIO - i/o error. | |
1005 * succeeds even for free dnodes. | |
789 | 1006 */ |
1544 | 1007 int |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9950
diff
changeset
|
1008 dnode_hold_impl(objset_t *os, uint64_t object, int flag, |
1544 | 1009 void *tag, dnode_t **dnp) |
789 | 1010 { |
1544 | 1011 int epb, idx, err; |
789 | 1012 int drop_struct_lock = FALSE; |
1544 | 1013 int type; |
789 | 1014 uint64_t blk; |
1015 dnode_t *mdn, *dn; | |
1016 dmu_buf_impl_t *db; | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1017 dnode_children_t *children_dnodes; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1018 dnode_handle_t *dnh; |
789 | 1019 |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7385
diff
changeset
|
1020 /* |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7385
diff
changeset
|
1021 * If you are holding the spa config lock as writer, you shouldn't |
11958
575ffe1e978d
6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents:
11935
diff
changeset
|
1022 * be asking the DMU to do *anything* unless it's the root pool |
575ffe1e978d
6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents:
11935
diff
changeset
|
1023 * which may require us to read from the root filesystem while |
575ffe1e978d
6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents:
11935
diff
changeset
|
1024 * holding some (not all) of the locks as writer. |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7385
diff
changeset
|
1025 */ |
11958
575ffe1e978d
6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents:
11935
diff
changeset
|
1026 ASSERT(spa_config_held(os->os_spa, SCL_ALL, RW_WRITER) == 0 || |
575ffe1e978d
6923585 deadlock while booting OpenSolaris build 132 from mirrored rpool with removed submirror
George Wilson <George.Wilson@Sun.COM>
parents:
11935
diff
changeset
|
1027 (spa_is_root(os->os_spa) && |
12586
b118bbd65be9
6494473 ZFS needs a way to slow down resilvering
George Wilson <George.Wilson@Sun.COM>
parents:
12432
diff
changeset
|
1028 spa_config_held(os->os_spa, SCL_STATE, RW_WRITER))); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7385
diff
changeset
|
1029 |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1030 if (object == DMU_USERUSED_OBJECT || object == DMU_GROUPUSED_OBJECT) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1031 dn = (object == DMU_USERUSED_OBJECT) ? |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1032 DMU_USERUSED_DNODE(os) : DMU_GROUPUSED_DNODE(os); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1033 if (dn == NULL) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1034 return (ENOENT); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1035 type = dn->dn_type; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1036 if ((flag & DNODE_MUST_BE_ALLOCATED) && type == DMU_OT_NONE) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1037 return (ENOENT); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1038 if ((flag & DNODE_MUST_BE_FREE) && type != DMU_OT_NONE) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1039 return (EEXIST); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1040 DNODE_VERIFY(dn); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1041 (void) refcount_add(&dn->dn_holds, tag); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1042 *dnp = dn; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1043 return (0); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1044 } |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1045 |
789 | 1046 if (object == 0 || object >= DN_MAX_OBJECT) |
1544 | 1047 return (EINVAL); |
789 | 1048 |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1049 mdn = DMU_META_DNODE(os); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1050 ASSERT(mdn->dn_object == DMU_META_DNODE_OBJECT); |
789 | 1051 |
873
adefbfa5f42d
6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents:
789
diff
changeset
|
1052 DNODE_VERIFY(mdn); |
789 | 1053 |
1054 if (!RW_WRITE_HELD(&mdn->dn_struct_rwlock)) { | |
1055 rw_enter(&mdn->dn_struct_rwlock, RW_READER); | |
1056 drop_struct_lock = TRUE; | |
1057 } | |
1058 | |
1059 blk = dbuf_whichblock(mdn, object * sizeof (dnode_phys_t)); | |
1060 | |
1544 | 1061 db = dbuf_hold(mdn, blk, FTAG); |
789 | 1062 if (drop_struct_lock) |
1063 rw_exit(&mdn->dn_struct_rwlock); | |
1544 | 1064 if (db == NULL) |
1065 return (EIO); | |
1066 err = dbuf_read(db, NULL, DB_RF_CANFAIL); | |
1067 if (err) { | |
1068 dbuf_rele(db, FTAG); | |
1069 return (err); | |
1070 } | |
789 | 1071 |
1072 ASSERT3U(db->db.db_size, >=, 1<<DNODE_SHIFT); | |
1073 epb = db->db.db_size >> DNODE_SHIFT; | |
1074 | |
1075 idx = object & (epb-1); | |
1076 | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1077 ASSERT(DB_DNODE(db)->dn_type == DMU_OT_DNODE); |
789 | 1078 children_dnodes = dmu_buf_get_user(&db->db); |
1079 if (children_dnodes == NULL) { | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1080 int i; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1081 dnode_children_t *winner; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1082 children_dnodes = kmem_alloc(sizeof (dnode_children_t) + |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1083 (epb - 1) * sizeof (dnode_handle_t), KM_SLEEP); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1084 children_dnodes->dnc_count = epb; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1085 dnh = &children_dnodes->dnc_children[0]; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1086 for (i = 0; i < epb; i++) { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1087 zrl_init(&dnh[i].dnh_zrlock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1088 dnh[i].dnh_dnode = NULL; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1089 } |
789 | 1090 if (winner = dmu_buf_set_user(&db->db, children_dnodes, NULL, |
1091 dnode_buf_pageout)) { | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1092 kmem_free(children_dnodes, sizeof (dnode_children_t) + |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1093 (epb - 1) * sizeof (dnode_handle_t)); |
789 | 1094 children_dnodes = winner; |
1095 } | |
1096 } | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1097 ASSERT(children_dnodes->dnc_count == epb); |
789 | 1098 |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1099 dnh = &children_dnodes->dnc_children[idx]; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1100 zrl_add(&dnh->dnh_zrlock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1101 if ((dn = dnh->dnh_dnode) == NULL) { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1102 dnode_phys_t *phys = (dnode_phys_t *)db->db.db_data+idx; |
789 | 1103 dnode_t *winner; |
4309
3dfde0f4662d
6542676 ARC needs to track meta-data memory overhead
maybee
parents:
3882
diff
changeset
|
1104 |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1105 dn = dnode_create(os, phys, db, object, dnh); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1106 winner = atomic_cas_ptr(&dnh->dnh_dnode, NULL, dn); |
789 | 1107 if (winner != NULL) { |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1108 zrl_add(&dnh->dnh_zrlock); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1109 dnode_destroy(dn); /* implicit zrl_remove() */ |
789 | 1110 dn = winner; |
1111 } | |
1112 } | |
1113 | |
1114 mutex_enter(&dn->dn_mtx); | |
1544 | 1115 type = dn->dn_type; |
789 | 1116 if (dn->dn_free_txg || |
1544 | 1117 ((flag & DNODE_MUST_BE_ALLOCATED) && type == DMU_OT_NONE) || |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1118 ((flag & DNODE_MUST_BE_FREE) && |
12432
222dd376dd6c
6952522 elpaso panics: assertion failed: refcount_is_zero(&dn->dn_holds), file: ../../common/fs/zfs/dnode.c
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
12411
diff
changeset
|
1119 (type != DMU_OT_NONE || !refcount_is_zero(&dn->dn_holds)))) { |
789 | 1120 mutex_exit(&dn->dn_mtx); |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1121 zrl_remove(&dnh->dnh_zrlock); |
1544 | 1122 dbuf_rele(db, FTAG); |
1123 return (type == DMU_OT_NONE ? ENOENT : EEXIST); | |
789 | 1124 } |
1125 mutex_exit(&dn->dn_mtx); | |
1126 | |
1544 | 1127 if (refcount_add(&dn->dn_holds, tag) == 1) |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1128 dbuf_add_ref(db, dnh); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1129 /* Now we can rely on the hold to prevent the dnode from moving. */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1130 zrl_remove(&dnh->dnh_zrlock); |
789 | 1131 |
873
adefbfa5f42d
6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents:
789
diff
changeset
|
1132 DNODE_VERIFY(dn); |
789 | 1133 ASSERT3P(dn->dn_dbuf, ==, db); |
1134 ASSERT3U(dn->dn_object, ==, object); | |
1544 | 1135 dbuf_rele(db, FTAG); |
789 | 1136 |
1544 | 1137 *dnp = dn; |
1138 return (0); | |
789 | 1139 } |
1140 | |
1141 /* | |
1142 * Return held dnode if the object is allocated, NULL if not. | |
1143 */ | |
1544 | 1144 int |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9950
diff
changeset
|
1145 dnode_hold(objset_t *os, uint64_t object, void *tag, dnode_t **dnp) |
789 | 1146 { |
1544 | 1147 return (dnode_hold_impl(os, object, DNODE_MUST_BE_ALLOCATED, tag, dnp)); |
789 | 1148 } |
1149 | |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
1150 /* |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
1151 * Can only add a reference if there is already at least one |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
1152 * reference on the dnode. Returns FALSE if unable to add a |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
1153 * new reference. |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
1154 */ |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
1155 boolean_t |
1544 | 1156 dnode_add_ref(dnode_t *dn, void *tag) |
789 | 1157 { |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
1158 mutex_enter(&dn->dn_mtx); |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
1159 if (refcount_is_zero(&dn->dn_holds)) { |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
1160 mutex_exit(&dn->dn_mtx); |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
1161 return (FALSE); |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
1162 } |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
1163 VERIFY(1 < refcount_add(&dn->dn_holds, tag)); |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
1164 mutex_exit(&dn->dn_mtx); |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
1165 return (TRUE); |
789 | 1166 } |
1167 | |
1168 void | |
1544 | 1169 dnode_rele(dnode_t *dn, void *tag) |
789 | 1170 { |
1171 uint64_t refs; | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1172 /* Get while the hold prevents the dnode from moving. */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1173 dmu_buf_impl_t *db = dn->dn_dbuf; |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1174 dnode_handle_t *dnh = dn->dn_handle; |
789 | 1175 |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
1176 mutex_enter(&dn->dn_mtx); |
1544 | 1177 refs = refcount_remove(&dn->dn_holds, tag); |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
1178 mutex_exit(&dn->dn_mtx); |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1179 |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1180 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1181 * It's unsafe to release the last hold on a dnode by dnode_rele() or |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1182 * indirectly by dbuf_rele() while relying on the dnode handle to |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1183 * prevent the dnode from moving, since releasing the last hold could |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1184 * result in the dnode's parent dbuf evicting its dnode handles. For |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1185 * that reason anyone calling dnode_rele() or dbuf_rele() without some |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1186 * other direct or indirect hold on the dnode must first drop the dnode |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1187 * handle. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1188 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1189 ASSERT(refs > 0 || dnh->dnh_zrlock.zr_owner != curthread); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1190 |
789 | 1191 /* NOTE: the DNODE_DNODE does not have a dn_dbuf */ |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1192 if (refs == 0 && db != NULL) { |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1193 /* |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1194 * Another thread could add a hold to the dnode handle in |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1195 * dnode_hold_impl() while holding the parent dbuf. Since the |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1196 * hold on the parent dbuf prevents the handle from being |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1197 * destroyed, the hold on the handle is OK. We can't yet assert |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1198 * that the handle has zero references, but that will be |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1199 * asserted anyway when the handle gets destroyed. |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1200 */ |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1201 dbuf_rele(db, dnh); |
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1202 } |
789 | 1203 } |
1204 | |
1205 void | |
1206 dnode_setdirty(dnode_t *dn, dmu_tx_t *tx) | |
1207 { | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9950
diff
changeset
|
1208 objset_t *os = dn->dn_objset; |
789 | 1209 uint64_t txg = tx->tx_txg; |
1210 | |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1211 if (DMU_OBJECT_IS_SPECIAL(dn->dn_object)) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1212 dsl_dataset_dirty(os->os_dsl_dataset, tx); |
789 | 1213 return; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1214 } |
789 | 1215 |
873
adefbfa5f42d
6347448 non ZFS_DEBUG kernels shouldn't call empty verify functions
ek110237
parents:
789
diff
changeset
|
1216 DNODE_VERIFY(dn); |
789 | 1217 |
1218 #ifdef ZFS_DEBUG | |
1219 mutex_enter(&dn->dn_mtx); | |
1220 ASSERT(dn->dn_phys->dn_type || dn->dn_allocated_txg); | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1221 ASSERT(dn->dn_free_txg == 0 || dn->dn_free_txg >= txg); |
789 | 1222 mutex_exit(&dn->dn_mtx); |
1223 #endif | |
1224 | |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1225 /* |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1226 * Determine old uid/gid when necessary |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1227 */ |
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:
11958
diff
changeset
|
1228 dmu_objset_userquota_get_ids(dn, B_TRUE, tx); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1229 |
789 | 1230 mutex_enter(&os->os_lock); |
1231 | |
1232 /* | |
1233 * If we are already marked dirty, we're done. | |
1234 */ | |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1235 if (list_link_active(&dn->dn_dirty_link[txg & TXG_MASK])) { |
789 | 1236 mutex_exit(&os->os_lock); |
1237 return; | |
1238 } | |
1239 | |
1240 ASSERT(!refcount_is_zero(&dn->dn_holds) || list_head(&dn->dn_dbufs)); | |
1241 ASSERT(dn->dn_datablksz != 0); | |
13805
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
1242 ASSERT0(dn->dn_next_bonuslen[txg&TXG_MASK]); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
1243 ASSERT0(dn->dn_next_blksz[txg&TXG_MASK]); |
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
1244 ASSERT0(dn->dn_next_bonustype[txg&TXG_MASK]); |
789 | 1245 |
1246 dprintf_ds(os->os_dsl_dataset, "obj=%llu txg=%llu\n", | |
1247 dn->dn_object, txg); | |
1248 | |
1249 if (dn->dn_free_txg > 0 && dn->dn_free_txg <= txg) { | |
1250 list_insert_tail(&os->os_free_dnodes[txg&TXG_MASK], dn); | |
1251 } else { | |
1252 list_insert_tail(&os->os_dirty_dnodes[txg&TXG_MASK], dn); | |
1253 } | |
1254 | |
1255 mutex_exit(&os->os_lock); | |
1256 | |
1257 /* | |
1258 * The dnode maintains a hold on its containing dbuf as | |
1259 * long as there are holds on it. Each instantiated child | |
12684
397e44ebb8a9
6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
12586
diff
changeset
|
1260 * dbuf maintains a hold on the dnode. When the last child |
789 | 1261 * drops its hold, the dnode will drop its hold on the |
1262 * containing dbuf. We add a "dirty hold" here so that the | |
1263 * dnode will hang around after we finish processing its | |
1264 * children. | |
1265 */ | |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4577
diff
changeset
|
1266 VERIFY(dnode_add_ref(dn, (void *)(uintptr_t)tx->tx_txg)); |
789 | 1267 |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1268 (void) dbuf_dirty(dn->dn_dbuf, tx); |
789 | 1269 |
1270 dsl_dataset_dirty(os->os_dsl_dataset, tx); | |
1271 } | |
1272 | |
1273 void | |
1274 dnode_free(dnode_t *dn, dmu_tx_t *tx) | |
1275 { | |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1276 int txgoff = tx->tx_txg & TXG_MASK; |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1277 |
789 | 1278 dprintf("dn=%p txg=%llu\n", dn, tx->tx_txg); |
1279 | |
1280 /* we should be the only holder... hopefully */ | |
1281 /* ASSERT3U(refcount_count(&dn->dn_holds), ==, 1); */ | |
1282 | |
1283 mutex_enter(&dn->dn_mtx); | |
1284 if (dn->dn_type == DMU_OT_NONE || dn->dn_free_txg) { | |
1285 mutex_exit(&dn->dn_mtx); | |
1286 return; | |
1287 } | |
1288 dn->dn_free_txg = tx->tx_txg; | |
1289 mutex_exit(&dn->dn_mtx); | |
1290 | |
1291 /* | |
1292 * If the dnode is already dirty, it needs to be moved from | |
1293 * the dirty list to the free list. | |
1294 */ | |
1295 mutex_enter(&dn->dn_objset->os_lock); | |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1296 if (list_link_active(&dn->dn_dirty_link[txgoff])) { |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1297 list_remove(&dn->dn_objset->os_dirty_dnodes[txgoff], dn); |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1298 list_insert_tail(&dn->dn_objset->os_free_dnodes[txgoff], dn); |
789 | 1299 mutex_exit(&dn->dn_objset->os_lock); |
1300 } else { | |
1301 mutex_exit(&dn->dn_objset->os_lock); | |
1302 dnode_setdirty(dn, tx); | |
1303 } | |
1304 } | |
1305 | |
1306 /* | |
1307 * Try to change the block size for the indicated dnode. This can only | |
1308 * succeed if there are no blocks allocated or dirty beyond first block | |
1309 */ | |
1310 int | |
1311 dnode_set_blksz(dnode_t *dn, uint64_t size, int ibs, dmu_tx_t *tx) | |
1312 { | |
1313 dmu_buf_impl_t *db, *db_next; | |
6992 | 1314 int err; |
789 | 1315 |
1316 if (size == 0) | |
1317 size = SPA_MINBLOCKSIZE; | |
1318 if (size > SPA_MAXBLOCKSIZE) | |
1319 size = SPA_MAXBLOCKSIZE; | |
1320 else | |
1321 size = P2ROUNDUP(size, SPA_MINBLOCKSIZE); | |
1322 | |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1323 if (ibs == dn->dn_indblkshift) |
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1324 ibs = 0; |
789 | 1325 |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1326 if (size >> SPA_MINBLOCKSHIFT == dn->dn_datablkszsec && ibs == 0) |
789 | 1327 return (0); |
1328 | |
1329 rw_enter(&dn->dn_struct_rwlock, RW_WRITER); | |
1330 | |
1331 /* Check for any allocated blocks beyond the first */ | |
1332 if (dn->dn_phys->dn_maxblkid != 0) | |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1333 goto fail; |
789 | 1334 |
1335 mutex_enter(&dn->dn_dbufs_mtx); | |
1336 for (db = list_head(&dn->dn_dbufs); db; db = db_next) { | |
1337 db_next = list_next(&dn->dn_dbufs, db); | |
1338 | |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1339 if (db->db_blkid != 0 && db->db_blkid != DMU_BONUS_BLKID && |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1340 db->db_blkid != DMU_SPILL_BLKID) { |
789 | 1341 mutex_exit(&dn->dn_dbufs_mtx); |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1342 goto fail; |
789 | 1343 } |
1344 } | |
1345 mutex_exit(&dn->dn_dbufs_mtx); | |
1346 | |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1347 if (ibs && dn->dn_nlevels != 1) |
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1348 goto fail; |
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1349 |
6992 | 1350 /* resize the old block */ |
1351 err = dbuf_hold_impl(dn, 0, 0, TRUE, FTAG, &db); | |
1352 if (err == 0) | |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1353 dbuf_new_size(db, size, tx); |
6992 | 1354 else if (err != ENOENT) |
1355 goto fail; | |
789 | 1356 |
1357 dnode_setdblksz(dn, size); | |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1358 dnode_setdirty(dn, tx); |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1359 dn->dn_next_blksz[tx->tx_txg&TXG_MASK] = size; |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1360 if (ibs) { |
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1361 dn->dn_indblkshift = ibs; |
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1362 dn->dn_next_indblkshift[tx->tx_txg&TXG_MASK] = ibs; |
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1363 } |
6992 | 1364 /* rele after we have fixed the blocksize in the dnode */ |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1365 if (db) |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1366 dbuf_rele(db, FTAG); |
789 | 1367 |
1368 rw_exit(&dn->dn_struct_rwlock); | |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1369 return (0); |
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1370 |
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1371 fail: |
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1372 rw_exit(&dn->dn_struct_rwlock); |
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1373 return (ENOTSUP); |
789 | 1374 } |
1375 | |
7332
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1376 /* read-holding callers must not rely on the lock being continuously held */ |
789 | 1377 void |
7332
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1378 dnode_new_blkid(dnode_t *dn, uint64_t blkid, dmu_tx_t *tx, boolean_t have_read) |
789 | 1379 { |
1380 uint64_t txgoff = tx->tx_txg & TXG_MASK; | |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1381 int epbs, new_nlevels; |
789 | 1382 uint64_t sz; |
1383 | |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1384 ASSERT(blkid != DMU_BONUS_BLKID); |
789 | 1385 |
7332
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1386 ASSERT(have_read ? |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1387 RW_READ_HELD(&dn->dn_struct_rwlock) : |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1388 RW_WRITE_HELD(&dn->dn_struct_rwlock)); |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1389 |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1390 /* |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1391 * if we have a read-lock, check to see if we need to do any work |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1392 * before upgrading to a write-lock. |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1393 */ |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1394 if (have_read) { |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1395 if (blkid <= dn->dn_maxblkid) |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1396 return; |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1397 |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1398 if (!rw_tryupgrade(&dn->dn_struct_rwlock)) { |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1399 rw_exit(&dn->dn_struct_rwlock); |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1400 rw_enter(&dn->dn_struct_rwlock, RW_WRITER); |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1401 } |
789 | 1402 } |
1403 | |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1404 if (blkid <= dn->dn_maxblkid) |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1405 goto out; |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1406 |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1407 dn->dn_maxblkid = blkid; |
789 | 1408 |
1409 /* | |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1410 * Compute the number of levels necessary to support the new maxblkid. |
789 | 1411 */ |
1412 new_nlevels = 1; | |
1413 epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT; | |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1414 for (sz = dn->dn_nblkptr; |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1415 sz <= blkid && sz >= dn->dn_nblkptr; sz <<= epbs) |
789 | 1416 new_nlevels++; |
1417 | |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1418 if (new_nlevels > dn->dn_nlevels) { |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1419 int old_nlevels = dn->dn_nlevels; |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1420 dmu_buf_impl_t *db; |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1421 list_t *list; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1422 dbuf_dirty_record_t *new, *dr, *dr_next; |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1423 |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1424 dn->dn_nlevels = new_nlevels; |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1425 |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1426 ASSERT3U(new_nlevels, >, dn->dn_next_nlevels[txgoff]); |
789 | 1427 dn->dn_next_nlevels[txgoff] = new_nlevels; |
1428 | |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1429 /* dirty the left indirects */ |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1430 db = dbuf_hold_level(dn, old_nlevels, 0, FTAG); |
12411
3e9af067a727
6911391 panic in dmu_tx_count_write()
John Harres <John.Harres@Sun.COM>
parents:
12178
diff
changeset
|
1431 ASSERT(db != NULL); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1432 new = dbuf_dirty(db, tx); |
1544 | 1433 dbuf_rele(db, FTAG); |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
1434 |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1435 /* transfer the dirty records to the new indirect */ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1436 mutex_enter(&dn->dn_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1437 mutex_enter(&new->dt.di.dr_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1438 list = &dn->dn_dirty_records[txgoff]; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1439 for (dr = list_head(list); dr; dr = dr_next) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1440 dr_next = list_next(&dn->dn_dirty_records[txgoff], dr); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1441 if (dr->dr_dbuf->db_level != new_nlevels-1 && |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1442 dr->dr_dbuf->db_blkid != DMU_BONUS_BLKID && |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1443 dr->dr_dbuf->db_blkid != DMU_SPILL_BLKID) { |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1444 ASSERT(dr->dr_dbuf->db_level == old_nlevels-1); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1445 list_remove(&dn->dn_dirty_records[txgoff], dr); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1446 list_insert_tail(&new->dt.di.dr_children, dr); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1447 dr->dr_parent = new; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1448 } |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1449 } |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1450 mutex_exit(&new->dt.di.dr_mtx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1451 mutex_exit(&dn->dn_mtx); |
789 | 1452 } |
1453 | |
1454 out: | |
7332
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1455 if (have_read) |
396f25bd1f34
6579975 dnode_new_blkid should look before it locks
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
7049
diff
changeset
|
1456 rw_downgrade(&dn->dn_struct_rwlock); |
789 | 1457 } |
1458 | |
1459 void | |
1460 dnode_clear_range(dnode_t *dn, uint64_t blkid, uint64_t nblks, dmu_tx_t *tx) | |
1461 { | |
1462 avl_tree_t *tree = &dn->dn_ranges[tx->tx_txg&TXG_MASK]; | |
1463 avl_index_t where; | |
1464 free_range_t *rp; | |
1465 free_range_t rp_tofind; | |
1466 uint64_t endblk = blkid + nblks; | |
1467 | |
1468 ASSERT(MUTEX_HELD(&dn->dn_mtx)); | |
1469 ASSERT(nblks <= UINT64_MAX - blkid); /* no overflow */ | |
1470 | |
1471 dprintf_dnode(dn, "blkid=%llu nblks=%llu txg=%llu\n", | |
1472 blkid, nblks, tx->tx_txg); | |
1473 rp_tofind.fr_blkid = blkid; | |
1474 rp = avl_find(tree, &rp_tofind, &where); | |
1475 if (rp == NULL) | |
1476 rp = avl_nearest(tree, where, AVL_BEFORE); | |
1477 if (rp == NULL) | |
1478 rp = avl_nearest(tree, where, AVL_AFTER); | |
1479 | |
1480 while (rp && (rp->fr_blkid <= blkid + nblks)) { | |
1481 uint64_t fr_endblk = rp->fr_blkid + rp->fr_nblks; | |
1482 free_range_t *nrp = AVL_NEXT(tree, rp); | |
1483 | |
1484 if (blkid <= rp->fr_blkid && endblk >= fr_endblk) { | |
1485 /* clear this entire range */ | |
1486 avl_remove(tree, rp); | |
1487 kmem_free(rp, sizeof (free_range_t)); | |
1488 } else if (blkid <= rp->fr_blkid && | |
1489 endblk > rp->fr_blkid && endblk < fr_endblk) { | |
1490 /* clear the beginning of this range */ | |
1491 rp->fr_blkid = endblk; | |
1492 rp->fr_nblks = fr_endblk - endblk; | |
1493 } else if (blkid > rp->fr_blkid && blkid < fr_endblk && | |
1494 endblk >= fr_endblk) { | |
1495 /* clear the end of this range */ | |
1496 rp->fr_nblks = blkid - rp->fr_blkid; | |
1497 } else if (blkid > rp->fr_blkid && endblk < fr_endblk) { | |
1498 /* clear a chunk out of this range */ | |
1499 free_range_t *new_rp = | |
1500 kmem_alloc(sizeof (free_range_t), KM_SLEEP); | |
1501 | |
1502 new_rp->fr_blkid = endblk; | |
1503 new_rp->fr_nblks = fr_endblk - endblk; | |
1504 avl_insert_here(tree, new_rp, rp, AVL_AFTER); | |
1505 rp->fr_nblks = blkid - rp->fr_blkid; | |
1506 } | |
1507 /* there may be no overlap */ | |
1508 rp = nrp; | |
1509 } | |
1510 } | |
1511 | |
1512 void | |
1513 dnode_free_range(dnode_t *dn, uint64_t off, uint64_t len, dmu_tx_t *tx) | |
1514 { | |
1515 dmu_buf_impl_t *db; | |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1516 uint64_t blkoff, blkid, nblks; |
6992 | 1517 int blksz, blkshift, head, tail; |
789 | 1518 int trunc = FALSE; |
6992 | 1519 int epbs; |
789 | 1520 |
1521 rw_enter(&dn->dn_struct_rwlock, RW_WRITER); | |
1522 blksz = dn->dn_datablksz; | |
6992 | 1523 blkshift = dn->dn_datablkshift; |
1524 epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT; | |
789 | 1525 |
1526 if (len == -1ULL) { | |
1527 len = UINT64_MAX - off; | |
1528 trunc = TRUE; | |
1529 } | |
1530 | |
1531 /* | |
1532 * First, block align the region to free: | |
1533 */ | |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1534 if (ISP2(blksz)) { |
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1535 head = P2NPHASE(off, blksz); |
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1536 blkoff = P2PHASE(off, blksz); |
6992 | 1537 if ((off >> blkshift) > dn->dn_maxblkid) |
1538 goto out; | |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1539 } else { |
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1540 ASSERT(dn->dn_maxblkid == 0); |
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1541 if (off == 0 && len >= blksz) { |
6992 | 1542 /* Freeing the whole block; fast-track this request */ |
1543 blkid = 0; | |
1544 nblks = 1; | |
1545 goto done; | |
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
|
1546 } else if (off >= blksz) { |
6992 | 1547 /* Freeing past end-of-data */ |
1548 goto out; | |
789 | 1549 } else { |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1550 /* Freeing part of the block. */ |
789 | 1551 head = blksz - off; |
1552 ASSERT3U(head, >, 0); | |
1553 } | |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1554 blkoff = off; |
789 | 1555 } |
1556 /* zero out any partial block data at the start of the range */ | |
1557 if (head) { | |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1558 ASSERT3U(blkoff + head, ==, blksz); |
789 | 1559 if (len < head) |
1560 head = len; | |
1561 if (dbuf_hold_impl(dn, 0, dbuf_whichblock(dn, off), TRUE, | |
1562 FTAG, &db) == 0) { | |
1563 caddr_t data; | |
1564 | |
1565 /* don't dirty if it isn't on disk and isn't dirty */ | |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3087
diff
changeset
|
1566 if (db->db_last_dirty || |
789 | 1567 (db->db_blkptr && !BP_IS_HOLE(db->db_blkptr))) { |
1568 rw_exit(&dn->dn_struct_rwlock); | |
1569 dbuf_will_dirty(db, tx); | |
1570 rw_enter(&dn->dn_struct_rwlock, RW_WRITER); | |
1571 data = db->db.db_data; | |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1572 bzero(data + blkoff, head); |
789 | 1573 } |
1544 | 1574 dbuf_rele(db, FTAG); |
789 | 1575 } |
1576 off += head; | |
1577 len -= head; | |
1578 } | |
1579 | |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1580 /* If the range was less than one block, we're done */ |
6992 | 1581 if (len == 0) |
1582 goto out; | |
1583 | |
1584 /* If the remaining range is past end of file, we're done */ | |
1585 if ((off >> blkshift) > dn->dn_maxblkid) | |
1586 goto out; | |
1587 | |
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
|
1588 ASSERT(ISP2(blksz)); |
6992 | 1589 if (trunc) |
1590 tail = 0; | |
1591 else | |
1592 tail = P2PHASE(len, blksz); | |
1593 | |
13805
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
1594 ASSERT0(P2PHASE(off, blksz)); |
6992 | 1595 /* zero out any partial block data at the end of the range */ |
1596 if (tail) { | |
1597 if (len < tail) | |
1598 tail = len; | |
1599 if (dbuf_hold_impl(dn, 0, dbuf_whichblock(dn, off+len), | |
1600 TRUE, FTAG, &db) == 0) { | |
1601 /* don't dirty if not on disk and not dirty */ | |
1602 if (db->db_last_dirty || | |
1603 (db->db_blkptr && !BP_IS_HOLE(db->db_blkptr))) { | |
1604 rw_exit(&dn->dn_struct_rwlock); | |
1605 dbuf_will_dirty(db, tx); | |
1606 rw_enter(&dn->dn_struct_rwlock, RW_WRITER); | |
1607 bzero(db->db.db_data, tail); | |
1608 } | |
1609 dbuf_rele(db, FTAG); | |
1610 } | |
1611 len -= tail; | |
1612 } | |
1613 | |
1614 /* If the range did not include a full block, we are done */ | |
1615 if (len == 0) | |
789 | 1616 goto out; |
1617 | |
6992 | 1618 ASSERT(IS_P2ALIGNED(off, blksz)); |
1619 ASSERT(trunc || IS_P2ALIGNED(len, blksz)); | |
1620 blkid = off >> blkshift; | |
1621 nblks = len >> blkshift; | |
1622 if (trunc) | |
1623 nblks += 1; | |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1624 |
6992 | 1625 /* |
1626 * Read in and mark all the level-1 indirects dirty, | |
1627 * so that they will stay in memory until syncing phase. | |
7049
d0b1e2eb4ab5
6723124 Assertion failed: all || blocks_freed == 0 || db->db_last_dirty
maybee
parents:
6992
diff
changeset
|
1628 * Always dirty the first and last indirect to make sure |
d0b1e2eb4ab5
6723124 Assertion failed: all || blocks_freed == 0 || db->db_last_dirty
maybee
parents:
6992
diff
changeset
|
1629 * we dirty all the partial indirects. |
6992 | 1630 */ |
1631 if (dn->dn_nlevels > 1) { | |
1632 uint64_t i, first, last; | |
1633 int shift = epbs + dn->dn_datablkshift; | |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1634 |
6992 | 1635 first = blkid >> epbs; |
7049
d0b1e2eb4ab5
6723124 Assertion failed: all || blocks_freed == 0 || db->db_last_dirty
maybee
parents:
6992
diff
changeset
|
1636 if (db = dbuf_hold_level(dn, 1, first, FTAG)) { |
d0b1e2eb4ab5
6723124 Assertion failed: all || blocks_freed == 0 || db->db_last_dirty
maybee
parents:
6992
diff
changeset
|
1637 dbuf_will_dirty(db, tx); |
d0b1e2eb4ab5
6723124 Assertion failed: all || blocks_freed == 0 || db->db_last_dirty
maybee
parents:
6992
diff
changeset
|
1638 dbuf_rele(db, FTAG); |
d0b1e2eb4ab5
6723124 Assertion failed: all || blocks_freed == 0 || db->db_last_dirty
maybee
parents:
6992
diff
changeset
|
1639 } |
6992 | 1640 if (trunc) |
1641 last = dn->dn_maxblkid >> epbs; | |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1642 else |
6992 | 1643 last = (blkid + nblks - 1) >> epbs; |
7049
d0b1e2eb4ab5
6723124 Assertion failed: all || blocks_freed == 0 || db->db_last_dirty
maybee
parents:
6992
diff
changeset
|
1644 if (last > first && (db = dbuf_hold_level(dn, 1, last, FTAG))) { |
d0b1e2eb4ab5
6723124 Assertion failed: all || blocks_freed == 0 || db->db_last_dirty
maybee
parents:
6992
diff
changeset
|
1645 dbuf_will_dirty(db, tx); |
d0b1e2eb4ab5
6723124 Assertion failed: all || blocks_freed == 0 || db->db_last_dirty
maybee
parents:
6992
diff
changeset
|
1646 dbuf_rele(db, FTAG); |
d0b1e2eb4ab5
6723124 Assertion failed: all || blocks_freed == 0 || db->db_last_dirty
maybee
parents:
6992
diff
changeset
|
1647 } |
d0b1e2eb4ab5
6723124 Assertion failed: all || blocks_freed == 0 || db->db_last_dirty
maybee
parents:
6992
diff
changeset
|
1648 for (i = first + 1; i < last; i++) { |
6992 | 1649 uint64_t ibyte = i << shift; |
1650 int err; | |
789 | 1651 |
6992 | 1652 err = dnode_next_offset(dn, |
1653 DNODE_FIND_HAVELOCK, &ibyte, 1, 1, 0); | |
1654 i = ibyte >> shift; | |
7049
d0b1e2eb4ab5
6723124 Assertion failed: all || blocks_freed == 0 || db->db_last_dirty
maybee
parents:
6992
diff
changeset
|
1655 if (err == ESRCH || i >= last) |
6992 | 1656 break; |
1657 ASSERT(err == 0); | |
1658 db = dbuf_hold_level(dn, 1, i, FTAG); | |
1659 if (db) { | |
1660 dbuf_will_dirty(db, tx); | |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1661 dbuf_rele(db, FTAG); |
789 | 1662 } |
2445
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1663 } |
45c1310316ff
6447381 dnode_free_range() does not handle non-power-of-two blocksizes correctly
ahrens
parents:
2082
diff
changeset
|
1664 } |
6992 | 1665 done: |
1666 /* | |
1667 * Add this range to the dnode range list. | |
1668 * We will finish up this free operation in the syncing phase. | |
1669 */ | |
789 | 1670 mutex_enter(&dn->dn_mtx); |
1671 dnode_clear_range(dn, blkid, nblks, tx); | |
1672 { | |
1673 free_range_t *rp, *found; | |
1674 avl_index_t where; | |
1675 avl_tree_t *tree = &dn->dn_ranges[tx->tx_txg&TXG_MASK]; | |
1676 | |
1677 /* Add new range to dn_ranges */ | |
1678 rp = kmem_alloc(sizeof (free_range_t), KM_SLEEP); | |
1679 rp->fr_blkid = blkid; | |
1680 rp->fr_nblks = nblks; | |
1681 found = avl_find(tree, rp, &where); | |
1682 ASSERT(found == NULL); | |
1683 avl_insert(tree, rp, where); | |
1684 dprintf_dnode(dn, "blkid=%llu nblks=%llu txg=%llu\n", | |
1685 blkid, nblks, tx->tx_txg); | |
1686 } | |
1687 mutex_exit(&dn->dn_mtx); | |
1688 | |
6992 | 1689 dbuf_free_range(dn, blkid, blkid + nblks - 1, tx); |
789 | 1690 dnode_setdirty(dn, tx); |
1691 out: | |
6992 | 1692 if (trunc && dn->dn_maxblkid >= (off >> blkshift)) |
1693 dn->dn_maxblkid = (off >> blkshift ? (off >> blkshift) - 1 : 0); | |
1694 | |
789 | 1695 rw_exit(&dn->dn_struct_rwlock); |
1696 } | |
1697 | |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1698 static boolean_t |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1699 dnode_spill_freed(dnode_t *dn) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1700 { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1701 int i; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1702 |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1703 mutex_enter(&dn->dn_mtx); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1704 for (i = 0; i < TXG_SIZE; i++) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1705 if (dn->dn_rm_spillblk[i] == DN_KILL_SPILLBLK) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1706 break; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1707 } |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1708 mutex_exit(&dn->dn_mtx); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1709 return (i < TXG_SIZE); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1710 } |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1711 |
789 | 1712 /* return TRUE if this blkid was freed in a recent txg, or FALSE if it wasn't */ |
1713 uint64_t | |
1714 dnode_block_freed(dnode_t *dn, uint64_t blkid) | |
1715 { | |
1716 free_range_t range_tofind; | |
1717 void *dp = spa_get_dsl(dn->dn_objset->os_spa); | |
1718 int i; | |
1719 | |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1720 if (blkid == DMU_BONUS_BLKID) |
789 | 1721 return (FALSE); |
1722 | |
1723 /* | |
1724 * If we're in the process of opening the pool, dp will not be | |
1725 * set yet, but there shouldn't be anything dirty. | |
1726 */ | |
1727 if (dp == NULL) | |
1728 return (FALSE); | |
1729 | |
1730 if (dn->dn_free_txg) | |
1731 return (TRUE); | |
1732 | |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1733 if (blkid == DMU_SPILL_BLKID) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1734 return (dnode_spill_freed(dn)); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
10298
diff
changeset
|
1735 |
789 | 1736 range_tofind.fr_blkid = blkid; |
1737 mutex_enter(&dn->dn_mtx); | |
1738 for (i = 0; i < TXG_SIZE; i++) { | |
1739 free_range_t *range_found; | |
1740 avl_index_t idx; | |
1741 | |
1742 range_found = avl_find(&dn->dn_ranges[i], &range_tofind, &idx); | |
1743 if (range_found) { | |
1744 ASSERT(range_found->fr_nblks > 0); | |
1745 break; | |
1746 } | |
1747 range_found = avl_nearest(&dn->dn_ranges[i], idx, AVL_BEFORE); | |
1748 if (range_found && | |
1749 range_found->fr_blkid + range_found->fr_nblks > blkid) | |
1750 break; | |
1751 } | |
1752 mutex_exit(&dn->dn_mtx); | |
1753 return (i < TXG_SIZE); | |
1754 } | |
1755 | |
1756 /* call from syncing context when we actually write/free space for this dnode */ | |
1757 void | |
2082 | 1758 dnode_diduse_space(dnode_t *dn, int64_t delta) |
789 | 1759 { |
2082 | 1760 uint64_t space; |
1761 dprintf_dnode(dn, "dn=%p dnp=%p used=%llu delta=%lld\n", | |
789 | 1762 dn, dn->dn_phys, |
2082 | 1763 (u_longlong_t)dn->dn_phys->dn_used, |
1764 (longlong_t)delta); | |
789 | 1765 |
1766 mutex_enter(&dn->dn_mtx); | |
2082 | 1767 space = DN_USED_BYTES(dn->dn_phys); |
1768 if (delta > 0) { | |
1769 ASSERT3U(space + delta, >=, space); /* no overflow */ | |
789 | 1770 } else { |
2082 | 1771 ASSERT3U(space, >=, -delta); /* no underflow */ |
1772 } | |
1773 space += delta; | |
4577 | 1774 if (spa_version(dn->dn_objset->os_spa) < SPA_VERSION_DNODE_BYTES) { |
2082 | 1775 ASSERT((dn->dn_phys->dn_flags & DNODE_FLAG_USED_BYTES) == 0); |
13805
e3a9ae14a119
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Madhav Suresh <madhav.suresh@delphix.com>
parents:
13765
diff
changeset
|
1776 ASSERT0(P2PHASE(space, 1<<DEV_BSHIFT)); |
2082 | 1777 dn->dn_phys->dn_used = space >> DEV_BSHIFT; |
1778 } else { | |
1779 dn->dn_phys->dn_used = space; | |
1780 dn->dn_phys->dn_flags |= DNODE_FLAG_USED_BYTES; | |
789 | 1781 } |
1782 mutex_exit(&dn->dn_mtx); | |
1783 } | |
1784 | |
1785 /* | |
1786 * Call when we think we're going to write/free space in open context. | |
1787 * Be conservative (ie. OK to write less than this or free more than | |
1788 * this, but don't write more or free less). | |
1789 */ | |
1790 void | |
1791 dnode_willuse_space(dnode_t *dn, int64_t space, dmu_tx_t *tx) | |
1792 { | |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9950
diff
changeset
|
1793 objset_t *os = dn->dn_objset; |
789 | 1794 dsl_dataset_t *ds = os->os_dsl_dataset; |
1795 | |
1796 if (space > 0) | |
1797 space = spa_get_asize(os->os_spa, space); | |
1798 | |
1799 if (ds) | |
1800 dsl_dir_willuse_space(ds->ds_dir, space, tx); | |
1801 | |
1802 dmu_tx_willuse_space(tx, space); | |
1803 } | |
1804 | |
9950
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1805 /* |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1806 * This function scans a block at the indicated "level" looking for |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1807 * a hole or data (depending on 'flags'). If level > 0, then we are |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1808 * scanning an indirect block looking at its pointers. If level == 0, |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1809 * then we are looking at a block of dnodes. If we don't find what we |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1810 * are looking for in the block, we return ESRCH. Otherwise, return |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1811 * with *offset pointing to the beginning (if searching forwards) or |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1812 * end (if searching backwards) of the range covered by the block |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1813 * pointer we matched on (or dnode). |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1814 * |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1815 * The basic search algorithm used below by dnode_next_offset() is to |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1816 * use this function to search up the block tree (widen the search) until |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1817 * we find something (i.e., we don't return ESRCH) and then search back |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1818 * down the tree (narrow the search) until we reach our original search |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1819 * level. |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1820 */ |
789 | 1821 static int |
6992 | 1822 dnode_next_offset_level(dnode_t *dn, int flags, uint64_t *offset, |
3025
4e5ee8301d84
6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents:
2885
diff
changeset
|
1823 int lvl, uint64_t blkfill, uint64_t txg) |
789 | 1824 { |
1825 dmu_buf_impl_t *db = NULL; | |
1826 void *data = NULL; | |
1827 uint64_t epbs = dn->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT; | |
1828 uint64_t epb = 1ULL << epbs; | |
1829 uint64_t minfill, maxfill; | |
6992 | 1830 boolean_t hole; |
1831 int i, inc, error, span; | |
789 | 1832 |
1833 dprintf("probing object %llu offset %llx level %d of %u\n", | |
1834 dn->dn_object, *offset, lvl, dn->dn_phys->dn_nlevels); | |
1835 | |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
1836 hole = ((flags & DNODE_FIND_HOLE) != 0); |
6992 | 1837 inc = (flags & DNODE_FIND_BACKWARDS) ? -1 : 1; |
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
|
1838 ASSERT(txg == 0 || !hole); |
6992 | 1839 |
789 | 1840 if (lvl == dn->dn_phys->dn_nlevels) { |
1841 error = 0; | |
1842 epb = dn->dn_phys->dn_nblkptr; | |
1843 data = dn->dn_phys->dn_blkptr; | |
1844 } else { | |
1845 uint64_t blkid = dbuf_whichblock(dn, *offset) >> (epbs * lvl); | |
1846 error = dbuf_hold_impl(dn, lvl, blkid, TRUE, FTAG, &db); | |
1847 if (error) { | |
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
|
1848 if (error != ENOENT) |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
1849 return (error); |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
1850 if (hole) |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
1851 return (0); |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
1852 /* |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
1853 * This can only happen when we are searching up |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
1854 * the block tree for data. We don't really need to |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
1855 * adjust the offset, as we will just end up looking |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
1856 * at the pointer to this block in its parent, and its |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
1857 * going to be unallocated, so we will skip over it. |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
1858 */ |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
1859 return (ESRCH); |
789 | 1860 } |
1793
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1646
diff
changeset
|
1861 error = dbuf_read(db, NULL, DB_RF_CANFAIL | DB_RF_HAVESTRUCT); |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1646
diff
changeset
|
1862 if (error) { |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1646
diff
changeset
|
1863 dbuf_rele(db, FTAG); |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1646
diff
changeset
|
1864 return (error); |
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1646
diff
changeset
|
1865 } |
789 | 1866 data = db->db.db_data; |
1867 } | |
1868 | |
3025
4e5ee8301d84
6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents:
2885
diff
changeset
|
1869 if (db && txg && |
4e5ee8301d84
6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents:
2885
diff
changeset
|
1870 (db->db_blkptr == NULL || db->db_blkptr->blk_birth <= txg)) { |
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
|
1871 /* |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
1872 * This can only happen when we are searching up the tree |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
1873 * and these conditions mean that we need to keep climbing. |
f69ff8507427
6727817 ZFS assertion failure (zero length arc_buf_alloc) during NFS I/O
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7332
diff
changeset
|
1874 */ |
3025
4e5ee8301d84
6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents:
2885
diff
changeset
|
1875 error = ESRCH; |
4e5ee8301d84
6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents:
2885
diff
changeset
|
1876 } else if (lvl == 0) { |
789 | 1877 dnode_phys_t *dnp = data; |
1878 span = DNODE_SHIFT; | |
1879 ASSERT(dn->dn_type == DMU_OT_DNODE); | |
1880 | |
6992 | 1881 for (i = (*offset >> span) & (blkfill - 1); |
1882 i >= 0 && i < blkfill; i += inc) { | |
9409
9dc3f17354ed
6809683 zfs destroy fails to free object in open context, stops up txg train
Jonathan W Adams <Jonathan.Adams@Sun.COM>
parents:
9396
diff
changeset
|
1883 if ((dnp[i].dn_type == DMU_OT_NONE) == hole) |
789 | 1884 break; |
6992 | 1885 *offset += (1ULL << span) * inc; |
789 | 1886 } |
6992 | 1887 if (i < 0 || i == blkfill) |
789 | 1888 error = ESRCH; |
1889 } else { | |
1890 blkptr_t *bp = data; | |
9950
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1891 uint64_t start = *offset; |
789 | 1892 span = (lvl - 1) * epbs + dn->dn_datablkshift; |
1893 minfill = 0; | |
1894 maxfill = blkfill << ((lvl - 1) * epbs); | |
1895 | |
1896 if (hole) | |
1897 maxfill--; | |
1898 else | |
1899 minfill++; | |
1900 | |
9950
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1901 *offset = *offset >> span; |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1902 for (i = BF64_GET(*offset, 0, epbs); |
6992 | 1903 i >= 0 && i < epb; i += inc) { |
789 | 1904 if (bp[i].blk_fill >= minfill && |
3025
4e5ee8301d84
6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents:
2885
diff
changeset
|
1905 bp[i].blk_fill <= maxfill && |
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
|
1906 (hole || bp[i].blk_birth > txg)) |
789 | 1907 break; |
9950
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1908 if (inc > 0 || *offset > 0) |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1909 *offset += inc; |
789 | 1910 } |
9950
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1911 *offset = *offset << span; |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1912 if (inc < 0) { |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1913 /* traversing backwards; position offset at the end */ |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1914 ASSERT3U(*offset, <=, start); |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1915 *offset = MIN(*offset + (1ULL << span) - 1, start); |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1916 } else if (*offset < start) { |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1917 *offset = start; |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1918 } |
78fc41aa9bc5
6792701 Removing large holey file does not free space
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
9409
diff
changeset
|
1919 if (i < 0 || i >= epb) |
789 | 1920 error = ESRCH; |
1921 } | |
1922 | |
1923 if (db) | |
1544 | 1924 dbuf_rele(db, FTAG); |
789 | 1925 |
1926 return (error); | |
1927 } | |
1928 | |
1929 /* | |
1930 * Find the next hole, data, or sparse region at or after *offset. | |
1931 * The value 'blkfill' tells us how many items we expect to find | |
1932 * in an L0 data block; this value is 1 for normal objects, | |
1933 * DNODES_PER_BLOCK for the meta dnode, and some fraction of | |
1934 * DNODES_PER_BLOCK when searching for sparse regions thereof. | |
3025
4e5ee8301d84
6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents:
2885
diff
changeset
|
1935 * |
789 | 1936 * Examples: |
1937 * | |
6992 | 1938 * dnode_next_offset(dn, flags, offset, 1, 1, 0); |
1939 * Finds the next/previous hole/data in a file. | |
789 | 1940 * Used in dmu_offset_next(). |
1941 * | |
6992 | 1942 * dnode_next_offset(mdn, flags, offset, 0, DNODES_PER_BLOCK, txg); |
789 | 1943 * Finds the next free/allocated dnode an objset's meta-dnode. |
3025
4e5ee8301d84
6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents:
2885
diff
changeset
|
1944 * Only finds objects that have new contents since txg (ie. |
4e5ee8301d84
6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents:
2885
diff
changeset
|
1945 * bonus buffer changes and content removal are ignored). |
789 | 1946 * Used in dmu_object_next(). |
1947 * | |
6992 | 1948 * dnode_next_offset(mdn, DNODE_FIND_HOLE, offset, 2, DNODES_PER_BLOCK >> 2, 0); |
789 | 1949 * Finds the next L2 meta-dnode bp that's at most 1/4 full. |
1950 * Used in dmu_object_alloc(). | |
1951 */ | |
1952 int | |
6992 | 1953 dnode_next_offset(dnode_t *dn, int flags, uint64_t *offset, |
3025
4e5ee8301d84
6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents:
2885
diff
changeset
|
1954 int minlvl, uint64_t blkfill, uint64_t txg) |
789 | 1955 { |
6992 | 1956 uint64_t initial_offset = *offset; |
789 | 1957 int lvl, maxlvl; |
1958 int error = 0; | |
1959 | |
6992 | 1960 if (!(flags & DNODE_FIND_HAVELOCK)) |
1961 rw_enter(&dn->dn_struct_rwlock, RW_READER); | |
789 | 1962 |
1963 if (dn->dn_phys->dn_nlevels == 0) { | |
6992 | 1964 error = ESRCH; |
1965 goto out; | |
789 | 1966 } |
1967 | |
1968 if (dn->dn_datablkshift == 0) { | |
1969 if (*offset < dn->dn_datablksz) { | |
6992 | 1970 if (flags & DNODE_FIND_HOLE) |
789 | 1971 *offset = dn->dn_datablksz; |
1972 } else { | |
1973 error = ESRCH; | |
1974 } | |
6992 | 1975 goto out; |
789 | 1976 } |
1977 | |
1978 maxlvl = dn->dn_phys->dn_nlevels; | |
1979 | |
1980 for (lvl = minlvl; lvl <= maxlvl; lvl++) { | |
3025
4e5ee8301d84
6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents:
2885
diff
changeset
|
1981 error = dnode_next_offset_level(dn, |
6992 | 1982 flags, offset, lvl, blkfill, txg); |
1793
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1646
diff
changeset
|
1983 if (error != ESRCH) |
789 | 1984 break; |
1985 } | |
1986 | |
6992 | 1987 while (error == 0 && --lvl >= minlvl) { |
3025
4e5ee8301d84
6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents:
2885
diff
changeset
|
1988 error = dnode_next_offset_level(dn, |
6992 | 1989 flags, offset, lvl, blkfill, txg); |
3025
4e5ee8301d84
6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents:
2885
diff
changeset
|
1990 } |
789 | 1991 |
6992 | 1992 if (error == 0 && (flags & DNODE_FIND_BACKWARDS ? |
1993 initial_offset < *offset : initial_offset > *offset)) | |
1793
d371fba21a3e
6407444 unhandled i/o error from dnode_next_offset_level()
ahrens
parents:
1646
diff
changeset
|
1994 error = ESRCH; |
6992 | 1995 out: |
1996 if (!(flags & DNODE_FIND_HAVELOCK)) | |
1997 rw_exit(&dn->dn_struct_rwlock); | |
789 | 1998 |
1999 return (error); | |
2000 } |