author | Christopher Siden <chris.siden@delphix.com> |
Mon, 21 May 2012 12:11:39 -0700 | |
changeset 13700 | 2889e2596bd6 |
parent 12450 | c77e20e4e046 |
child 13764 | 38b4aca480b3 |
permissions | -rw-r--r-- |
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:
885
diff
changeset
|
5 |
* Common Development and Distribution License (the "License"). |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
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 |
/* |
|
12285
d736d62dcca2
6944833 Avoid prefetching dbufs in dmu_sync() path
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
11165
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:
12450
diff
changeset
|
23 |
* Copyright (c) 2012 by Delphix. All rights reserved. |
789 | 24 |
*/ |
25 |
||
26 |
/* |
|
27 |
* This file contains the top half of the zfs directory structure |
|
28 |
* implementation. The bottom half is in zap_leaf.c. |
|
29 |
* |
|
30 |
* The zdir is an extendable hash data structure. There is a table of |
|
31 |
* pointers to buckets (zap_t->zd_data->zd_leafs). The buckets are |
|
32 |
* each a constant size and hold a variable number of directory entries. |
|
33 |
* The buckets (aka "leaf nodes") are implemented in zap_leaf.c. |
|
34 |
* |
|
35 |
* The pointer table holds a power of 2 number of pointers. |
|
36 |
* (1<<zap_t->zd_data->zd_phys->zd_prefix_len). The bucket pointed to |
|
37 |
* by the pointer at index i in the table holds entries whose hash value |
|
38 |
* has a zd_prefix_len - bit prefix |
|
39 |
*/ |
|
40 |
||
41 |
#include <sys/spa.h> |
|
42 |
#include <sys/dmu.h> |
|
43 |
#include <sys/zfs_context.h> |
|
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5497
diff
changeset
|
44 |
#include <sys/zfs_znode.h> |
9643
ffd8e7765f02
6736004 zvols need an additional property for comstar support
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7046
diff
changeset
|
45 |
#include <sys/fs/zfs.h> |
789 | 46 |
#include <sys/zap.h> |
1544 | 47 |
#include <sys/refcount.h> |
789 | 48 |
#include <sys/zap_impl.h> |
49 |
#include <sys/zap_leaf.h> |
|
50 |
||
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
51 |
int fzap_default_block_shift = 14; /* 16k blocksize */ |
789 | 52 |
|
53 |
static void zap_leaf_pageout(dmu_buf_t *db, void *vl); |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
54 |
static uint64_t zap_allocate_blocks(zap_t *zap, int nblocks); |
789 | 55 |
|
56 |
||
57 |
void |
|
58 |
fzap_byteswap(void *vbuf, size_t size) |
|
59 |
{ |
|
60 |
uint64_t block_type; |
|
61 |
||
62 |
block_type = *(uint64_t *)vbuf; |
|
63 |
||
2856 | 64 |
if (block_type == ZBT_LEAF || block_type == BSWAP_64(ZBT_LEAF)) |
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
65 |
zap_leaf_byteswap(vbuf, size); |
2856 | 66 |
else { |
789 | 67 |
/* it's a ptrtbl block */ |
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
68 |
byteswap_uint64_array(vbuf, size); |
789 | 69 |
} |
70 |
} |
|
71 |
||
72 |
void |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10612
diff
changeset
|
73 |
fzap_upgrade(zap_t *zap, dmu_tx_t *tx, zap_flags_t flags) |
789 | 74 |
{ |
75 |
dmu_buf_t *db; |
|
76 |
zap_leaf_t *l; |
|
77 |
int i; |
|
78 |
zap_phys_t *zp; |
|
79 |
||
80 |
ASSERT(RW_WRITE_HELD(&zap->zap_rwlock)); |
|
81 |
zap->zap_ismicro = FALSE; |
|
82 |
||
83 |
(void) dmu_buf_update_user(zap->zap_dbuf, zap, zap, |
|
2641 | 84 |
&zap->zap_f.zap_phys, zap_evict); |
789 | 85 |
|
86 |
mutex_init(&zap->zap_f.zap_num_entries_mtx, 0, 0, 0); |
|
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
87 |
zap->zap_f.zap_block_shift = highbit(zap->zap_dbuf->db_size) - 1; |
789 | 88 |
|
89 |
zp = zap->zap_f.zap_phys; |
|
90 |
/* |
|
91 |
* explicitly zero it since it might be coming from an |
|
92 |
* initialized microzap |
|
93 |
*/ |
|
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
94 |
bzero(zap->zap_dbuf->db_data, zap->zap_dbuf->db_size); |
789 | 95 |
zp->zap_block_type = ZBT_HEADER; |
96 |
zp->zap_magic = ZAP_MAGIC; |
|
97 |
||
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
98 |
zp->zap_ptrtbl.zt_shift = ZAP_EMBEDDED_PTRTBL_SHIFT(zap); |
789 | 99 |
|
100 |
zp->zap_freeblk = 2; /* block 1 will be the first leaf */ |
|
101 |
zp->zap_num_leafs = 1; |
|
102 |
zp->zap_num_entries = 0; |
|
103 |
zp->zap_salt = zap->zap_salt; |
|
5331 | 104 |
zp->zap_normflags = zap->zap_normflags; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10612
diff
changeset
|
105 |
zp->zap_flags = flags; |
789 | 106 |
|
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
107 |
/* block 1 will be the first leaf */ |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
108 |
for (i = 0; i < (1<<zp->zap_ptrtbl.zt_shift); i++) |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
109 |
ZAP_EMBEDDED_PTRTBL_ENT(zap, i) = 1; |
789 | 110 |
|
111 |
/* |
|
112 |
* set up block 1 - the first leaf |
|
113 |
*/ |
|
1544 | 114 |
VERIFY(0 == dmu_buf_hold(zap->zap_objset, zap->zap_object, |
12285
d736d62dcca2
6944833 Avoid prefetching dbufs in dmu_sync() path
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
11165
diff
changeset
|
115 |
1<<FZAP_BLOCK_SHIFT(zap), FTAG, &db, DMU_READ_NO_PREFETCH)); |
789 | 116 |
dmu_buf_will_dirty(db, tx); |
117 |
||
118 |
l = kmem_zalloc(sizeof (zap_leaf_t), KM_SLEEP); |
|
119 |
l->l_dbuf = db; |
|
120 |
l->l_phys = db->db_data; |
|
121 |
||
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5497
diff
changeset
|
122 |
zap_leaf_init(l, zp->zap_normflags != 0); |
789 | 123 |
|
124 |
kmem_free(l, sizeof (zap_leaf_t)); |
|
1544 | 125 |
dmu_buf_rele(db, FTAG); |
789 | 126 |
} |
127 |
||
128 |
static int |
|
129 |
zap_tryupgradedir(zap_t *zap, dmu_tx_t *tx) |
|
130 |
{ |
|
131 |
if (RW_WRITE_HELD(&zap->zap_rwlock)) |
|
132 |
return (1); |
|
133 |
if (rw_tryupgrade(&zap->zap_rwlock)) { |
|
134 |
dmu_buf_will_dirty(zap->zap_dbuf, tx); |
|
135 |
return (1); |
|
136 |
} |
|
137 |
return (0); |
|
138 |
} |
|
139 |
||
140 |
/* |
|
141 |
* Generic routines for dealing with the pointer & cookie tables. |
|
142 |
*/ |
|
143 |
||
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
144 |
static int |
789 | 145 |
zap_table_grow(zap_t *zap, zap_table_phys_t *tbl, |
146 |
void (*transfer_func)(const uint64_t *src, uint64_t *dst, int n), |
|
147 |
dmu_tx_t *tx) |
|
148 |
{ |
|
149 |
uint64_t b, newblk; |
|
150 |
dmu_buf_t *db_old, *db_new; |
|
1544 | 151 |
int err; |
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
152 |
int bs = FZAP_BLOCK_SHIFT(zap); |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
153 |
int hepb = 1<<(bs-4); |
789 | 154 |
/* hepb = half the number of entries in a block */ |
155 |
||
156 |
ASSERT(RW_WRITE_HELD(&zap->zap_rwlock)); |
|
157 |
ASSERT(tbl->zt_blk != 0); |
|
158 |
ASSERT(tbl->zt_numblks > 0); |
|
159 |
||
160 |
if (tbl->zt_nextblk != 0) { |
|
161 |
newblk = tbl->zt_nextblk; |
|
162 |
} else { |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
163 |
newblk = zap_allocate_blocks(zap, tbl->zt_numblks * 2); |
789 | 164 |
tbl->zt_nextblk = newblk; |
165 |
ASSERT3U(tbl->zt_blks_copied, ==, 0); |
|
166 |
dmu_prefetch(zap->zap_objset, zap->zap_object, |
|
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
167 |
tbl->zt_blk << bs, tbl->zt_numblks << bs); |
789 | 168 |
} |
169 |
||
170 |
/* |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
171 |
* Copy the ptrtbl from the old to new location. |
789 | 172 |
*/ |
173 |
||
174 |
b = tbl->zt_blks_copied; |
|
1544 | 175 |
err = dmu_buf_hold(zap->zap_objset, zap->zap_object, |
12285
d736d62dcca2
6944833 Avoid prefetching dbufs in dmu_sync() path
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
11165
diff
changeset
|
176 |
(tbl->zt_blk + b) << bs, FTAG, &db_old, DMU_READ_NO_PREFETCH); |
1544 | 177 |
if (err) |
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
178 |
return (err); |
789 | 179 |
|
180 |
/* first half of entries in old[b] go to new[2*b+0] */ |
|
1544 | 181 |
VERIFY(0 == dmu_buf_hold(zap->zap_objset, zap->zap_object, |
12285
d736d62dcca2
6944833 Avoid prefetching dbufs in dmu_sync() path
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
11165
diff
changeset
|
182 |
(newblk + 2*b+0) << bs, FTAG, &db_new, DMU_READ_NO_PREFETCH)); |
789 | 183 |
dmu_buf_will_dirty(db_new, tx); |
184 |
transfer_func(db_old->db_data, db_new->db_data, hepb); |
|
1544 | 185 |
dmu_buf_rele(db_new, FTAG); |
789 | 186 |
|
187 |
/* second half of entries in old[b] go to new[2*b+1] */ |
|
1544 | 188 |
VERIFY(0 == dmu_buf_hold(zap->zap_objset, zap->zap_object, |
12285
d736d62dcca2
6944833 Avoid prefetching dbufs in dmu_sync() path
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
11165
diff
changeset
|
189 |
(newblk + 2*b+1) << bs, FTAG, &db_new, DMU_READ_NO_PREFETCH)); |
789 | 190 |
dmu_buf_will_dirty(db_new, tx); |
191 |
transfer_func((uint64_t *)db_old->db_data + hepb, |
|
192 |
db_new->db_data, hepb); |
|
1544 | 193 |
dmu_buf_rele(db_new, FTAG); |
789 | 194 |
|
1544 | 195 |
dmu_buf_rele(db_old, FTAG); |
789 | 196 |
|
197 |
tbl->zt_blks_copied++; |
|
198 |
||
199 |
dprintf("copied block %llu of %llu\n", |
|
200 |
tbl->zt_blks_copied, tbl->zt_numblks); |
|
201 |
||
202 |
if (tbl->zt_blks_copied == tbl->zt_numblks) { |
|
1544 | 203 |
(void) dmu_free_range(zap->zap_objset, zap->zap_object, |
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
204 |
tbl->zt_blk << bs, tbl->zt_numblks << bs, tx); |
789 | 205 |
|
206 |
tbl->zt_blk = newblk; |
|
207 |
tbl->zt_numblks *= 2; |
|
208 |
tbl->zt_shift++; |
|
209 |
tbl->zt_nextblk = 0; |
|
210 |
tbl->zt_blks_copied = 0; |
|
211 |
||
212 |
dprintf("finished; numblocks now %llu (%lluk entries)\n", |
|
213 |
tbl->zt_numblks, 1<<(tbl->zt_shift-10)); |
|
214 |
} |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
215 |
|
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
216 |
return (0); |
789 | 217 |
} |
218 |
||
1544 | 219 |
static int |
789 | 220 |
zap_table_store(zap_t *zap, zap_table_phys_t *tbl, uint64_t idx, uint64_t val, |
221 |
dmu_tx_t *tx) |
|
222 |
{ |
|
1544 | 223 |
int err; |
224 |
uint64_t blk, off; |
|
225 |
int bs = FZAP_BLOCK_SHIFT(zap); |
|
789 | 226 |
dmu_buf_t *db; |
227 |
||
228 |
ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); |
|
229 |
ASSERT(tbl->zt_blk != 0); |
|
230 |
||
231 |
dprintf("storing %llx at index %llx\n", val, idx); |
|
232 |
||
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
233 |
blk = idx >> (bs-3); |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
234 |
off = idx & ((1<<(bs-3))-1); |
789 | 235 |
|
1544 | 236 |
err = dmu_buf_hold(zap->zap_objset, zap->zap_object, |
12285
d736d62dcca2
6944833 Avoid prefetching dbufs in dmu_sync() path
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
11165
diff
changeset
|
237 |
(tbl->zt_blk + blk) << bs, FTAG, &db, DMU_READ_NO_PREFETCH); |
1544 | 238 |
if (err) |
239 |
return (err); |
|
789 | 240 |
dmu_buf_will_dirty(db, tx); |
241 |
||
242 |
if (tbl->zt_nextblk != 0) { |
|
1544 | 243 |
uint64_t idx2 = idx * 2; |
244 |
uint64_t blk2 = idx2 >> (bs-3); |
|
245 |
uint64_t off2 = idx2 & ((1<<(bs-3))-1); |
|
246 |
dmu_buf_t *db2; |
|
789 | 247 |
|
1544 | 248 |
err = dmu_buf_hold(zap->zap_objset, zap->zap_object, |
12285
d736d62dcca2
6944833 Avoid prefetching dbufs in dmu_sync() path
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
11165
diff
changeset
|
249 |
(tbl->zt_nextblk + blk2) << bs, FTAG, &db2, |
d736d62dcca2
6944833 Avoid prefetching dbufs in dmu_sync() path
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
11165
diff
changeset
|
250 |
DMU_READ_NO_PREFETCH); |
1544 | 251 |
if (err) { |
252 |
dmu_buf_rele(db, FTAG); |
|
253 |
return (err); |
|
254 |
} |
|
255 |
dmu_buf_will_dirty(db2, tx); |
|
256 |
((uint64_t *)db2->db_data)[off2] = val; |
|
257 |
((uint64_t *)db2->db_data)[off2+1] = val; |
|
258 |
dmu_buf_rele(db2, FTAG); |
|
789 | 259 |
} |
260 |
||
1544 | 261 |
((uint64_t *)db->db_data)[off] = val; |
262 |
dmu_buf_rele(db, FTAG); |
|
263 |
||
264 |
return (0); |
|
789 | 265 |
} |
266 |
||
1544 | 267 |
static int |
268 |
zap_table_load(zap_t *zap, zap_table_phys_t *tbl, uint64_t idx, uint64_t *valp) |
|
789 | 269 |
{ |
1544 | 270 |
uint64_t blk, off; |
271 |
int err; |
|
789 | 272 |
dmu_buf_t *db; |
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
273 |
int bs = FZAP_BLOCK_SHIFT(zap); |
789 | 274 |
|
275 |
ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); |
|
276 |
||
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
277 |
blk = idx >> (bs-3); |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
278 |
off = idx & ((1<<(bs-3))-1); |
789 | 279 |
|
1544 | 280 |
err = dmu_buf_hold(zap->zap_objset, zap->zap_object, |
12285
d736d62dcca2
6944833 Avoid prefetching dbufs in dmu_sync() path
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
11165
diff
changeset
|
281 |
(tbl->zt_blk + blk) << bs, FTAG, &db, DMU_READ_NO_PREFETCH); |
1544 | 282 |
if (err) |
283 |
return (err); |
|
284 |
*valp = ((uint64_t *)db->db_data)[off]; |
|
285 |
dmu_buf_rele(db, FTAG); |
|
286 |
||
287 |
if (tbl->zt_nextblk != 0) { |
|
288 |
/* |
|
289 |
* read the nextblk for the sake of i/o error checking, |
|
290 |
* so that zap_table_load() will catch errors for |
|
291 |
* zap_table_store. |
|
292 |
*/ |
|
293 |
blk = (idx*2) >> (bs-3); |
|
294 |
||
295 |
err = dmu_buf_hold(zap->zap_objset, zap->zap_object, |
|
12285
d736d62dcca2
6944833 Avoid prefetching dbufs in dmu_sync() path
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
11165
diff
changeset
|
296 |
(tbl->zt_nextblk + blk) << bs, FTAG, &db, |
d736d62dcca2
6944833 Avoid prefetching dbufs in dmu_sync() path
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
11165
diff
changeset
|
297 |
DMU_READ_NO_PREFETCH); |
1544 | 298 |
dmu_buf_rele(db, FTAG); |
299 |
} |
|
300 |
return (err); |
|
789 | 301 |
} |
302 |
||
303 |
/* |
|
304 |
* Routines for growing the ptrtbl. |
|
305 |
*/ |
|
306 |
||
307 |
static void |
|
308 |
zap_ptrtbl_transfer(const uint64_t *src, uint64_t *dst, int n) |
|
309 |
{ |
|
310 |
int i; |
|
311 |
for (i = 0; i < n; i++) { |
|
312 |
uint64_t lb = src[i]; |
|
313 |
dst[2*i+0] = lb; |
|
314 |
dst[2*i+1] = lb; |
|
315 |
} |
|
316 |
} |
|
317 |
||
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
318 |
static int |
789 | 319 |
zap_grow_ptrtbl(zap_t *zap, dmu_tx_t *tx) |
320 |
{ |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10612
diff
changeset
|
321 |
/* |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10612
diff
changeset
|
322 |
* The pointer table should never use more hash bits than we |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10612
diff
changeset
|
323 |
* have (otherwise we'd be using useless zero bits to index it). |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10612
diff
changeset
|
324 |
* If we are within 2 bits of running out, stop growing, since |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10612
diff
changeset
|
325 |
* this is already an aberrant condition. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10612
diff
changeset
|
326 |
*/ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10612
diff
changeset
|
327 |
if (zap->zap_f.zap_phys->zap_ptrtbl.zt_shift >= zap_hashbits(zap) - 2) |
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
328 |
return (ENOSPC); |
789 | 329 |
|
330 |
if (zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks == 0) { |
|
331 |
/* |
|
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
332 |
* We are outgrowing the "embedded" ptrtbl (the one |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
333 |
* stored in the header block). Give it its own entire |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
334 |
* block, which will double the size of the ptrtbl. |
789 | 335 |
*/ |
336 |
uint64_t newblk; |
|
337 |
dmu_buf_t *db_new; |
|
1544 | 338 |
int err; |
789 | 339 |
|
340 |
ASSERT3U(zap->zap_f.zap_phys->zap_ptrtbl.zt_shift, ==, |
|
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
341 |
ZAP_EMBEDDED_PTRTBL_SHIFT(zap)); |
789 | 342 |
ASSERT3U(zap->zap_f.zap_phys->zap_ptrtbl.zt_blk, ==, 0); |
343 |
||
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
344 |
newblk = zap_allocate_blocks(zap, 1); |
1544 | 345 |
err = dmu_buf_hold(zap->zap_objset, zap->zap_object, |
12285
d736d62dcca2
6944833 Avoid prefetching dbufs in dmu_sync() path
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
11165
diff
changeset
|
346 |
newblk << FZAP_BLOCK_SHIFT(zap), FTAG, &db_new, |
d736d62dcca2
6944833 Avoid prefetching dbufs in dmu_sync() path
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
11165
diff
changeset
|
347 |
DMU_READ_NO_PREFETCH); |
1544 | 348 |
if (err) |
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
349 |
return (err); |
789 | 350 |
dmu_buf_will_dirty(db_new, tx); |
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
351 |
zap_ptrtbl_transfer(&ZAP_EMBEDDED_PTRTBL_ENT(zap, 0), |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
352 |
db_new->db_data, 1 << ZAP_EMBEDDED_PTRTBL_SHIFT(zap)); |
1544 | 353 |
dmu_buf_rele(db_new, FTAG); |
789 | 354 |
|
355 |
zap->zap_f.zap_phys->zap_ptrtbl.zt_blk = newblk; |
|
356 |
zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks = 1; |
|
357 |
zap->zap_f.zap_phys->zap_ptrtbl.zt_shift++; |
|
358 |
||
359 |
ASSERT3U(1ULL << zap->zap_f.zap_phys->zap_ptrtbl.zt_shift, ==, |
|
360 |
zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks << |
|
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
361 |
(FZAP_BLOCK_SHIFT(zap)-3)); |
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
362 |
|
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
363 |
return (0); |
789 | 364 |
} else { |
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
365 |
return (zap_table_grow(zap, &zap->zap_f.zap_phys->zap_ptrtbl, |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
366 |
zap_ptrtbl_transfer, tx)); |
789 | 367 |
} |
368 |
} |
|
369 |
||
370 |
static void |
|
371 |
zap_increment_num_entries(zap_t *zap, int delta, dmu_tx_t *tx) |
|
372 |
{ |
|
373 |
dmu_buf_will_dirty(zap->zap_dbuf, tx); |
|
374 |
mutex_enter(&zap->zap_f.zap_num_entries_mtx); |
|
375 |
ASSERT(delta > 0 || zap->zap_f.zap_phys->zap_num_entries >= -delta); |
|
376 |
zap->zap_f.zap_phys->zap_num_entries += delta; |
|
377 |
mutex_exit(&zap->zap_f.zap_num_entries_mtx); |
|
378 |
} |
|
379 |
||
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
380 |
static uint64_t |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
381 |
zap_allocate_blocks(zap_t *zap, int nblocks) |
789 | 382 |
{ |
383 |
uint64_t newblk; |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
384 |
ASSERT(RW_WRITE_HELD(&zap->zap_rwlock)); |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
385 |
newblk = zap->zap_f.zap_phys->zap_freeblk; |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
386 |
zap->zap_f.zap_phys->zap_freeblk += nblocks; |
789 | 387 |
return (newblk); |
388 |
} |
|
389 |
||
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
390 |
static zap_leaf_t * |
789 | 391 |
zap_create_leaf(zap_t *zap, dmu_tx_t *tx) |
392 |
{ |
|
393 |
void *winner; |
|
394 |
zap_leaf_t *l = kmem_alloc(sizeof (zap_leaf_t), KM_SLEEP); |
|
395 |
||
396 |
ASSERT(RW_WRITE_HELD(&zap->zap_rwlock)); |
|
397 |
||
398 |
rw_init(&l->l_rwlock, 0, 0, 0); |
|
399 |
rw_enter(&l->l_rwlock, RW_WRITER); |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
400 |
l->l_blkid = zap_allocate_blocks(zap, 1); |
789 | 401 |
l->l_dbuf = NULL; |
402 |
l->l_phys = NULL; |
|
403 |
||
1544 | 404 |
VERIFY(0 == dmu_buf_hold(zap->zap_objset, zap->zap_object, |
12285
d736d62dcca2
6944833 Avoid prefetching dbufs in dmu_sync() path
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
11165
diff
changeset
|
405 |
l->l_blkid << FZAP_BLOCK_SHIFT(zap), NULL, &l->l_dbuf, |
d736d62dcca2
6944833 Avoid prefetching dbufs in dmu_sync() path
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
11165
diff
changeset
|
406 |
DMU_READ_NO_PREFETCH)); |
789 | 407 |
winner = dmu_buf_set_user(l->l_dbuf, l, &l->l_phys, zap_leaf_pageout); |
408 |
ASSERT(winner == NULL); |
|
409 |
dmu_buf_will_dirty(l->l_dbuf, tx); |
|
410 |
||
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5497
diff
changeset
|
411 |
zap_leaf_init(l, zap->zap_normflags != 0); |
789 | 412 |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
413 |
zap->zap_f.zap_phys->zap_num_leafs++; |
789 | 414 |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
415 |
return (l); |
789 | 416 |
} |
417 |
||
418 |
int |
|
419 |
fzap_count(zap_t *zap, uint64_t *count) |
|
420 |
{ |
|
421 |
ASSERT(!zap->zap_ismicro); |
|
422 |
mutex_enter(&zap->zap_f.zap_num_entries_mtx); /* unnecessary */ |
|
423 |
*count = zap->zap_f.zap_phys->zap_num_entries; |
|
424 |
mutex_exit(&zap->zap_f.zap_num_entries_mtx); |
|
425 |
return (0); |
|
426 |
} |
|
427 |
||
428 |
/* |
|
429 |
* Routines for obtaining zap_leaf_t's |
|
430 |
*/ |
|
431 |
||
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
432 |
void |
789 | 433 |
zap_put_leaf(zap_leaf_t *l) |
434 |
{ |
|
435 |
rw_exit(&l->l_rwlock); |
|
1544 | 436 |
dmu_buf_rele(l->l_dbuf, NULL); |
789 | 437 |
} |
438 |
||
439 |
_NOTE(ARGSUSED(0)) |
|
440 |
static void |
|
441 |
zap_leaf_pageout(dmu_buf_t *db, void *vl) |
|
442 |
{ |
|
443 |
zap_leaf_t *l = vl; |
|
444 |
||
445 |
rw_destroy(&l->l_rwlock); |
|
446 |
kmem_free(l, sizeof (zap_leaf_t)); |
|
447 |
} |
|
448 |
||
449 |
static zap_leaf_t * |
|
450 |
zap_open_leaf(uint64_t blkid, dmu_buf_t *db) |
|
451 |
{ |
|
452 |
zap_leaf_t *l, *winner; |
|
453 |
||
454 |
ASSERT(blkid != 0); |
|
455 |
||
456 |
l = kmem_alloc(sizeof (zap_leaf_t), KM_SLEEP); |
|
457 |
rw_init(&l->l_rwlock, 0, 0, 0); |
|
458 |
rw_enter(&l->l_rwlock, RW_WRITER); |
|
459 |
l->l_blkid = blkid; |
|
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
460 |
l->l_bs = highbit(db->db_size)-1; |
789 | 461 |
l->l_dbuf = db; |
462 |
l->l_phys = NULL; |
|
463 |
||
464 |
winner = dmu_buf_set_user(db, l, &l->l_phys, zap_leaf_pageout); |
|
465 |
||
466 |
rw_exit(&l->l_rwlock); |
|
467 |
if (winner != NULL) { |
|
468 |
/* someone else set it first */ |
|
469 |
zap_leaf_pageout(NULL, l); |
|
470 |
l = winner; |
|
471 |
} |
|
472 |
||
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
473 |
/* |
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
474 |
* lhr_pad was previously used for the next leaf in the leaf |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
475 |
* chain. There should be no chained leafs (as we have removed |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
476 |
* support for them). |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
477 |
*/ |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
478 |
ASSERT3U(l->l_phys->l_hdr.lh_pad1, ==, 0); |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
479 |
|
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
480 |
/* |
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
481 |
* There should be more hash entries than there can be |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
482 |
* chunks to put in the hash table |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
483 |
*/ |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
484 |
ASSERT3U(ZAP_LEAF_HASH_NUMENTRIES(l), >, ZAP_LEAF_NUMCHUNKS(l) / 3); |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
485 |
|
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
486 |
/* The chunks should begin at the end of the hash table */ |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
487 |
ASSERT3P(&ZAP_LEAF_CHUNK(l, 0), ==, |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
488 |
&l->l_phys->l_hash[ZAP_LEAF_HASH_NUMENTRIES(l)]); |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
489 |
|
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
490 |
/* The chunks should end at the end of the block */ |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
491 |
ASSERT3U((uintptr_t)&ZAP_LEAF_CHUNK(l, ZAP_LEAF_NUMCHUNKS(l)) - |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
492 |
(uintptr_t)l->l_phys, ==, l->l_dbuf->db_size); |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
493 |
|
789 | 494 |
return (l); |
495 |
} |
|
496 |
||
1544 | 497 |
static int |
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
498 |
zap_get_leaf_byblk(zap_t *zap, uint64_t blkid, dmu_tx_t *tx, krw_t lt, |
1544 | 499 |
zap_leaf_t **lp) |
789 | 500 |
{ |
501 |
dmu_buf_t *db; |
|
502 |
zap_leaf_t *l; |
|
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
503 |
int bs = FZAP_BLOCK_SHIFT(zap); |
1544 | 504 |
int err; |
789 | 505 |
|
506 |
ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); |
|
507 |
||
1544 | 508 |
err = dmu_buf_hold(zap->zap_objset, zap->zap_object, |
12285
d736d62dcca2
6944833 Avoid prefetching dbufs in dmu_sync() path
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
11165
diff
changeset
|
509 |
blkid << bs, NULL, &db, DMU_READ_NO_PREFETCH); |
1544 | 510 |
if (err) |
511 |
return (err); |
|
789 | 512 |
|
513 |
ASSERT3U(db->db_object, ==, zap->zap_object); |
|
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
514 |
ASSERT3U(db->db_offset, ==, blkid << bs); |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
515 |
ASSERT3U(db->db_size, ==, 1 << bs); |
789 | 516 |
ASSERT(blkid != 0); |
517 |
||
518 |
l = dmu_buf_get_user(db); |
|
519 |
||
520 |
if (l == NULL) |
|
521 |
l = zap_open_leaf(blkid, db); |
|
522 |
||
523 |
rw_enter(&l->l_rwlock, lt); |
|
524 |
/* |
|
525 |
* Must lock before dirtying, otherwise l->l_phys could change, |
|
526 |
* causing ASSERT below to fail. |
|
527 |
*/ |
|
528 |
if (lt == RW_WRITER) |
|
529 |
dmu_buf_will_dirty(db, tx); |
|
530 |
ASSERT3U(l->l_blkid, ==, blkid); |
|
531 |
ASSERT3P(l->l_dbuf, ==, db); |
|
532 |
ASSERT3P(l->l_phys, ==, l->l_dbuf->db_data); |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
533 |
ASSERT3U(l->l_phys->l_hdr.lh_block_type, ==, ZBT_LEAF); |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
534 |
ASSERT3U(l->l_phys->l_hdr.lh_magic, ==, ZAP_LEAF_MAGIC); |
789 | 535 |
|
1544 | 536 |
*lp = l; |
537 |
return (0); |
|
789 | 538 |
} |
539 |
||
1544 | 540 |
static int |
541 |
zap_idx_to_blk(zap_t *zap, uint64_t idx, uint64_t *valp) |
|
789 | 542 |
{ |
543 |
ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); |
|
544 |
||
545 |
if (zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks == 0) { |
|
546 |
ASSERT3U(idx, <, |
|
547 |
(1ULL << zap->zap_f.zap_phys->zap_ptrtbl.zt_shift)); |
|
1544 | 548 |
*valp = ZAP_EMBEDDED_PTRTBL_ENT(zap, idx); |
549 |
return (0); |
|
789 | 550 |
} else { |
551 |
return (zap_table_load(zap, &zap->zap_f.zap_phys->zap_ptrtbl, |
|
1544 | 552 |
idx, valp)); |
789 | 553 |
} |
554 |
} |
|
555 |
||
1544 | 556 |
static int |
789 | 557 |
zap_set_idx_to_blk(zap_t *zap, uint64_t idx, uint64_t blk, dmu_tx_t *tx) |
558 |
{ |
|
559 |
ASSERT(tx != NULL); |
|
560 |
ASSERT(RW_WRITE_HELD(&zap->zap_rwlock)); |
|
561 |
||
562 |
if (zap->zap_f.zap_phys->zap_ptrtbl.zt_blk == 0) { |
|
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
563 |
ZAP_EMBEDDED_PTRTBL_ENT(zap, idx) = blk; |
1544 | 564 |
return (0); |
789 | 565 |
} else { |
1544 | 566 |
return (zap_table_store(zap, &zap->zap_f.zap_phys->zap_ptrtbl, |
567 |
idx, blk, tx)); |
|
789 | 568 |
} |
569 |
} |
|
570 |
||
1544 | 571 |
static int |
572 |
zap_deref_leaf(zap_t *zap, uint64_t h, dmu_tx_t *tx, krw_t lt, zap_leaf_t **lp) |
|
789 | 573 |
{ |
1544 | 574 |
uint64_t idx, blk; |
575 |
int err; |
|
789 | 576 |
|
577 |
ASSERT(zap->zap_dbuf == NULL || |
|
578 |
zap->zap_f.zap_phys == zap->zap_dbuf->db_data); |
|
579 |
ASSERT3U(zap->zap_f.zap_phys->zap_magic, ==, ZAP_MAGIC); |
|
580 |
idx = ZAP_HASH_IDX(h, zap->zap_f.zap_phys->zap_ptrtbl.zt_shift); |
|
1544 | 581 |
err = zap_idx_to_blk(zap, idx, &blk); |
582 |
if (err != 0) |
|
583 |
return (err); |
|
584 |
err = zap_get_leaf_byblk(zap, blk, tx, lt, lp); |
|
789 | 585 |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
586 |
ASSERT(err || ZAP_HASH_IDX(h, (*lp)->l_phys->l_hdr.lh_prefix_len) == |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
587 |
(*lp)->l_phys->l_hdr.lh_prefix); |
1544 | 588 |
return (err); |
789 | 589 |
} |
590 |
||
1544 | 591 |
static int |
5497 | 592 |
zap_expand_leaf(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx, zap_leaf_t **lp) |
789 | 593 |
{ |
5497 | 594 |
zap_t *zap = zn->zn_zap; |
595 |
uint64_t hash = zn->zn_hash; |
|
789 | 596 |
zap_leaf_t *nl; |
597 |
int prefix_diff, i, err; |
|
598 |
uint64_t sibling; |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
599 |
int old_prefix_len = l->l_phys->l_hdr.lh_prefix_len; |
789 | 600 |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
601 |
ASSERT3U(old_prefix_len, <=, zap->zap_f.zap_phys->zap_ptrtbl.zt_shift); |
789 | 602 |
ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); |
603 |
||
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
604 |
ASSERT3U(ZAP_HASH_IDX(hash, old_prefix_len), ==, |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
605 |
l->l_phys->l_hdr.lh_prefix); |
789 | 606 |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
607 |
if (zap_tryupgradedir(zap, tx) == 0 || |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
608 |
old_prefix_len == zap->zap_f.zap_phys->zap_ptrtbl.zt_shift) { |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
609 |
/* We failed to upgrade, or need to grow the pointer table */ |
789 | 610 |
objset_t *os = zap->zap_objset; |
611 |
uint64_t object = zap->zap_object; |
|
612 |
||
613 |
zap_put_leaf(l); |
|
614 |
zap_unlockdir(zap); |
|
5384
8eba72d775e9
6623831 assertion failed in dmu_tx_willuse_space() from mzap_upgrade()
ahrens
parents:
5331
diff
changeset
|
615 |
err = zap_lockdir(os, object, tx, RW_WRITER, |
5497 | 616 |
FALSE, FALSE, &zn->zn_zap); |
617 |
zap = zn->zn_zap; |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
618 |
if (err) |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
619 |
return (err); |
789 | 620 |
ASSERT(!zap->zap_ismicro); |
621 |
||
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
622 |
while (old_prefix_len == |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
623 |
zap->zap_f.zap_phys->zap_ptrtbl.zt_shift) { |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
624 |
err = zap_grow_ptrtbl(zap, tx); |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
625 |
if (err) |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
626 |
return (err); |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
627 |
} |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
628 |
|
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
629 |
err = zap_deref_leaf(zap, hash, tx, RW_WRITER, &l); |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
630 |
if (err) |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
631 |
return (err); |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
632 |
|
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
633 |
if (l->l_phys->l_hdr.lh_prefix_len != old_prefix_len) { |
789 | 634 |
/* it split while our locks were down */ |
1544 | 635 |
*lp = l; |
636 |
return (0); |
|
637 |
} |
|
789 | 638 |
} |
639 |
ASSERT(RW_WRITE_HELD(&zap->zap_rwlock)); |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
640 |
ASSERT3U(old_prefix_len, <, zap->zap_f.zap_phys->zap_ptrtbl.zt_shift); |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
641 |
ASSERT3U(ZAP_HASH_IDX(hash, old_prefix_len), ==, |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
642 |
l->l_phys->l_hdr.lh_prefix); |
789 | 643 |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
644 |
prefix_diff = zap->zap_f.zap_phys->zap_ptrtbl.zt_shift - |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
645 |
(old_prefix_len + 1); |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
646 |
sibling = (ZAP_HASH_IDX(hash, old_prefix_len + 1) | 1) << prefix_diff; |
1544 | 647 |
|
648 |
/* check for i/o errors before doing zap_leaf_split */ |
|
789 | 649 |
for (i = 0; i < (1ULL<<prefix_diff); i++) { |
1544 | 650 |
uint64_t blk; |
651 |
err = zap_idx_to_blk(zap, sibling+i, &blk); |
|
652 |
if (err) |
|
653 |
return (err); |
|
654 |
ASSERT3U(blk, ==, l->l_blkid); |
|
655 |
} |
|
656 |
||
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
657 |
nl = zap_create_leaf(zap, tx); |
5498
334b476844ca
6622831 normalization properties are not preserved by "zfs send"
timh
parents:
5497
diff
changeset
|
658 |
zap_leaf_split(l, nl, zap->zap_normflags != 0); |
1544 | 659 |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
660 |
/* set sibling pointers */ |
1544 | 661 |
for (i = 0; i < (1ULL<<prefix_diff); i++) { |
662 |
err = zap_set_idx_to_blk(zap, sibling+i, nl->l_blkid, tx); |
|
663 |
ASSERT3U(err, ==, 0); /* we checked for i/o errors above */ |
|
789 | 664 |
} |
665 |
||
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
666 |
if (hash & (1ULL << (64 - l->l_phys->l_hdr.lh_prefix_len))) { |
789 | 667 |
/* we want the sibling */ |
668 |
zap_put_leaf(l); |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
669 |
*lp = nl; |
789 | 670 |
} else { |
671 |
zap_put_leaf(nl); |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
672 |
*lp = l; |
789 | 673 |
} |
674 |
||
1544 | 675 |
return (0); |
789 | 676 |
} |
677 |
||
678 |
static void |
|
5497 | 679 |
zap_put_leaf_maybe_grow_ptrtbl(zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx) |
789 | 680 |
{ |
5497 | 681 |
zap_t *zap = zn->zn_zap; |
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
682 |
int shift = zap->zap_f.zap_phys->zap_ptrtbl.zt_shift; |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
683 |
int leaffull = (l->l_phys->l_hdr.lh_prefix_len == shift && |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
684 |
l->l_phys->l_hdr.lh_nfree < ZAP_LEAF_LOW_WATER); |
789 | 685 |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
686 |
zap_put_leaf(l); |
789 | 687 |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
688 |
if (leaffull || zap->zap_f.zap_phys->zap_ptrtbl.zt_nextblk) { |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
689 |
int err; |
789 | 690 |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
691 |
/* |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
692 |
* We are in the middle of growing the pointer table, or |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
693 |
* this leaf will soon make us grow it. |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
694 |
*/ |
789 | 695 |
if (zap_tryupgradedir(zap, tx) == 0) { |
696 |
objset_t *os = zap->zap_objset; |
|
697 |
uint64_t zapobj = zap->zap_object; |
|
698 |
||
699 |
zap_unlockdir(zap); |
|
700 |
err = zap_lockdir(os, zapobj, tx, |
|
5497 | 701 |
RW_WRITER, FALSE, FALSE, &zn->zn_zap); |
702 |
zap = zn->zn_zap; |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
703 |
if (err) |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
704 |
return; |
789 | 705 |
} |
706 |
||
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
707 |
/* could have finished growing while our locks were down */ |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
708 |
if (zap->zap_f.zap_phys->zap_ptrtbl.zt_shift == shift) |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
709 |
(void) zap_grow_ptrtbl(zap, tx); |
789 | 710 |
} |
711 |
} |
|
712 |
||
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
713 |
static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
714 |
fzap_checkname(zap_name_t *zn) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
715 |
{ |
11165
68184eb5449e
6903705 dedup=fletcher4,verify doesn't byteswap correctly, has lots of hash collisions
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
716 |
if (zn->zn_key_orig_numints * zn->zn_key_intlen > ZAP_MAXNAMELEN) |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
717 |
return (ENAMETOOLONG); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
718 |
return (0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
719 |
} |
789 | 720 |
|
721 |
static int |
|
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
722 |
fzap_checksize(uint64_t integer_size, uint64_t num_integers) |
789 | 723 |
{ |
724 |
/* Only integer sizes supported by C */ |
|
725 |
switch (integer_size) { |
|
726 |
case 1: |
|
727 |
case 2: |
|
728 |
case 4: |
|
729 |
case 8: |
|
730 |
break; |
|
731 |
default: |
|
732 |
return (EINVAL); |
|
733 |
} |
|
734 |
||
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
735 |
if (integer_size * num_integers > ZAP_MAXVALUELEN) |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
736 |
return (E2BIG); |
789 | 737 |
|
738 |
return (0); |
|
739 |
} |
|
740 |
||
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
741 |
static int |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
742 |
fzap_check(zap_name_t *zn, uint64_t integer_size, uint64_t num_integers) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
743 |
{ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
744 |
int err; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
745 |
|
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
746 |
if ((err = fzap_checkname(zn)) != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
747 |
return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
748 |
return (fzap_checksize(integer_size, num_integers)); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
749 |
} |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
750 |
|
789 | 751 |
/* |
5331 | 752 |
* Routines for manipulating attributes. |
789 | 753 |
*/ |
754 |
int |
|
5331 | 755 |
fzap_lookup(zap_name_t *zn, |
756 |
uint64_t integer_size, uint64_t num_integers, void *buf, |
|
757 |
char *realname, int rn_len, boolean_t *ncp) |
|
789 | 758 |
{ |
759 |
zap_leaf_t *l; |
|
760 |
int err; |
|
761 |
zap_entry_handle_t zeh; |
|
762 |
||
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
763 |
if ((err = fzap_checkname(zn)) != 0) |
789 | 764 |
return (err); |
765 |
||
5331 | 766 |
err = zap_deref_leaf(zn->zn_zap, zn->zn_hash, NULL, RW_READER, &l); |
1544 | 767 |
if (err != 0) |
768 |
return (err); |
|
5331 | 769 |
err = zap_leaf_lookup(l, zn, &zeh); |
770 |
if (err == 0) { |
|
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
771 |
if ((err = fzap_checksize(integer_size, num_integers)) != 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
772 |
zap_put_leaf(l); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
773 |
return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
774 |
} |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
775 |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
776 |
err = zap_entry_read(&zeh, integer_size, num_integers, buf); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10612
diff
changeset
|
777 |
(void) zap_entry_read_name(zn->zn_zap, &zeh, rn_len, realname); |
5331 | 778 |
if (ncp) { |
779 |
*ncp = zap_entry_normalization_conflict(&zeh, |
|
780 |
zn, NULL, zn->zn_zap); |
|
781 |
} |
|
782 |
} |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
783 |
|
789 | 784 |
zap_put_leaf(l); |
785 |
return (err); |
|
786 |
} |
|
787 |
||
788 |
int |
|
5331 | 789 |
fzap_add_cd(zap_name_t *zn, |
789 | 790 |
uint64_t integer_size, uint64_t num_integers, |
1544 | 791 |
const void *val, uint32_t cd, dmu_tx_t *tx) |
789 | 792 |
{ |
793 |
zap_leaf_t *l; |
|
794 |
int err; |
|
795 |
zap_entry_handle_t zeh; |
|
5331 | 796 |
zap_t *zap = zn->zn_zap; |
789 | 797 |
|
798 |
ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); |
|
799 |
ASSERT(!zap->zap_ismicro); |
|
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
800 |
ASSERT(fzap_check(zn, integer_size, num_integers) == 0); |
789 | 801 |
|
5331 | 802 |
err = zap_deref_leaf(zap, zn->zn_hash, tx, RW_WRITER, &l); |
1544 | 803 |
if (err != 0) |
804 |
return (err); |
|
789 | 805 |
retry: |
5331 | 806 |
err = zap_leaf_lookup(l, zn, &zeh); |
789 | 807 |
if (err == 0) { |
808 |
err = EEXIST; |
|
809 |
goto out; |
|
810 |
} |
|
1544 | 811 |
if (err != ENOENT) |
812 |
goto out; |
|
789 | 813 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10612
diff
changeset
|
814 |
err = zap_entry_create(l, zn, cd, |
789 | 815 |
integer_size, num_integers, val, &zeh); |
816 |
||
817 |
if (err == 0) { |
|
818 |
zap_increment_num_entries(zap, 1, tx); |
|
819 |
} else if (err == EAGAIN) { |
|
5497 | 820 |
err = zap_expand_leaf(zn, l, tx, &l); |
821 |
zap = zn->zn_zap; /* zap_expand_leaf() may change zap */ |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
822 |
if (err == 0) |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
823 |
goto retry; |
789 | 824 |
} |
825 |
||
826 |
out: |
|
5497 | 827 |
if (zap != NULL) |
828 |
zap_put_leaf_maybe_grow_ptrtbl(zn, l, tx); |
|
789 | 829 |
return (err); |
830 |
} |
|
831 |
||
832 |
int |
|
5331 | 833 |
fzap_add(zap_name_t *zn, |
789 | 834 |
uint64_t integer_size, uint64_t num_integers, |
835 |
const void *val, dmu_tx_t *tx) |
|
836 |
{ |
|
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
837 |
int err = fzap_check(zn, integer_size, num_integers); |
789 | 838 |
if (err != 0) |
839 |
return (err); |
|
840 |
||
5331 | 841 |
return (fzap_add_cd(zn, integer_size, num_integers, |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10612
diff
changeset
|
842 |
val, ZAP_NEED_CD, tx)); |
789 | 843 |
} |
844 |
||
845 |
int |
|
5331 | 846 |
fzap_update(zap_name_t *zn, |
789 | 847 |
int integer_size, uint64_t num_integers, const void *val, dmu_tx_t *tx) |
848 |
{ |
|
849 |
zap_leaf_t *l; |
|
850 |
int err, create; |
|
851 |
zap_entry_handle_t zeh; |
|
5331 | 852 |
zap_t *zap = zn->zn_zap; |
789 | 853 |
|
854 |
ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); |
|
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
855 |
err = fzap_check(zn, integer_size, num_integers); |
789 | 856 |
if (err != 0) |
857 |
return (err); |
|
858 |
||
5331 | 859 |
err = zap_deref_leaf(zap, zn->zn_hash, tx, RW_WRITER, &l); |
1544 | 860 |
if (err != 0) |
861 |
return (err); |
|
789 | 862 |
retry: |
5331 | 863 |
err = zap_leaf_lookup(l, zn, &zeh); |
789 | 864 |
create = (err == ENOENT); |
865 |
ASSERT(err == 0 || err == ENOENT); |
|
866 |
||
867 |
if (create) { |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10612
diff
changeset
|
868 |
err = zap_entry_create(l, zn, ZAP_NEED_CD, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10612
diff
changeset
|
869 |
integer_size, num_integers, val, &zeh); |
789 | 870 |
if (err == 0) |
871 |
zap_increment_num_entries(zap, 1, tx); |
|
872 |
} else { |
|
873 |
err = zap_entry_update(&zeh, integer_size, num_integers, val); |
|
874 |
} |
|
875 |
||
876 |
if (err == EAGAIN) { |
|
5497 | 877 |
err = zap_expand_leaf(zn, l, tx, &l); |
878 |
zap = zn->zn_zap; /* zap_expand_leaf() may change zap */ |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
879 |
if (err == 0) |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
880 |
goto retry; |
789 | 881 |
} |
882 |
||
5497 | 883 |
if (zap != NULL) |
884 |
zap_put_leaf_maybe_grow_ptrtbl(zn, l, tx); |
|
789 | 885 |
return (err); |
886 |
} |
|
887 |
||
888 |
int |
|
5331 | 889 |
fzap_length(zap_name_t *zn, |
789 | 890 |
uint64_t *integer_size, uint64_t *num_integers) |
891 |
{ |
|
892 |
zap_leaf_t *l; |
|
893 |
int err; |
|
894 |
zap_entry_handle_t zeh; |
|
895 |
||
5331 | 896 |
err = zap_deref_leaf(zn->zn_zap, zn->zn_hash, NULL, RW_READER, &l); |
1544 | 897 |
if (err != 0) |
898 |
return (err); |
|
5331 | 899 |
err = zap_leaf_lookup(l, zn, &zeh); |
789 | 900 |
if (err != 0) |
901 |
goto out; |
|
902 |
||
903 |
if (integer_size) |
|
904 |
*integer_size = zeh.zeh_integer_size; |
|
905 |
if (num_integers) |
|
906 |
*num_integers = zeh.zeh_num_integers; |
|
907 |
out: |
|
908 |
zap_put_leaf(l); |
|
909 |
return (err); |
|
910 |
} |
|
911 |
||
912 |
int |
|
5331 | 913 |
fzap_remove(zap_name_t *zn, dmu_tx_t *tx) |
789 | 914 |
{ |
915 |
zap_leaf_t *l; |
|
916 |
int err; |
|
917 |
zap_entry_handle_t zeh; |
|
918 |
||
5331 | 919 |
err = zap_deref_leaf(zn->zn_zap, zn->zn_hash, tx, RW_WRITER, &l); |
1544 | 920 |
if (err != 0) |
921 |
return (err); |
|
5331 | 922 |
err = zap_leaf_lookup(l, zn, &zeh); |
789 | 923 |
if (err == 0) { |
924 |
zap_entry_remove(&zeh); |
|
5331 | 925 |
zap_increment_num_entries(zn->zn_zap, -1, tx); |
789 | 926 |
} |
927 |
zap_put_leaf(l); |
|
928 |
return (err); |
|
929 |
} |
|
930 |
||
12450
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
931 |
void |
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
932 |
fzap_prefetch(zap_name_t *zn) |
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
933 |
{ |
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
934 |
uint64_t idx, blk; |
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
935 |
zap_t *zap = zn->zn_zap; |
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
936 |
int bs; |
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
937 |
|
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
938 |
idx = ZAP_HASH_IDX(zn->zn_hash, |
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
939 |
zap->zap_f.zap_phys->zap_ptrtbl.zt_shift); |
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
940 |
if (zap_idx_to_blk(zap, idx, &blk) != 0) |
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
941 |
return; |
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
942 |
bs = FZAP_BLOCK_SHIFT(zap); |
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
943 |
dmu_prefetch(zap->zap_objset, zap->zap_object, blk << bs, 1 << bs); |
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
944 |
} |
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
945 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
946 |
/* |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
947 |
* Helper functions for consumers. |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
948 |
*/ |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
949 |
|
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12450
diff
changeset
|
950 |
uint64_t |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12450
diff
changeset
|
951 |
zap_create_link(objset_t *os, dmu_object_type_t ot, uint64_t parent_obj, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12450
diff
changeset
|
952 |
const char *name, dmu_tx_t *tx) |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12450
diff
changeset
|
953 |
{ |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12450
diff
changeset
|
954 |
uint64_t new_obj; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12450
diff
changeset
|
955 |
|
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12450
diff
changeset
|
956 |
VERIFY((new_obj = zap_create(os, ot, DMU_OT_NONE, 0, tx)) > 0); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12450
diff
changeset
|
957 |
VERIFY(zap_add(os, parent_obj, name, sizeof (uint64_t), 1, &new_obj, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12450
diff
changeset
|
958 |
tx) == 0); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12450
diff
changeset
|
959 |
|
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12450
diff
changeset
|
960 |
return (new_obj); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12450
diff
changeset
|
961 |
} |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12450
diff
changeset
|
962 |
|
789 | 963 |
int |
4577 | 964 |
zap_value_search(objset_t *os, uint64_t zapobj, uint64_t value, uint64_t mask, |
965 |
char *name) |
|
789 | 966 |
{ |
967 |
zap_cursor_t zc; |
|
968 |
zap_attribute_t *za; |
|
969 |
int err; |
|
970 |
||
4577 | 971 |
if (mask == 0) |
972 |
mask = -1ULL; |
|
973 |
||
789 | 974 |
za = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP); |
975 |
for (zap_cursor_init(&zc, os, zapobj); |
|
976 |
(err = zap_cursor_retrieve(&zc, za)) == 0; |
|
977 |
zap_cursor_advance(&zc)) { |
|
4577 | 978 |
if ((za->za_first_integer & mask) == (value & mask)) { |
789 | 979 |
(void) strcpy(name, za->za_name); |
980 |
break; |
|
981 |
} |
|
982 |
} |
|
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
983 |
zap_cursor_fini(&zc); |
789 | 984 |
kmem_free(za, sizeof (zap_attribute_t)); |
985 |
return (err); |
|
986 |
} |
|
987 |
||
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
988 |
int |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
989 |
zap_join(objset_t *os, uint64_t fromobj, uint64_t intoobj, dmu_tx_t *tx) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
990 |
{ |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
991 |
zap_cursor_t zc; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
992 |
zap_attribute_t za; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
993 |
int err; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
994 |
|
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
995 |
for (zap_cursor_init(&zc, os, fromobj); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
996 |
zap_cursor_retrieve(&zc, &za) == 0; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
997 |
(void) zap_cursor_advance(&zc)) { |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
998 |
if (za.za_integer_length != 8 || za.za_num_integers != 1) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
999 |
return (EINVAL); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1000 |
err = zap_add(os, intoobj, za.za_name, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1001 |
8, 1, &za.za_first_integer, tx); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1002 |
if (err) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1003 |
return (err); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1004 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1005 |
zap_cursor_fini(&zc); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1006 |
return (0); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1007 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1008 |
|
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1009 |
int |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1010 |
zap_join_key(objset_t *os, uint64_t fromobj, uint64_t intoobj, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1011 |
uint64_t value, dmu_tx_t *tx) |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1012 |
{ |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1013 |
zap_cursor_t zc; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1014 |
zap_attribute_t za; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1015 |
int err; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1016 |
|
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1017 |
for (zap_cursor_init(&zc, os, fromobj); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1018 |
zap_cursor_retrieve(&zc, &za) == 0; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1019 |
(void) zap_cursor_advance(&zc)) { |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1020 |
if (za.za_integer_length != 8 || za.za_num_integers != 1) |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1021 |
return (EINVAL); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1022 |
err = zap_add(os, intoobj, za.za_name, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1023 |
8, 1, &value, tx); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1024 |
if (err) |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1025 |
return (err); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1026 |
} |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1027 |
zap_cursor_fini(&zc); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1028 |
return (0); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1029 |
} |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1030 |
|
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1031 |
int |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1032 |
zap_join_increment(objset_t *os, uint64_t fromobj, uint64_t intoobj, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1033 |
dmu_tx_t *tx) |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1034 |
{ |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1035 |
zap_cursor_t zc; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1036 |
zap_attribute_t za; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1037 |
int err; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1038 |
|
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1039 |
for (zap_cursor_init(&zc, os, fromobj); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1040 |
zap_cursor_retrieve(&zc, &za) == 0; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1041 |
(void) zap_cursor_advance(&zc)) { |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1042 |
uint64_t delta = 0; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1043 |
|
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1044 |
if (za.za_integer_length != 8 || za.za_num_integers != 1) |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1045 |
return (EINVAL); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1046 |
|
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1047 |
err = zap_lookup(os, intoobj, za.za_name, 8, 1, &delta); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1048 |
if (err != 0 && err != ENOENT) |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1049 |
return (err); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1050 |
delta += za.za_first_integer; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1051 |
err = zap_update(os, intoobj, za.za_name, 8, 1, &delta, tx); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1052 |
if (err) |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1053 |
return (err); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1054 |
} |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1055 |
zap_cursor_fini(&zc); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1056 |
return (0); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1057 |
} |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1058 |
|
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1059 |
int |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1060 |
zap_add_int(objset_t *os, uint64_t obj, uint64_t value, dmu_tx_t *tx) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1061 |
{ |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1062 |
char name[20]; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1063 |
|
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1064 |
(void) snprintf(name, sizeof (name), "%llx", (longlong_t)value); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1065 |
return (zap_add(os, obj, name, 8, 1, &value, tx)); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1066 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1067 |
|
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1068 |
int |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1069 |
zap_remove_int(objset_t *os, uint64_t obj, uint64_t value, dmu_tx_t *tx) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1070 |
{ |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1071 |
char name[20]; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1072 |
|
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1073 |
(void) snprintf(name, sizeof (name), "%llx", (longlong_t)value); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1074 |
return (zap_remove(os, obj, name, tx)); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1075 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1076 |
|
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1077 |
int |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1078 |
zap_lookup_int(objset_t *os, uint64_t obj, uint64_t value) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1079 |
{ |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1080 |
char name[20]; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1081 |
|
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1082 |
(void) snprintf(name, sizeof (name), "%llx", (longlong_t)value); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1083 |
return (zap_lookup(os, obj, name, 8, 1, &value)); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
5498
diff
changeset
|
1084 |
} |
789 | 1085 |
|
10407
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1086 |
int |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1087 |
zap_add_int_key(objset_t *os, uint64_t obj, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1088 |
uint64_t key, uint64_t value, dmu_tx_t *tx) |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1089 |
{ |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1090 |
char name[20]; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1091 |
|
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1092 |
(void) snprintf(name, sizeof (name), "%llx", (longlong_t)key); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1093 |
return (zap_add(os, obj, name, 8, 1, &value, tx)); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1094 |
} |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1095 |
|
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1096 |
int |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1097 |
zap_lookup_int_key(objset_t *os, uint64_t obj, uint64_t key, uint64_t *valuep) |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1098 |
{ |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1099 |
char name[20]; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1100 |
|
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1101 |
(void) snprintf(name, sizeof (name), "%llx", (longlong_t)key); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1102 |
return (zap_lookup(os, obj, name, 8, 1, valuep)); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1103 |
} |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1104 |
|
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1105 |
int |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1106 |
zap_increment(objset_t *os, uint64_t obj, const char *name, int64_t delta, |
10407
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1107 |
dmu_tx_t *tx) |
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1108 |
{ |
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1109 |
uint64_t value = 0; |
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1110 |
int err; |
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1111 |
|
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1112 |
if (delta == 0) |
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1113 |
return (0); |
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1114 |
|
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1115 |
err = zap_lookup(os, obj, name, 8, 1, &value); |
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1116 |
if (err != 0 && err != ENOENT) |
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1117 |
return (err); |
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1118 |
value += delta; |
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1119 |
if (value == 0) |
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1120 |
err = zap_remove(os, obj, name, tx); |
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1121 |
else |
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1122 |
err = zap_update(os, obj, name, 8, 1, &value, tx); |
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1123 |
return (err); |
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1124 |
} |
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1125 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1126 |
int |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1127 |
zap_increment_int(objset_t *os, uint64_t obj, uint64_t key, int64_t delta, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1128 |
dmu_tx_t *tx) |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1129 |
{ |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1130 |
char name[20]; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1131 |
|
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1132 |
(void) snprintf(name, sizeof (name), "%llx", (longlong_t)key); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1133 |
return (zap_increment(os, obj, name, delta, tx)); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12285
diff
changeset
|
1134 |
} |
10407
34e10c4af053
6875779 zfs user accounting callbacks can be simplified
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9653
diff
changeset
|
1135 |
|
789 | 1136 |
/* |
1137 |
* Routines for iterating over the attributes. |
|
1138 |
*/ |
|
1139 |
||
1140 |
int |
|
1141 |
fzap_cursor_retrieve(zap_t *zap, zap_cursor_t *zc, zap_attribute_t *za) |
|
1142 |
{ |
|
1143 |
int err = ENOENT; |
|
1144 |
zap_entry_handle_t zeh; |
|
1145 |
zap_leaf_t *l; |
|
1146 |
||
1147 |
/* retrieve the next entry at or after zc_hash/zc_cd */ |
|
1148 |
/* if no entry, return ENOENT */ |
|
1149 |
||
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1150 |
if (zc->zc_leaf && |
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
1151 |
(ZAP_HASH_IDX(zc->zc_hash, |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
1152 |
zc->zc_leaf->l_phys->l_hdr.lh_prefix_len) != |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
1153 |
zc->zc_leaf->l_phys->l_hdr.lh_prefix)) { |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1154 |
rw_enter(&zc->zc_leaf->l_rwlock, RW_READER); |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1155 |
zap_put_leaf(zc->zc_leaf); |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1156 |
zc->zc_leaf = NULL; |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1157 |
} |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1158 |
|
789 | 1159 |
again: |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1160 |
if (zc->zc_leaf == NULL) { |
1544 | 1161 |
err = zap_deref_leaf(zap, zc->zc_hash, NULL, RW_READER, |
1162 |
&zc->zc_leaf); |
|
1163 |
if (err != 0) |
|
1164 |
return (err); |
|
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1165 |
} else { |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1166 |
rw_enter(&zc->zc_leaf->l_rwlock, RW_READER); |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1167 |
} |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1168 |
l = zc->zc_leaf; |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1169 |
|
789 | 1170 |
err = zap_leaf_lookup_closest(l, zc->zc_hash, zc->zc_cd, &zeh); |
1171 |
||
1172 |
if (err == ENOENT) { |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
1173 |
uint64_t nocare = |
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
1174 |
(1ULL << (64 - l->l_phys->l_hdr.lh_prefix_len)) - 1; |
789 | 1175 |
zc->zc_hash = (zc->zc_hash & ~nocare) + nocare + 1; |
1176 |
zc->zc_cd = 0; |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
1177 |
if (l->l_phys->l_hdr.lh_prefix_len == 0 || zc->zc_hash == 0) { |
789 | 1178 |
zc->zc_hash = -1ULL; |
1179 |
} else { |
|
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1180 |
zap_put_leaf(zc->zc_leaf); |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1181 |
zc->zc_leaf = NULL; |
789 | 1182 |
goto again; |
1183 |
} |
|
1184 |
} |
|
1185 |
||
1186 |
if (err == 0) { |
|
1187 |
zc->zc_hash = zeh.zeh_hash; |
|
1188 |
zc->zc_cd = zeh.zeh_cd; |
|
1189 |
za->za_integer_length = zeh.zeh_integer_size; |
|
1190 |
za->za_num_integers = zeh.zeh_num_integers; |
|
1191 |
if (zeh.zeh_num_integers == 0) { |
|
1192 |
za->za_first_integer = 0; |
|
1193 |
} else { |
|
1194 |
err = zap_entry_read(&zeh, 8, 1, &za->za_first_integer); |
|
1195 |
ASSERT(err == 0 || err == EOVERFLOW); |
|
1196 |
} |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10612
diff
changeset
|
1197 |
err = zap_entry_read_name(zap, &zeh, |
789 | 1198 |
sizeof (za->za_name), za->za_name); |
1199 |
ASSERT(err == 0); |
|
5331 | 1200 |
|
1201 |
za->za_normalization_conflict = |
|
1202 |
zap_entry_normalization_conflict(&zeh, |
|
1203 |
NULL, za->za_name, zap); |
|
789 | 1204 |
} |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1205 |
rw_exit(&zc->zc_leaf->l_rwlock); |
789 | 1206 |
return (err); |
1207 |
} |
|
1208 |
||
1209 |
static void |
|
1210 |
zap_stats_ptrtbl(zap_t *zap, uint64_t *tbl, int len, zap_stats_t *zs) |
|
1211 |
{ |
|
1544 | 1212 |
int i, err; |
789 | 1213 |
uint64_t lastblk = 0; |
1214 |
||
1215 |
/* |
|
1216 |
* NB: if a leaf has more pointers than an entire ptrtbl block |
|
1217 |
* can hold, then it'll be accounted for more than once, since |
|
1218 |
* we won't have lastblk. |
|
1219 |
*/ |
|
1220 |
for (i = 0; i < len; i++) { |
|
1221 |
zap_leaf_t *l; |
|
1222 |
||
1223 |
if (tbl[i] == lastblk) |
|
1224 |
continue; |
|
1225 |
lastblk = tbl[i]; |
|
1226 |
||
1544 | 1227 |
err = zap_get_leaf_byblk(zap, tbl[i], NULL, RW_READER, &l); |
1228 |
if (err == 0) { |
|
1578
1fd8ab638fc0
6389897 remove zap leaf chaining code as it is never used
ahrens
parents:
1544
diff
changeset
|
1229 |
zap_leaf_stats(zap, l, zs); |
1544 | 1230 |
zap_put_leaf(l); |
1231 |
} |
|
789 | 1232 |
} |
1233 |
} |
|
1234 |
||
10612
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1235 |
int |
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1236 |
fzap_cursor_move_to_key(zap_cursor_t *zc, zap_name_t *zn) |
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1237 |
{ |
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1238 |
int err; |
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1239 |
zap_leaf_t *l; |
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1240 |
zap_entry_handle_t zeh; |
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1241 |
|
11165
68184eb5449e
6903705 dedup=fletcher4,verify doesn't byteswap correctly, has lots of hash collisions
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
1242 |
if (zn->zn_key_orig_numints * zn->zn_key_intlen > ZAP_MAXNAMELEN) |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10922
diff
changeset
|
1243 |
return (ENAMETOOLONG); |
10612
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1244 |
|
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1245 |
err = zap_deref_leaf(zc->zc_zap, zn->zn_hash, NULL, RW_READER, &l); |
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1246 |
if (err != 0) |
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1247 |
return (err); |
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1248 |
|
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1249 |
err = zap_leaf_lookup(l, zn, &zeh); |
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1250 |
if (err != 0) |
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1251 |
return (err); |
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1252 |
|
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1253 |
zc->zc_leaf = l; |
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1254 |
zc->zc_hash = zeh.zeh_hash; |
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1255 |
zc->zc_cd = zeh.zeh_cd; |
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1256 |
|
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1257 |
return (err); |
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1258 |
} |
89423355fa6f
6650218 Commit callbacks API for the DMU
Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
parents:
10431
diff
changeset
|
1259 |
|
789 | 1260 |
void |
1261 |
fzap_get_stats(zap_t *zap, zap_stats_t *zs) |
|
1262 |
{ |
|
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
1263 |
int bs = FZAP_BLOCK_SHIFT(zap); |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
1264 |
zs->zs_blocksize = 1ULL << bs; |
1632
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1265 |
|
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1266 |
/* |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1267 |
* Set zap_phys_t fields |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1268 |
*/ |
789 | 1269 |
zs->zs_num_leafs = zap->zap_f.zap_phys->zap_num_leafs; |
1270 |
zs->zs_num_entries = zap->zap_f.zap_phys->zap_num_entries; |
|
1271 |
zs->zs_num_blocks = zap->zap_f.zap_phys->zap_freeblk; |
|
1632
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1272 |
zs->zs_block_type = zap->zap_f.zap_phys->zap_block_type; |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1273 |
zs->zs_magic = zap->zap_f.zap_phys->zap_magic; |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1274 |
zs->zs_salt = zap->zap_f.zap_phys->zap_salt; |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1275 |
|
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1276 |
/* |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1277 |
* Set zap_ptrtbl fields |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1278 |
*/ |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1279 |
zs->zs_ptrtbl_len = 1ULL << zap->zap_f.zap_phys->zap_ptrtbl.zt_shift; |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1280 |
zs->zs_ptrtbl_nextblk = zap->zap_f.zap_phys->zap_ptrtbl.zt_nextblk; |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1281 |
zs->zs_ptrtbl_blks_copied = |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1282 |
zap->zap_f.zap_phys->zap_ptrtbl.zt_blks_copied; |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1283 |
zs->zs_ptrtbl_zt_blk = zap->zap_f.zap_phys->zap_ptrtbl.zt_blk; |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1284 |
zs->zs_ptrtbl_zt_numblks = zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks; |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
1285 |
zs->zs_ptrtbl_zt_shift = zap->zap_f.zap_phys->zap_ptrtbl.zt_shift; |
789 | 1286 |
|
1287 |
if (zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks == 0) { |
|
1288 |
/* the ptrtbl is entirely in the header block. */ |
|
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
1289 |
zap_stats_ptrtbl(zap, &ZAP_EMBEDDED_PTRTBL_ENT(zap, 0), |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
1290 |
1 << ZAP_EMBEDDED_PTRTBL_SHIFT(zap), zs); |
789 | 1291 |
} else { |
1292 |
int b; |
|
1293 |
||
1294 |
dmu_prefetch(zap->zap_objset, zap->zap_object, |
|
1491
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
1295 |
zap->zap_f.zap_phys->zap_ptrtbl.zt_blk << bs, |
bdcb30e07e7d
6389368 fat zap should use 16k blocks (with backwards compatability)
ahrens
parents:
885
diff
changeset
|
1296 |
zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks << bs); |
789 | 1297 |
|
1298 |
for (b = 0; b < zap->zap_f.zap_phys->zap_ptrtbl.zt_numblks; |
|
1299 |
b++) { |
|
1300 |
dmu_buf_t *db; |
|
1544 | 1301 |
int err; |
789 | 1302 |
|
1544 | 1303 |
err = dmu_buf_hold(zap->zap_objset, zap->zap_object, |
1304 |
(zap->zap_f.zap_phys->zap_ptrtbl.zt_blk + b) << bs, |
|
12285
d736d62dcca2
6944833 Avoid prefetching dbufs in dmu_sync() path
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
11165
diff
changeset
|
1305 |
FTAG, &db, DMU_READ_NO_PREFETCH); |
1544 | 1306 |
if (err == 0) { |
1307 |
zap_stats_ptrtbl(zap, db->db_data, |
|
1308 |
1<<(bs-3), zs); |
|
1309 |
dmu_buf_rele(db, FTAG); |
|
1310 |
} |
|
789 | 1311 |
} |
1312 |
} |
|
1313 |
} |
|
9653
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1314 |
|
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1315 |
int |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1316 |
fzap_count_write(zap_name_t *zn, int add, uint64_t *towrite, |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1317 |
uint64_t *tooverwrite) |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1318 |
{ |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1319 |
zap_t *zap = zn->zn_zap; |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1320 |
zap_leaf_t *l; |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1321 |
int err; |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1322 |
|
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1323 |
/* |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1324 |
* Account for the header block of the fatzap. |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1325 |
*/ |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1326 |
if (!add && dmu_buf_freeable(zap->zap_dbuf)) { |
10431
a4572ce3df84
6870347 assertion failure in dmu_tx_willuse_space(): refcount_count(&tx->tx_space_written) + delta <= tx->tx
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
10407
diff
changeset
|
1327 |
*tooverwrite += zap->zap_dbuf->db_size; |
9653
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1328 |
} else { |
10431
a4572ce3df84
6870347 assertion failure in dmu_tx_willuse_space(): refcount_count(&tx->tx_space_written) + delta <= tx->tx
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
10407
diff
changeset
|
1329 |
*towrite += zap->zap_dbuf->db_size; |
9653
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1330 |
} |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1331 |
|
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1332 |
/* |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1333 |
* Account for the pointer table blocks. |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1334 |
* If we are adding we need to account for the following cases : |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1335 |
* - If the pointer table is embedded, this operation could force an |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1336 |
* external pointer table. |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1337 |
* - If this already has an external pointer table this operation |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1338 |
* could extend the table. |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1339 |
*/ |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1340 |
if (add) { |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1341 |
if (zap->zap_f.zap_phys->zap_ptrtbl.zt_blk == 0) |
10431
a4572ce3df84
6870347 assertion failure in dmu_tx_willuse_space(): refcount_count(&tx->tx_space_written) + delta <= tx->tx
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
10407
diff
changeset
|
1342 |
*towrite += zap->zap_dbuf->db_size; |
9653
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1343 |
else |
10431
a4572ce3df84
6870347 assertion failure in dmu_tx_willuse_space(): refcount_count(&tx->tx_space_written) + delta <= tx->tx
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
10407
diff
changeset
|
1344 |
*towrite += (zap->zap_dbuf->db_size * 3); |
9653
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1345 |
} |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1346 |
|
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1347 |
/* |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1348 |
* Now, check if the block containing leaf is freeable |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1349 |
* and account accordingly. |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1350 |
*/ |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1351 |
err = zap_deref_leaf(zap, zn->zn_hash, NULL, RW_READER, &l); |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1352 |
if (err != 0) { |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1353 |
return (err); |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1354 |
} |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1355 |
|
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1356 |
if (!add && dmu_buf_freeable(l->l_dbuf)) { |
10431
a4572ce3df84
6870347 assertion failure in dmu_tx_willuse_space(): refcount_count(&tx->tx_space_written) + delta <= tx->tx
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
10407
diff
changeset
|
1357 |
*tooverwrite += l->l_dbuf->db_size; |
9653
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1358 |
} else { |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1359 |
/* |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1360 |
* If this an add operation, the leaf block could split. |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1361 |
* Hence, we need to account for an additional leaf block. |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1362 |
*/ |
10431
a4572ce3df84
6870347 assertion failure in dmu_tx_willuse_space(): refcount_count(&tx->tx_space_written) + delta <= tx->tx
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
10407
diff
changeset
|
1363 |
*towrite += (add ? 2 : 1) * l->l_dbuf->db_size; |
9653
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1364 |
} |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1365 |
|
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1366 |
zap_put_leaf(l); |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1367 |
return (0); |
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9643
diff
changeset
|
1368 |
} |