author | ahrens |
Fri, 01 Aug 2008 16:32:18 -0700 | |
changeset 7265 | cc18862247da |
parent 7237 | f47d41541b14 |
child 7312 | 3992f9a413c2 |
permissions | -rw-r--r-- |
789 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
1544 | 5 |
* Common Development and Distribution License (the "License"). |
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 |
/* |
|
5831
48655d6b290b
6630761 In sub-filesystem, available space is less than refreservation space
ck153898
parents:
5712
diff
changeset
|
22 |
* Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
789 | 23 |
* Use is subject to license terms. |
24 |
*/ |
|
25 |
||
26 |
#pragma ident "%Z%%M% %I% %E% SMI" |
|
27 |
||
28 |
#include <sys/dmu_objset.h> |
|
29 |
#include <sys/dsl_dataset.h> |
|
30 |
#include <sys/dsl_dir.h> |
|
2082 | 31 |
#include <sys/dsl_prop.h> |
2199 | 32 |
#include <sys/dsl_synctask.h> |
789 | 33 |
#include <sys/dmu_traverse.h> |
34 |
#include <sys/dmu_tx.h> |
|
35 |
#include <sys/arc.h> |
|
36 |
#include <sys/zio.h> |
|
37 |
#include <sys/zap.h> |
|
38 |
#include <sys/unique.h> |
|
39 |
#include <sys/zfs_context.h> |
|
4007 | 40 |
#include <sys/zfs_ioctl.h> |
4543 | 41 |
#include <sys/spa.h> |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
42 |
#include <sys/zfs_znode.h> |
4543 | 43 |
#include <sys/sunddi.h> |
789 | 44 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
45 |
static char *dsl_reaper = "the grim reaper"; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
46 |
|
2199 | 47 |
static dsl_checkfunc_t dsl_dataset_destroy_begin_check; |
48 |
static dsl_syncfunc_t dsl_dataset_destroy_begin_sync; |
|
49 |
static dsl_checkfunc_t dsl_dataset_rollback_check; |
|
50 |
static dsl_syncfunc_t dsl_dataset_rollback_sync; |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
51 |
static dsl_syncfunc_t dsl_dataset_set_reservation_sync; |
1731
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
52 |
|
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3025
diff
changeset
|
53 |
#define DS_REF_MAX (1ULL << 62) |
789 | 54 |
|
55 |
#define DSL_DEADLIST_BLOCKSIZE SPA_MAXBLOCKSIZE |
|
56 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
57 |
#define DSL_DATASET_IS_DESTROYED(ds) ((ds)->ds_owner == dsl_reaper) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
58 |
|
789 | 59 |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
60 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
61 |
* Figure out how much of this delta should be propogated to the dsl_dir |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
62 |
* layer. If there's a refreservation, that space has already been |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
63 |
* partially accounted for in our ancestors. |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
64 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
65 |
static int64_t |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
66 |
parent_delta(dsl_dataset_t *ds, int64_t delta) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
67 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
68 |
uint64_t old_bytes, new_bytes; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
69 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
70 |
if (ds->ds_reserved == 0) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
71 |
return (delta); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
72 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
73 |
old_bytes = MAX(ds->ds_phys->ds_unique_bytes, ds->ds_reserved); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
74 |
new_bytes = MAX(ds->ds_phys->ds_unique_bytes + delta, ds->ds_reserved); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
75 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
76 |
ASSERT3U(ABS((int64_t)(new_bytes - old_bytes)), <=, ABS(delta)); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
77 |
return (new_bytes - old_bytes); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
78 |
} |
789 | 79 |
|
80 |
void |
|
81 |
dsl_dataset_block_born(dsl_dataset_t *ds, blkptr_t *bp, dmu_tx_t *tx) |
|
82 |
{ |
|
2082 | 83 |
int used = bp_get_dasize(tx->tx_pool->dp_spa, bp); |
789 | 84 |
int compressed = BP_GET_PSIZE(bp); |
85 |
int uncompressed = BP_GET_UCSIZE(bp); |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
86 |
int64_t delta; |
789 | 87 |
|
88 |
dprintf_bp(bp, "born, ds=%p\n", ds); |
|
89 |
||
90 |
ASSERT(dmu_tx_is_syncing(tx)); |
|
91 |
/* It could have been compressed away to nothing */ |
|
92 |
if (BP_IS_HOLE(bp)) |
|
93 |
return; |
|
94 |
ASSERT(BP_GET_TYPE(bp) != DMU_OT_NONE); |
|
95 |
ASSERT3U(BP_GET_TYPE(bp), <, DMU_OT_NUMTYPES); |
|
96 |
if (ds == NULL) { |
|
97 |
/* |
|
98 |
* Account for the meta-objset space in its placeholder |
|
99 |
* dsl_dir. |
|
100 |
*/ |
|
101 |
ASSERT3U(compressed, ==, uncompressed); /* it's all metadata */ |
|
102 |
dsl_dir_diduse_space(tx->tx_pool->dp_mos_dir, |
|
103 |
used, compressed, uncompressed, tx); |
|
104 |
dsl_dir_dirty(tx->tx_pool->dp_mos_dir, tx); |
|
105 |
return; |
|
106 |
} |
|
107 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
|
108 |
mutex_enter(&ds->ds_lock); |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
109 |
delta = parent_delta(ds, used); |
789 | 110 |
ds->ds_phys->ds_used_bytes += used; |
111 |
ds->ds_phys->ds_compressed_bytes += compressed; |
|
112 |
ds->ds_phys->ds_uncompressed_bytes += uncompressed; |
|
113 |
ds->ds_phys->ds_unique_bytes += used; |
|
114 |
mutex_exit(&ds->ds_lock); |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
115 |
dsl_dir_diduse_space(ds->ds_dir, delta, compressed, uncompressed, tx); |
789 | 116 |
} |
117 |
||
6992 | 118 |
int |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
119 |
dsl_dataset_block_kill(dsl_dataset_t *ds, blkptr_t *bp, zio_t *pio, |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
120 |
dmu_tx_t *tx) |
789 | 121 |
{ |
2082 | 122 |
int used = bp_get_dasize(tx->tx_pool->dp_spa, bp); |
789 | 123 |
int compressed = BP_GET_PSIZE(bp); |
124 |
int uncompressed = BP_GET_UCSIZE(bp); |
|
125 |
||
126 |
ASSERT(dmu_tx_is_syncing(tx)); |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
127 |
/* No block pointer => nothing to free */ |
789 | 128 |
if (BP_IS_HOLE(bp)) |
6992 | 129 |
return (0); |
789 | 130 |
|
131 |
ASSERT(used > 0); |
|
132 |
if (ds == NULL) { |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
133 |
int err; |
789 | 134 |
/* |
135 |
* Account for the meta-objset space in its placeholder |
|
136 |
* dataset. |
|
137 |
*/ |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
138 |
err = dsl_free(pio, tx->tx_pool, |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
139 |
tx->tx_txg, bp, NULL, NULL, pio ? ARC_NOWAIT: ARC_WAIT); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
140 |
ASSERT(err == 0); |
789 | 141 |
|
142 |
dsl_dir_diduse_space(tx->tx_pool->dp_mos_dir, |
|
143 |
-used, -compressed, -uncompressed, tx); |
|
144 |
dsl_dir_dirty(tx->tx_pool->dp_mos_dir, tx); |
|
6992 | 145 |
return (used); |
789 | 146 |
} |
147 |
ASSERT3P(tx->tx_pool, ==, ds->ds_dir->dd_pool); |
|
148 |
||
149 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
|
150 |
||
151 |
if (bp->blk_birth > ds->ds_phys->ds_prev_snap_txg) { |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
152 |
int err; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
153 |
int64_t delta; |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
154 |
|
789 | 155 |
dprintf_bp(bp, "freeing: %s", ""); |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
156 |
err = dsl_free(pio, tx->tx_pool, |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
157 |
tx->tx_txg, bp, NULL, NULL, pio ? ARC_NOWAIT: ARC_WAIT); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
158 |
ASSERT(err == 0); |
789 | 159 |
|
160 |
mutex_enter(&ds->ds_lock); |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
161 |
ASSERT(ds->ds_phys->ds_unique_bytes >= used || |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
162 |
!DS_UNIQUE_IS_ACCURATE(ds)); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
163 |
delta = parent_delta(ds, -used); |
789 | 164 |
ds->ds_phys->ds_unique_bytes -= used; |
165 |
mutex_exit(&ds->ds_lock); |
|
166 |
dsl_dir_diduse_space(ds->ds_dir, |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
167 |
delta, -compressed, -uncompressed, tx); |
789 | 168 |
} else { |
169 |
dprintf_bp(bp, "putting on dead list: %s", ""); |
|
1544 | 170 |
VERIFY(0 == bplist_enqueue(&ds->ds_deadlist, bp, tx)); |
5712
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5569
diff
changeset
|
171 |
ASSERT3U(ds->ds_prev->ds_object, ==, |
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5569
diff
changeset
|
172 |
ds->ds_phys->ds_prev_snap_obj); |
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5569
diff
changeset
|
173 |
ASSERT(ds->ds_prev->ds_phys->ds_num_children > 0); |
789 | 174 |
/* if (bp->blk_birth > prev prev snap txg) prev unique += bs */ |
5712
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5569
diff
changeset
|
175 |
if (ds->ds_prev->ds_phys->ds_next_snap_obj == |
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5569
diff
changeset
|
176 |
ds->ds_object && bp->blk_birth > |
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5569
diff
changeset
|
177 |
ds->ds_prev->ds_phys->ds_prev_snap_txg) { |
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5569
diff
changeset
|
178 |
dmu_buf_will_dirty(ds->ds_prev->ds_dbuf, tx); |
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5569
diff
changeset
|
179 |
mutex_enter(&ds->ds_prev->ds_lock); |
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5569
diff
changeset
|
180 |
ds->ds_prev->ds_phys->ds_unique_bytes += used; |
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5569
diff
changeset
|
181 |
mutex_exit(&ds->ds_prev->ds_lock); |
789 | 182 |
} |
183 |
} |
|
184 |
mutex_enter(&ds->ds_lock); |
|
185 |
ASSERT3U(ds->ds_phys->ds_used_bytes, >=, used); |
|
186 |
ds->ds_phys->ds_used_bytes -= used; |
|
187 |
ASSERT3U(ds->ds_phys->ds_compressed_bytes, >=, compressed); |
|
188 |
ds->ds_phys->ds_compressed_bytes -= compressed; |
|
189 |
ASSERT3U(ds->ds_phys->ds_uncompressed_bytes, >=, uncompressed); |
|
190 |
ds->ds_phys->ds_uncompressed_bytes -= uncompressed; |
|
191 |
mutex_exit(&ds->ds_lock); |
|
6992 | 192 |
|
193 |
return (used); |
|
789 | 194 |
} |
195 |
||
1544 | 196 |
uint64_t |
197 |
dsl_dataset_prev_snap_txg(dsl_dataset_t *ds) |
|
789 | 198 |
{ |
2885 | 199 |
uint64_t trysnap = 0; |
200 |
||
789 | 201 |
if (ds == NULL) |
1544 | 202 |
return (0); |
789 | 203 |
/* |
204 |
* The snapshot creation could fail, but that would cause an |
|
205 |
* incorrect FALSE return, which would only result in an |
|
206 |
* overestimation of the amount of space that an operation would |
|
207 |
* consume, which is OK. |
|
208 |
* |
|
209 |
* There's also a small window where we could miss a pending |
|
210 |
* snapshot, because we could set the sync task in the quiescing |
|
211 |
* phase. So this should only be used as a guess. |
|
212 |
*/ |
|
2885 | 213 |
if (ds->ds_trysnap_txg > |
214 |
spa_last_synced_txg(ds->ds_dir->dd_pool->dp_spa)) |
|
215 |
trysnap = ds->ds_trysnap_txg; |
|
216 |
return (MAX(ds->ds_phys->ds_prev_snap_txg, trysnap)); |
|
1544 | 217 |
} |
218 |
||
219 |
int |
|
220 |
dsl_dataset_block_freeable(dsl_dataset_t *ds, uint64_t blk_birth) |
|
221 |
{ |
|
222 |
return (blk_birth > dsl_dataset_prev_snap_txg(ds)); |
|
789 | 223 |
} |
224 |
||
225 |
/* ARGSUSED */ |
|
226 |
static void |
|
227 |
dsl_dataset_evict(dmu_buf_t *db, void *dsv) |
|
228 |
{ |
|
229 |
dsl_dataset_t *ds = dsv; |
|
230 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
231 |
ASSERT(ds->ds_owner == NULL || DSL_DATASET_IS_DESTROYED(ds)); |
789 | 232 |
|
233 |
dprintf_ds(ds, "evicting %s\n", ""); |
|
234 |
||
4787 | 235 |
unique_remove(ds->ds_fsid_guid); |
789 | 236 |
|
237 |
if (ds->ds_user_ptr != NULL) |
|
238 |
ds->ds_user_evict_func(ds, ds->ds_user_ptr); |
|
239 |
||
240 |
if (ds->ds_prev) { |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
241 |
dsl_dataset_drop_ref(ds->ds_prev, ds); |
789 | 242 |
ds->ds_prev = NULL; |
243 |
} |
|
244 |
||
245 |
bplist_close(&ds->ds_deadlist); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
246 |
if (ds->ds_dir) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
247 |
dsl_dir_close(ds->ds_dir, ds); |
789 | 248 |
|
4787 | 249 |
ASSERT(!list_link_active(&ds->ds_synced_link)); |
789 | 250 |
|
2856 | 251 |
mutex_destroy(&ds->ds_lock); |
4787 | 252 |
mutex_destroy(&ds->ds_opening_lock); |
2856 | 253 |
mutex_destroy(&ds->ds_deadlist.bpl_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
254 |
rw_destroy(&ds->ds_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
255 |
cv_destroy(&ds->ds_exclusive_cv); |
2856 | 256 |
|
789 | 257 |
kmem_free(ds, sizeof (dsl_dataset_t)); |
258 |
} |
|
259 |
||
1544 | 260 |
static int |
789 | 261 |
dsl_dataset_get_snapname(dsl_dataset_t *ds) |
262 |
{ |
|
263 |
dsl_dataset_phys_t *headphys; |
|
264 |
int err; |
|
265 |
dmu_buf_t *headdbuf; |
|
266 |
dsl_pool_t *dp = ds->ds_dir->dd_pool; |
|
267 |
objset_t *mos = dp->dp_meta_objset; |
|
268 |
||
269 |
if (ds->ds_snapname[0]) |
|
1544 | 270 |
return (0); |
789 | 271 |
if (ds->ds_phys->ds_next_snap_obj == 0) |
1544 | 272 |
return (0); |
789 | 273 |
|
1544 | 274 |
err = dmu_bonus_hold(mos, ds->ds_dir->dd_phys->dd_head_dataset_obj, |
275 |
FTAG, &headdbuf); |
|
276 |
if (err) |
|
277 |
return (err); |
|
789 | 278 |
headphys = headdbuf->db_data; |
279 |
err = zap_value_search(dp->dp_meta_objset, |
|
4577 | 280 |
headphys->ds_snapnames_zapobj, ds->ds_object, 0, ds->ds_snapname); |
1544 | 281 |
dmu_buf_rele(headdbuf, FTAG); |
282 |
return (err); |
|
789 | 283 |
} |
284 |
||
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
285 |
static int |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
286 |
dsl_dataset_snap_lookup(dsl_dataset_t *ds, const char *name, uint64_t *value) |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
287 |
{ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
288 |
objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
289 |
uint64_t snapobj = ds->ds_phys->ds_snapnames_zapobj; |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
290 |
matchtype_t mt; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
291 |
int err; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
292 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
293 |
if (ds->ds_phys->ds_flags & DS_FLAG_CI_DATASET) |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
294 |
mt = MT_FIRST; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
295 |
else |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
296 |
mt = MT_EXACT; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
297 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
298 |
err = zap_lookup_norm(mos, snapobj, name, 8, 1, |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
299 |
value, mt, NULL, 0, NULL); |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
300 |
if (err == ENOTSUP && mt == MT_FIRST) |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
301 |
err = zap_lookup(mos, snapobj, name, 8, 1, value); |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
302 |
return (err); |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
303 |
} |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
304 |
|
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
305 |
static int |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
306 |
dsl_dataset_snap_remove(dsl_dataset_t *ds, char *name, dmu_tx_t *tx) |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
307 |
{ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
308 |
objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
309 |
uint64_t snapobj = ds->ds_phys->ds_snapnames_zapobj; |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
310 |
matchtype_t mt; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
311 |
int err; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
312 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
313 |
if (ds->ds_phys->ds_flags & DS_FLAG_CI_DATASET) |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
314 |
mt = MT_FIRST; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
315 |
else |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
316 |
mt = MT_EXACT; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
317 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
318 |
err = zap_remove_norm(mos, snapobj, name, mt, tx); |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
319 |
if (err == ENOTSUP && mt == MT_FIRST) |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
320 |
err = zap_remove(mos, snapobj, name, tx); |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
321 |
return (err); |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
322 |
} |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
323 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
324 |
static int |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
325 |
dsl_dataset_get_ref(dsl_pool_t *dp, uint64_t dsobj, void *tag, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
326 |
dsl_dataset_t **dsp) |
789 | 327 |
{ |
328 |
objset_t *mos = dp->dp_meta_objset; |
|
329 |
dmu_buf_t *dbuf; |
|
330 |
dsl_dataset_t *ds; |
|
1544 | 331 |
int err; |
789 | 332 |
|
333 |
ASSERT(RW_LOCK_HELD(&dp->dp_config_rwlock) || |
|
334 |
dsl_pool_sync_context(dp)); |
|
335 |
||
1544 | 336 |
err = dmu_bonus_hold(mos, dsobj, tag, &dbuf); |
337 |
if (err) |
|
338 |
return (err); |
|
789 | 339 |
ds = dmu_buf_get_user(dbuf); |
340 |
if (ds == NULL) { |
|
341 |
dsl_dataset_t *winner; |
|
342 |
||
343 |
ds = kmem_zalloc(sizeof (dsl_dataset_t), KM_SLEEP); |
|
344 |
ds->ds_dbuf = dbuf; |
|
345 |
ds->ds_object = dsobj; |
|
346 |
ds->ds_phys = dbuf->db_data; |
|
347 |
||
2856 | 348 |
mutex_init(&ds->ds_lock, NULL, MUTEX_DEFAULT, NULL); |
4787 | 349 |
mutex_init(&ds->ds_opening_lock, NULL, MUTEX_DEFAULT, NULL); |
2856 | 350 |
mutex_init(&ds->ds_deadlist.bpl_lock, NULL, MUTEX_DEFAULT, |
351 |
NULL); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
352 |
rw_init(&ds->ds_rwlock, 0, 0, 0); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
353 |
cv_init(&ds->ds_exclusive_cv, NULL, CV_DEFAULT, NULL); |
2856 | 354 |
|
1544 | 355 |
err = bplist_open(&ds->ds_deadlist, |
789 | 356 |
mos, ds->ds_phys->ds_deadlist_obj); |
1544 | 357 |
if (err == 0) { |
358 |
err = dsl_dir_open_obj(dp, |
|
359 |
ds->ds_phys->ds_dir_obj, NULL, ds, &ds->ds_dir); |
|
360 |
} |
|
361 |
if (err) { |
|
362 |
/* |
|
363 |
* we don't really need to close the blist if we |
|
364 |
* just opened it. |
|
365 |
*/ |
|
2856 | 366 |
mutex_destroy(&ds->ds_lock); |
4787 | 367 |
mutex_destroy(&ds->ds_opening_lock); |
2856 | 368 |
mutex_destroy(&ds->ds_deadlist.bpl_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
369 |
rw_destroy(&ds->ds_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
370 |
cv_destroy(&ds->ds_exclusive_cv); |
1544 | 371 |
kmem_free(ds, sizeof (dsl_dataset_t)); |
372 |
dmu_buf_rele(dbuf, tag); |
|
373 |
return (err); |
|
374 |
} |
|
789 | 375 |
|
376 |
if (ds->ds_dir->dd_phys->dd_head_dataset_obj == dsobj) { |
|
377 |
ds->ds_snapname[0] = '\0'; |
|
378 |
if (ds->ds_phys->ds_prev_snap_obj) { |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
379 |
err = dsl_dataset_get_ref(dp, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
380 |
ds->ds_phys->ds_prev_snap_obj, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
381 |
ds, &ds->ds_prev); |
789 | 382 |
} |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
383 |
} else if (zfs_flags & ZFS_DEBUG_SNAPNAMES) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
384 |
err = dsl_dataset_get_snapname(ds); |
789 | 385 |
} |
386 |
||
5475
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
387 |
if (!dsl_dataset_is_snapshot(ds)) { |
5569
d3caac36d311
6634062 dsl_dataset_open_obj misuses RW_LOCK_HELD
ck153898
parents:
5518
diff
changeset
|
388 |
/* |
d3caac36d311
6634062 dsl_dataset_open_obj misuses RW_LOCK_HELD
ck153898
parents:
5518
diff
changeset
|
389 |
* In sync context, we're called with either no lock |
d3caac36d311
6634062 dsl_dataset_open_obj misuses RW_LOCK_HELD
ck153898
parents:
5518
diff
changeset
|
390 |
* or with the write lock. If we're not syncing, |
d3caac36d311
6634062 dsl_dataset_open_obj misuses RW_LOCK_HELD
ck153898
parents:
5518
diff
changeset
|
391 |
* we're always called with the read lock held. |
d3caac36d311
6634062 dsl_dataset_open_obj misuses RW_LOCK_HELD
ck153898
parents:
5518
diff
changeset
|
392 |
*/ |
5475
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
393 |
boolean_t need_lock = |
5569
d3caac36d311
6634062 dsl_dataset_open_obj misuses RW_LOCK_HELD
ck153898
parents:
5518
diff
changeset
|
394 |
!RW_WRITE_HELD(&dp->dp_config_rwlock) && |
d3caac36d311
6634062 dsl_dataset_open_obj misuses RW_LOCK_HELD
ck153898
parents:
5518
diff
changeset
|
395 |
dsl_pool_sync_context(dp); |
5475
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
396 |
|
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
397 |
if (need_lock) |
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
398 |
rw_enter(&dp->dp_config_rwlock, RW_READER); |
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
399 |
|
7265 | 400 |
err = dsl_prop_get_ds(ds, |
5475
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
401 |
"refreservation", sizeof (uint64_t), 1, |
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
402 |
&ds->ds_reserved, NULL); |
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
403 |
if (err == 0) { |
7265 | 404 |
err = dsl_prop_get_ds(ds, |
5475
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
405 |
"refquota", sizeof (uint64_t), 1, |
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
406 |
&ds->ds_quota, NULL); |
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
407 |
} |
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
408 |
|
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
409 |
if (need_lock) |
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
410 |
rw_exit(&dp->dp_config_rwlock); |
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
411 |
} else { |
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
412 |
ds->ds_reserved = ds->ds_quota = 0; |
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
413 |
} |
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
414 |
|
1544 | 415 |
if (err == 0) { |
416 |
winner = dmu_buf_set_user_ie(dbuf, ds, &ds->ds_phys, |
|
417 |
dsl_dataset_evict); |
|
418 |
} |
|
419 |
if (err || winner) { |
|
789 | 420 |
bplist_close(&ds->ds_deadlist); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
421 |
if (ds->ds_prev) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
422 |
dsl_dataset_drop_ref(ds->ds_prev, ds); |
789 | 423 |
dsl_dir_close(ds->ds_dir, ds); |
2856 | 424 |
mutex_destroy(&ds->ds_lock); |
4787 | 425 |
mutex_destroy(&ds->ds_opening_lock); |
2856 | 426 |
mutex_destroy(&ds->ds_deadlist.bpl_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
427 |
rw_destroy(&ds->ds_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
428 |
cv_destroy(&ds->ds_exclusive_cv); |
789 | 429 |
kmem_free(ds, sizeof (dsl_dataset_t)); |
1544 | 430 |
if (err) { |
431 |
dmu_buf_rele(dbuf, tag); |
|
432 |
return (err); |
|
433 |
} |
|
789 | 434 |
ds = winner; |
435 |
} else { |
|
4787 | 436 |
ds->ds_fsid_guid = |
789 | 437 |
unique_insert(ds->ds_phys->ds_fsid_guid); |
438 |
} |
|
439 |
} |
|
440 |
ASSERT3P(ds->ds_dbuf, ==, dbuf); |
|
441 |
ASSERT3P(ds->ds_phys, ==, dbuf->db_data); |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
442 |
ASSERT(ds->ds_phys->ds_prev_snap_obj != 0 || |
7061
524fec1acf1c
6723703 zpool upgrade -> assertion failed: ds->ds_phys->ds_prev_snap_obj != 0 || ...
ahrens
parents:
7046
diff
changeset
|
443 |
spa_version(dp->dp_spa) < SPA_VERSION_ORIGIN || |
7077
a63bdc0b8352
6724675 assertion failed in dsl_dataset_get_ref(): ds->ds_phys->ds_prev_snap_obj != 0 ...
ahrens
parents:
7061
diff
changeset
|
444 |
dp->dp_origin_snap == NULL || ds == dp->dp_origin_snap); |
789 | 445 |
mutex_enter(&ds->ds_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
446 |
if (!dsl_pool_sync_context(dp) && DSL_DATASET_IS_DESTROYED(ds)) { |
789 | 447 |
mutex_exit(&ds->ds_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
448 |
dmu_buf_rele(ds->ds_dbuf, tag); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
449 |
return (ENOENT); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
450 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
451 |
mutex_exit(&ds->ds_lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
452 |
*dsp = ds; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
453 |
return (0); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
454 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
455 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
456 |
static int |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
457 |
dsl_dataset_hold_ref(dsl_dataset_t *ds, void *tag) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
458 |
{ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
459 |
dsl_pool_t *dp = ds->ds_dir->dd_pool; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
460 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
461 |
/* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
462 |
* In syncing context we don't want the rwlock lock: there |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
463 |
* may be an existing writer waiting for sync phase to |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
464 |
* finish. We don't need to worry about such writers, since |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
465 |
* sync phase is single-threaded, so the writer can't be |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
466 |
* doing anything while we are active. |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
467 |
*/ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
468 |
if (dsl_pool_sync_context(dp)) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
469 |
ASSERT(!DSL_DATASET_IS_DESTROYED(ds)); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
470 |
return (0); |
789 | 471 |
} |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
472 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
473 |
/* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
474 |
* Normal users will hold the ds_rwlock as a READER until they |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
475 |
* are finished (i.e., call dsl_dataset_rele()). "Owners" will |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
476 |
* drop their READER lock after they set the ds_owner field. |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
477 |
* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
478 |
* If the dataset is being destroyed, the destroy thread will |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
479 |
* obtain a WRITER lock for exclusive access after it's done its |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
480 |
* open-context work and then change the ds_owner to |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
481 |
* dsl_reaper once destruction is assured. So threads |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
482 |
* may block here temporarily, until the "destructability" of |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
483 |
* the dataset is determined. |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
484 |
*/ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
485 |
ASSERT(!RW_WRITE_HELD(&dp->dp_config_rwlock)); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
486 |
mutex_enter(&ds->ds_lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
487 |
while (!rw_tryenter(&ds->ds_rwlock, RW_READER)) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
488 |
rw_exit(&dp->dp_config_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
489 |
cv_wait(&ds->ds_exclusive_cv, &ds->ds_lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
490 |
if (DSL_DATASET_IS_DESTROYED(ds)) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
491 |
mutex_exit(&ds->ds_lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
492 |
dsl_dataset_drop_ref(ds, tag); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
493 |
rw_enter(&dp->dp_config_rwlock, RW_READER); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
494 |
return (ENOENT); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
495 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
496 |
rw_enter(&dp->dp_config_rwlock, RW_READER); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
497 |
} |
789 | 498 |
mutex_exit(&ds->ds_lock); |
1544 | 499 |
return (0); |
789 | 500 |
} |
501 |
||
502 |
int |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
503 |
dsl_dataset_hold_obj(dsl_pool_t *dp, uint64_t dsobj, void *tag, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
504 |
dsl_dataset_t **dsp) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
505 |
{ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
506 |
int err = dsl_dataset_get_ref(dp, dsobj, tag, dsp); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
507 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
508 |
if (err) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
509 |
return (err); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
510 |
return (dsl_dataset_hold_ref(*dsp, tag)); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
511 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
512 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
513 |
int |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
514 |
dsl_dataset_own_obj(dsl_pool_t *dp, uint64_t dsobj, int flags, void *owner, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
515 |
dsl_dataset_t **dsp) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
516 |
{ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
517 |
int err = dsl_dataset_hold_obj(dp, dsobj, owner, dsp); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
518 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
519 |
ASSERT(DS_MODE_TYPE(flags) != DS_MODE_USER); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
520 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
521 |
if (err) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
522 |
return (err); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
523 |
if (!dsl_dataset_tryown(*dsp, DS_MODE_IS_INCONSISTENT(flags), owner)) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
524 |
dsl_dataset_rele(*dsp, owner); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
525 |
return (EBUSY); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
526 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
527 |
return (0); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
528 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
529 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
530 |
int |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
531 |
dsl_dataset_hold(const char *name, void *tag, dsl_dataset_t **dsp) |
789 | 532 |
{ |
533 |
dsl_dir_t *dd; |
|
534 |
dsl_pool_t *dp; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
535 |
const char *snapname; |
789 | 536 |
uint64_t obj; |
537 |
int err = 0; |
|
538 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
539 |
err = dsl_dir_open_spa(NULL, name, FTAG, &dd, &snapname); |
1544 | 540 |
if (err) |
541 |
return (err); |
|
789 | 542 |
|
543 |
dp = dd->dd_pool; |
|
544 |
obj = dd->dd_phys->dd_head_dataset_obj; |
|
545 |
rw_enter(&dp->dp_config_rwlock, RW_READER); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
546 |
if (obj) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
547 |
err = dsl_dataset_get_ref(dp, obj, tag, dsp); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
548 |
else |
789 | 549 |
err = ENOENT; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
550 |
if (err) |
789 | 551 |
goto out; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
552 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
553 |
err = dsl_dataset_hold_ref(*dsp, tag); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
554 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
555 |
/* we may be looking for a snapshot */ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
556 |
if (err == 0 && snapname != NULL) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
557 |
dsl_dataset_t *ds = NULL; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
558 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
559 |
if (*snapname++ != '@') { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
560 |
dsl_dataset_rele(*dsp, tag); |
789 | 561 |
err = ENOENT; |
562 |
goto out; |
|
563 |
} |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
564 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
565 |
dprintf("looking for snapshot '%s'\n", snapname); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
566 |
err = dsl_dataset_snap_lookup(*dsp, snapname, &obj); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
567 |
if (err == 0) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
568 |
err = dsl_dataset_get_ref(dp, obj, tag, &ds); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
569 |
dsl_dataset_rele(*dsp, tag); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
570 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
571 |
ASSERT3U((err == 0), ==, (ds != NULL)); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
572 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
573 |
if (ds) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
574 |
mutex_enter(&ds->ds_lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
575 |
if (ds->ds_snapname[0] == 0) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
576 |
(void) strlcpy(ds->ds_snapname, snapname, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
577 |
sizeof (ds->ds_snapname)); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
578 |
mutex_exit(&ds->ds_lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
579 |
err = dsl_dataset_hold_ref(ds, tag); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
580 |
*dsp = err ? NULL : ds; |
789 | 581 |
} |
582 |
} |
|
583 |
out: |
|
584 |
rw_exit(&dp->dp_config_rwlock); |
|
585 |
dsl_dir_close(dd, FTAG); |
|
586 |
return (err); |
|
587 |
} |
|
588 |
||
589 |
int |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
590 |
dsl_dataset_own(const char *name, int flags, void *owner, dsl_dataset_t **dsp) |
789 | 591 |
{ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
592 |
int err = dsl_dataset_hold(name, owner, dsp); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
593 |
if (err) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
594 |
return (err); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
595 |
if ((*dsp)->ds_phys->ds_num_children > 0 && |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
596 |
!DS_MODE_IS_READONLY(flags)) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
597 |
dsl_dataset_rele(*dsp, owner); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
598 |
return (EROFS); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
599 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
600 |
if (!dsl_dataset_tryown(*dsp, DS_MODE_IS_INCONSISTENT(flags), owner)) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
601 |
dsl_dataset_rele(*dsp, owner); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
602 |
return (EBUSY); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
603 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
604 |
return (0); |
789 | 605 |
} |
606 |
||
607 |
void |
|
608 |
dsl_dataset_name(dsl_dataset_t *ds, char *name) |
|
609 |
{ |
|
610 |
if (ds == NULL) { |
|
611 |
(void) strcpy(name, "mos"); |
|
612 |
} else { |
|
613 |
dsl_dir_name(ds->ds_dir, name); |
|
1544 | 614 |
VERIFY(0 == dsl_dataset_get_snapname(ds)); |
789 | 615 |
if (ds->ds_snapname[0]) { |
616 |
(void) strcat(name, "@"); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
617 |
/* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
618 |
* We use a "recursive" mutex so that we |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
619 |
* can call dprintf_ds() with ds_lock held. |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
620 |
*/ |
789 | 621 |
if (!MUTEX_HELD(&ds->ds_lock)) { |
622 |
mutex_enter(&ds->ds_lock); |
|
623 |
(void) strcat(name, ds->ds_snapname); |
|
624 |
mutex_exit(&ds->ds_lock); |
|
625 |
} else { |
|
626 |
(void) strcat(name, ds->ds_snapname); |
|
627 |
} |
|
628 |
} |
|
629 |
} |
|
630 |
} |
|
631 |
||
3978
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
632 |
static int |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
633 |
dsl_dataset_namelen(dsl_dataset_t *ds) |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
634 |
{ |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
635 |
int result; |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
636 |
|
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
637 |
if (ds == NULL) { |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
638 |
result = 3; /* "mos" */ |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
639 |
} else { |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
640 |
result = dsl_dir_namelen(ds->ds_dir); |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
641 |
VERIFY(0 == dsl_dataset_get_snapname(ds)); |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
642 |
if (ds->ds_snapname[0]) { |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
643 |
++result; /* adding one for the @-sign */ |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
644 |
if (!MUTEX_HELD(&ds->ds_lock)) { |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
645 |
mutex_enter(&ds->ds_lock); |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
646 |
result += strlen(ds->ds_snapname); |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
647 |
mutex_exit(&ds->ds_lock); |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
648 |
} else { |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
649 |
result += strlen(ds->ds_snapname); |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
650 |
} |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
651 |
} |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
652 |
} |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
653 |
|
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
654 |
return (result); |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
655 |
} |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
656 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
657 |
void |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
658 |
dsl_dataset_drop_ref(dsl_dataset_t *ds, void *tag) |
789 | 659 |
{ |
1544 | 660 |
dmu_buf_rele(ds->ds_dbuf, tag); |
789 | 661 |
} |
662 |
||
663 |
void |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
664 |
dsl_dataset_rele(dsl_dataset_t *ds, void *tag) |
5367 | 665 |
{ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
666 |
if (!dsl_pool_sync_context(ds->ds_dir->dd_pool)) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
667 |
rw_exit(&ds->ds_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
668 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
669 |
dsl_dataset_drop_ref(ds, tag); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
670 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
671 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
672 |
void |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
673 |
dsl_dataset_disown(dsl_dataset_t *ds, void *owner) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
674 |
{ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
675 |
ASSERT((ds->ds_owner == owner && ds->ds_dbuf) || |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
676 |
(DSL_DATASET_IS_DESTROYED(ds) && ds->ds_dbuf == NULL)); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
677 |
|
5367 | 678 |
mutex_enter(&ds->ds_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
679 |
ds->ds_owner = NULL; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
680 |
if (RW_WRITE_HELD(&ds->ds_rwlock)) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
681 |
rw_exit(&ds->ds_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
682 |
cv_broadcast(&ds->ds_exclusive_cv); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
683 |
} |
5367 | 684 |
mutex_exit(&ds->ds_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
685 |
if (ds->ds_dbuf) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
686 |
dsl_dataset_drop_ref(ds, owner); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
687 |
else |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
688 |
dsl_dataset_evict(ds->ds_dbuf, ds); |
5367 | 689 |
} |
690 |
||
691 |
boolean_t |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
692 |
dsl_dataset_tryown(dsl_dataset_t *ds, boolean_t inconsistentok, void *owner) |
5367 | 693 |
{ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
694 |
boolean_t gotit = FALSE; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
695 |
|
5367 | 696 |
mutex_enter(&ds->ds_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
697 |
if (ds->ds_owner == NULL && |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
698 |
(!DS_IS_INCONSISTENT(ds) || inconsistentok)) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
699 |
ds->ds_owner = owner; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
700 |
if (!dsl_pool_sync_context(ds->ds_dir->dd_pool)) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
701 |
rw_exit(&ds->ds_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
702 |
gotit = TRUE; |
5367 | 703 |
} |
704 |
mutex_exit(&ds->ds_lock); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
705 |
return (gotit); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
706 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
707 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
708 |
void |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
709 |
dsl_dataset_make_exclusive(dsl_dataset_t *ds, void *owner) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
710 |
{ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
711 |
ASSERT3P(owner, ==, ds->ds_owner); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
712 |
if (!RW_WRITE_HELD(&ds->ds_rwlock)) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
713 |
rw_enter(&ds->ds_rwlock, RW_WRITER); |
5367 | 714 |
} |
715 |
||
2199 | 716 |
uint64_t |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
717 |
dsl_dataset_create_sync_dd(dsl_dir_t *dd, dsl_dataset_t *origin, |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
718 |
uint64_t flags, dmu_tx_t *tx) |
789 | 719 |
{ |
5367 | 720 |
dsl_pool_t *dp = dd->dd_pool; |
789 | 721 |
dmu_buf_t *dbuf; |
722 |
dsl_dataset_phys_t *dsphys; |
|
5367 | 723 |
uint64_t dsobj; |
789 | 724 |
objset_t *mos = dp->dp_meta_objset; |
725 |
||
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
726 |
if (origin == NULL) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
727 |
origin = dp->dp_origin_snap; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
728 |
|
5367 | 729 |
ASSERT(origin == NULL || origin->ds_dir->dd_pool == dp); |
730 |
ASSERT(origin == NULL || origin->ds_phys->ds_num_children > 0); |
|
789 | 731 |
ASSERT(dmu_tx_is_syncing(tx)); |
5367 | 732 |
ASSERT(dd->dd_phys->dd_head_dataset_obj == 0); |
789 | 733 |
|
928
36d72fe4da29
6349314 dmu_object_type names incorrect for DSL Directories and DSL Datasets
tabriz
parents:
885
diff
changeset
|
734 |
dsobj = dmu_object_alloc(mos, DMU_OT_DSL_DATASET, 0, |
36d72fe4da29
6349314 dmu_object_type names incorrect for DSL Directories and DSL Datasets
tabriz
parents:
885
diff
changeset
|
735 |
DMU_OT_DSL_DATASET, sizeof (dsl_dataset_phys_t), tx); |
1544 | 736 |
VERIFY(0 == dmu_bonus_hold(mos, dsobj, FTAG, &dbuf)); |
789 | 737 |
dmu_buf_will_dirty(dbuf, tx); |
738 |
dsphys = dbuf->db_data; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
739 |
bzero(dsphys, sizeof (dsl_dataset_phys_t)); |
789 | 740 |
dsphys->ds_dir_obj = dd->dd_object; |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
741 |
dsphys->ds_flags = flags; |
789 | 742 |
dsphys->ds_fsid_guid = unique_create(); |
743 |
(void) random_get_pseudo_bytes((void*)&dsphys->ds_guid, |
|
744 |
sizeof (dsphys->ds_guid)); |
|
745 |
dsphys->ds_snapnames_zapobj = |
|
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
746 |
zap_create_norm(mos, U8_TEXTPREP_TOUPPER, DMU_OT_DSL_DS_SNAP_MAP, |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
747 |
DMU_OT_NONE, 0, tx); |
789 | 748 |
dsphys->ds_creation_time = gethrestime_sec(); |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
749 |
dsphys->ds_creation_txg = tx->tx_txg == TXG_INITIAL ? 1 : tx->tx_txg; |
789 | 750 |
dsphys->ds_deadlist_obj = |
751 |
bplist_create(mos, DSL_DEADLIST_BLOCKSIZE, tx); |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
752 |
|
5367 | 753 |
if (origin) { |
754 |
dsphys->ds_prev_snap_obj = origin->ds_object; |
|
789 | 755 |
dsphys->ds_prev_snap_txg = |
5367 | 756 |
origin->ds_phys->ds_creation_txg; |
789 | 757 |
dsphys->ds_used_bytes = |
5367 | 758 |
origin->ds_phys->ds_used_bytes; |
789 | 759 |
dsphys->ds_compressed_bytes = |
5367 | 760 |
origin->ds_phys->ds_compressed_bytes; |
789 | 761 |
dsphys->ds_uncompressed_bytes = |
5367 | 762 |
origin->ds_phys->ds_uncompressed_bytes; |
763 |
dsphys->ds_bp = origin->ds_phys->ds_bp; |
|
6502
66aef5f20377
6694731 drc->drc_real_ds->ds_phys->ds_flags & (1ULL<<0), file: ../../common/fs/zfs/dmu_send.c, line: 1069
timh
parents:
6492
diff
changeset
|
764 |
dsphys->ds_flags |= origin->ds_phys->ds_flags; |
789 | 765 |
|
5367 | 766 |
dmu_buf_will_dirty(origin->ds_dbuf, tx); |
767 |
origin->ds_phys->ds_num_children++; |
|
789 | 768 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
769 |
if (spa_version(dp->dp_spa) >= SPA_VERSION_NEXT_CLONES) { |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
770 |
if (origin->ds_phys->ds_next_clones_obj == 0) { |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
771 |
origin->ds_phys->ds_next_clones_obj = |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
772 |
zap_create(mos, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
773 |
DMU_OT_NEXT_CLONES, DMU_OT_NONE, 0, tx); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
774 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
775 |
VERIFY(0 == zap_add_int(mos, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
776 |
origin->ds_phys->ds_next_clones_obj, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
777 |
dsobj, tx)); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
778 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
779 |
|
789 | 780 |
dmu_buf_will_dirty(dd->dd_dbuf, tx); |
5367 | 781 |
dd->dd_phys->dd_origin_obj = origin->ds_object; |
789 | 782 |
} |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
783 |
|
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
784 |
if (spa_version(dp->dp_spa) >= SPA_VERSION_UNIQUE_ACCURATE) |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
785 |
dsphys->ds_flags |= DS_FLAG_UNIQUE_ACCURATE; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
786 |
|
1544 | 787 |
dmu_buf_rele(dbuf, FTAG); |
789 | 788 |
|
789 |
dmu_buf_will_dirty(dd->dd_dbuf, tx); |
|
790 |
dd->dd_phys->dd_head_dataset_obj = dsobj; |
|
5367 | 791 |
|
792 |
return (dsobj); |
|
793 |
} |
|
794 |
||
795 |
uint64_t |
|
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
796 |
dsl_dataset_create_sync(dsl_dir_t *pdd, const char *lastname, |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
797 |
dsl_dataset_t *origin, uint64_t flags, cred_t *cr, dmu_tx_t *tx) |
5367 | 798 |
{ |
799 |
dsl_pool_t *dp = pdd->dd_pool; |
|
800 |
uint64_t dsobj, ddobj; |
|
801 |
dsl_dir_t *dd; |
|
802 |
||
803 |
ASSERT(lastname[0] != '@'); |
|
804 |
||
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
805 |
ddobj = dsl_dir_create_sync(dp, pdd, lastname, tx); |
5367 | 806 |
VERIFY(0 == dsl_dir_open_obj(dp, ddobj, lastname, FTAG, &dd)); |
807 |
||
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
808 |
dsobj = dsl_dataset_create_sync_dd(dd, origin, flags, tx); |
5367 | 809 |
|
810 |
dsl_deleg_set_create_perms(dd, tx, cr); |
|
811 |
||
789 | 812 |
dsl_dir_close(dd, FTAG); |
813 |
||
2199 | 814 |
return (dsobj); |
815 |
} |
|
816 |
||
817 |
struct destroyarg { |
|
818 |
dsl_sync_task_group_t *dstg; |
|
819 |
char *snapname; |
|
820 |
char *failed; |
|
821 |
}; |
|
822 |
||
823 |
static int |
|
824 |
dsl_snapshot_destroy_one(char *name, void *arg) |
|
825 |
{ |
|
826 |
struct destroyarg *da = arg; |
|
827 |
dsl_dataset_t *ds; |
|
828 |
char *cp; |
|
829 |
int err; |
|
830 |
||
831 |
(void) strcat(name, "@"); |
|
832 |
(void) strcat(name, da->snapname); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
833 |
err = dsl_dataset_own(name, DS_MODE_READONLY | DS_MODE_INCONSISTENT, |
4007 | 834 |
da->dstg, &ds); |
2199 | 835 |
cp = strchr(name, '@'); |
836 |
*cp = '\0'; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
837 |
if (err == 0) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
838 |
dsl_dataset_make_exclusive(ds, da->dstg); |
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7077
diff
changeset
|
839 |
if (ds->ds_user_ptr) { |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7077
diff
changeset
|
840 |
ds->ds_user_evict_func(ds, ds->ds_user_ptr); |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7077
diff
changeset
|
841 |
ds->ds_user_ptr = NULL; |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7077
diff
changeset
|
842 |
} |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
843 |
dsl_sync_task_create(da->dstg, dsl_dataset_destroy_check, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
844 |
dsl_dataset_destroy_sync, ds, da->dstg, 0); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
845 |
} else if (err == ENOENT) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
846 |
err = 0; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
847 |
} else { |
2199 | 848 |
(void) strcpy(da->failed, name); |
849 |
} |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
850 |
return (err); |
789 | 851 |
} |
852 |
||
2199 | 853 |
/* |
854 |
* Destroy 'snapname' in all descendants of 'fsname'. |
|
855 |
*/ |
|
856 |
#pragma weak dmu_snapshots_destroy = dsl_snapshots_destroy |
|
857 |
int |
|
858 |
dsl_snapshots_destroy(char *fsname, char *snapname) |
|
859 |
{ |
|
860 |
int err; |
|
861 |
struct destroyarg da; |
|
862 |
dsl_sync_task_t *dst; |
|
863 |
spa_t *spa; |
|
864 |
||
4603
c7840c367d00
6494569 zfs recv -d pool/<doesn't exist> core dumps for top-level filesystem backups
ahrens
parents:
4577
diff
changeset
|
865 |
err = spa_open(fsname, &spa, FTAG); |
2199 | 866 |
if (err) |
867 |
return (err); |
|
868 |
da.dstg = dsl_sync_task_group_create(spa_get_dsl(spa)); |
|
869 |
da.snapname = snapname; |
|
870 |
da.failed = fsname; |
|
871 |
||
872 |
err = dmu_objset_find(fsname, |
|
2417 | 873 |
dsl_snapshot_destroy_one, &da, DS_FIND_CHILDREN); |
2199 | 874 |
|
875 |
if (err == 0) |
|
876 |
err = dsl_sync_task_group_wait(da.dstg); |
|
877 |
||
878 |
for (dst = list_head(&da.dstg->dstg_tasks); dst; |
|
879 |
dst = list_next(&da.dstg->dstg_tasks, dst)) { |
|
880 |
dsl_dataset_t *ds = dst->dst_arg1; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
881 |
/* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
882 |
* Return the file system name that triggered the error |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
883 |
*/ |
2199 | 884 |
if (dst->dst_err) { |
885 |
dsl_dataset_name(ds, fsname); |
|
4603
c7840c367d00
6494569 zfs recv -d pool/<doesn't exist> core dumps for top-level filesystem backups
ahrens
parents:
4577
diff
changeset
|
886 |
*strchr(fsname, '@') = '\0'; |
2199 | 887 |
} |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
888 |
dsl_dataset_disown(ds, da.dstg); |
2199 | 889 |
} |
890 |
||
891 |
dsl_sync_task_group_destroy(da.dstg); |
|
892 |
spa_close(spa, FTAG); |
|
893 |
return (err); |
|
894 |
} |
|
895 |
||
5367 | 896 |
/* |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
897 |
* ds must be opened as OWNER. On return (whether successful or not), |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
898 |
* ds will be closed and caller can no longer dereference it. |
5367 | 899 |
*/ |
789 | 900 |
int |
5367 | 901 |
dsl_dataset_destroy(dsl_dataset_t *ds, void *tag) |
789 | 902 |
{ |
903 |
int err; |
|
2199 | 904 |
dsl_sync_task_group_t *dstg; |
905 |
objset_t *os; |
|
789 | 906 |
dsl_dir_t *dd; |
2199 | 907 |
uint64_t obj; |
908 |
||
5367 | 909 |
if (dsl_dataset_is_snapshot(ds)) { |
2199 | 910 |
/* Destroying a snapshot is simpler */ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
911 |
dsl_dataset_make_exclusive(ds, tag); |
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7077
diff
changeset
|
912 |
|
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7077
diff
changeset
|
913 |
if (ds->ds_user_ptr) { |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7077
diff
changeset
|
914 |
ds->ds_user_evict_func(ds, ds->ds_user_ptr); |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7077
diff
changeset
|
915 |
ds->ds_user_ptr = NULL; |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7077
diff
changeset
|
916 |
} |
2199 | 917 |
err = dsl_sync_task_do(ds->ds_dir->dd_pool, |
918 |
dsl_dataset_destroy_check, dsl_dataset_destroy_sync, |
|
5367 | 919 |
ds, tag, 0); |
920 |
goto out; |
|
2199 | 921 |
} |
922 |
||
923 |
dd = ds->ds_dir; |
|
789 | 924 |
|
2199 | 925 |
/* |
926 |
* Check for errors and mark this ds as inconsistent, in |
|
927 |
* case we crash while freeing the objects. |
|
928 |
*/ |
|
929 |
err = dsl_sync_task_do(dd->dd_pool, dsl_dataset_destroy_begin_check, |
|
930 |
dsl_dataset_destroy_begin_sync, ds, NULL, 0); |
|
5367 | 931 |
if (err) |
932 |
goto out; |
|
933 |
||
934 |
err = dmu_objset_open_ds(ds, DMU_OST_ANY, &os); |
|
935 |
if (err) |
|
936 |
goto out; |
|
2199 | 937 |
|
938 |
/* |
|
939 |
* remove the objects in open context, so that we won't |
|
940 |
* have too much to do in syncing context. |
|
941 |
*/ |
|
3025
4e5ee8301d84
6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents:
2885
diff
changeset
|
942 |
for (obj = 0; err == 0; err = dmu_object_next(os, &obj, FALSE, |
4e5ee8301d84
6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents:
2885
diff
changeset
|
943 |
ds->ds_phys->ds_prev_snap_txg)) { |
6992 | 944 |
/* |
945 |
* Ignore errors, if there is not enough disk space |
|
946 |
* we will deal with it in dsl_dataset_destroy_sync(). |
|
947 |
*/ |
|
948 |
(void) dmu_free_object(os, obj); |
|
2199 | 949 |
} |
950 |
||
951 |
dmu_objset_close(os); |
|
952 |
if (err != ESRCH) |
|
5367 | 953 |
goto out; |
2199 | 954 |
|
6975
c511f317869e
6717522 panic in dmu_objset_stats() due to freed objset_impl_t
maybee
parents:
6689
diff
changeset
|
955 |
rw_enter(&dd->dd_pool->dp_config_rwlock, RW_READER); |
c511f317869e
6717522 panic in dmu_objset_stats() due to freed objset_impl_t
maybee
parents:
6689
diff
changeset
|
956 |
err = dsl_dir_open_obj(dd->dd_pool, dd->dd_object, NULL, FTAG, &dd); |
c511f317869e
6717522 panic in dmu_objset_stats() due to freed objset_impl_t
maybee
parents:
6689
diff
changeset
|
957 |
rw_exit(&dd->dd_pool->dp_config_rwlock); |
c511f317869e
6717522 panic in dmu_objset_stats() due to freed objset_impl_t
maybee
parents:
6689
diff
changeset
|
958 |
|
c511f317869e
6717522 panic in dmu_objset_stats() due to freed objset_impl_t
maybee
parents:
6689
diff
changeset
|
959 |
if (err) |
c511f317869e
6717522 panic in dmu_objset_stats() due to freed objset_impl_t
maybee
parents:
6689
diff
changeset
|
960 |
goto out; |
c511f317869e
6717522 panic in dmu_objset_stats() due to freed objset_impl_t
maybee
parents:
6689
diff
changeset
|
961 |
|
5367 | 962 |
if (ds->ds_user_ptr) { |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
963 |
/* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
964 |
* We need to sync out all in-flight IO before we try |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
965 |
* to evict (the dataset evict func is trying to clear |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
966 |
* the cached entries for this dataset in the ARC). |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
967 |
*/ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
968 |
txg_wait_synced(dd->dd_pool, 0); |
5367 | 969 |
} |
970 |
||
2199 | 971 |
/* |
972 |
* Blow away the dsl_dir + head dataset. |
|
973 |
*/ |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
974 |
dsl_dataset_make_exclusive(ds, tag); |
6975
c511f317869e
6717522 panic in dmu_objset_stats() due to freed objset_impl_t
maybee
parents:
6689
diff
changeset
|
975 |
if (ds->ds_user_ptr) { |
c511f317869e
6717522 panic in dmu_objset_stats() due to freed objset_impl_t
maybee
parents:
6689
diff
changeset
|
976 |
ds->ds_user_evict_func(ds, ds->ds_user_ptr); |
c511f317869e
6717522 panic in dmu_objset_stats() due to freed objset_impl_t
maybee
parents:
6689
diff
changeset
|
977 |
ds->ds_user_ptr = NULL; |
c511f317869e
6717522 panic in dmu_objset_stats() due to freed objset_impl_t
maybee
parents:
6689
diff
changeset
|
978 |
} |
2199 | 979 |
dstg = dsl_sync_task_group_create(ds->ds_dir->dd_pool); |
980 |
dsl_sync_task_create(dstg, dsl_dataset_destroy_check, |
|
5367 | 981 |
dsl_dataset_destroy_sync, ds, tag, 0); |
2199 | 982 |
dsl_sync_task_create(dstg, dsl_dir_destroy_check, |
983 |
dsl_dir_destroy_sync, dd, FTAG, 0); |
|
984 |
err = dsl_sync_task_group_wait(dstg); |
|
985 |
dsl_sync_task_group_destroy(dstg); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
986 |
/* if it is successful, dsl_dir_destroy_sync will close the dd */ |
5367 | 987 |
if (err) |
2199 | 988 |
dsl_dir_close(dd, FTAG); |
5367 | 989 |
out: |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
990 |
dsl_dataset_disown(ds, tag); |
789 | 991 |
return (err); |
992 |
} |
|
993 |
||
994 |
int |
|
5367 | 995 |
dsl_dataset_rollback(dsl_dataset_t *ds, dmu_objset_type_t ost) |
789 | 996 |
{ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
997 |
ASSERT(ds->ds_owner); |
5367 | 998 |
|
2199 | 999 |
return (dsl_sync_task_do(ds->ds_dir->dd_pool, |
1000 |
dsl_dataset_rollback_check, dsl_dataset_rollback_sync, |
|
5367 | 1001 |
ds, &ost, 0)); |
789 | 1002 |
} |
1003 |
||
1004 |
void * |
|
1005 |
dsl_dataset_set_user_ptr(dsl_dataset_t *ds, |
|
1006 |
void *p, dsl_dataset_evict_func_t func) |
|
1007 |
{ |
|
1008 |
void *old; |
|
1009 |
||
1010 |
mutex_enter(&ds->ds_lock); |
|
1011 |
old = ds->ds_user_ptr; |
|
1012 |
if (old == NULL) { |
|
1013 |
ds->ds_user_ptr = p; |
|
1014 |
ds->ds_user_evict_func = func; |
|
1015 |
} |
|
1016 |
mutex_exit(&ds->ds_lock); |
|
1017 |
return (old); |
|
1018 |
} |
|
1019 |
||
1020 |
void * |
|
1021 |
dsl_dataset_get_user_ptr(dsl_dataset_t *ds) |
|
1022 |
{ |
|
1023 |
return (ds->ds_user_ptr); |
|
1024 |
} |
|
1025 |
||
1026 |
||
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
1027 |
blkptr_t * |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
1028 |
dsl_dataset_get_blkptr(dsl_dataset_t *ds) |
789 | 1029 |
{ |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
1030 |
return (&ds->ds_phys->ds_bp); |
789 | 1031 |
} |
1032 |
||
1033 |
void |
|
1034 |
dsl_dataset_set_blkptr(dsl_dataset_t *ds, blkptr_t *bp, dmu_tx_t *tx) |
|
1035 |
{ |
|
1036 |
ASSERT(dmu_tx_is_syncing(tx)); |
|
1037 |
/* If it's the meta-objset, set dp_meta_rootbp */ |
|
1038 |
if (ds == NULL) { |
|
1039 |
tx->tx_pool->dp_meta_rootbp = *bp; |
|
1040 |
} else { |
|
1041 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
|
1042 |
ds->ds_phys->ds_bp = *bp; |
|
1043 |
} |
|
1044 |
} |
|
1045 |
||
1046 |
spa_t * |
|
1047 |
dsl_dataset_get_spa(dsl_dataset_t *ds) |
|
1048 |
{ |
|
1049 |
return (ds->ds_dir->dd_pool->dp_spa); |
|
1050 |
} |
|
1051 |
||
1052 |
void |
|
1053 |
dsl_dataset_dirty(dsl_dataset_t *ds, dmu_tx_t *tx) |
|
1054 |
{ |
|
1055 |
dsl_pool_t *dp; |
|
1056 |
||
1057 |
if (ds == NULL) /* this is the meta-objset */ |
|
1058 |
return; |
|
1059 |
||
1060 |
ASSERT(ds->ds_user_ptr != NULL); |
|
2885 | 1061 |
|
1062 |
if (ds->ds_phys->ds_next_snap_obj != 0) |
|
1063 |
panic("dirtying snapshot!"); |
|
789 | 1064 |
|
1065 |
dp = ds->ds_dir->dd_pool; |
|
1066 |
||
1067 |
if (txg_list_add(&dp->dp_dirty_datasets, ds, tx->tx_txg) == 0) { |
|
1068 |
/* up the hold count until we can be written out */ |
|
1069 |
dmu_buf_add_ref(ds->ds_dbuf, ds); |
|
1070 |
} |
|
1071 |
} |
|
1072 |
||
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1073 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1074 |
* The unique space in the head dataset can be calculated by subtracting |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1075 |
* the space used in the most recent snapshot, that is still being used |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1076 |
* in this file system, from the space currently in use. To figure out |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1077 |
* the space in the most recent snapshot still in use, we need to take |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1078 |
* the total space used in the snapshot and subtract out the space that |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1079 |
* has been freed up since the snapshot was taken. |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1080 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1081 |
static void |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1082 |
dsl_dataset_recalc_head_uniq(dsl_dataset_t *ds) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1083 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1084 |
uint64_t mrs_used; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1085 |
uint64_t dlused, dlcomp, dluncomp; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1086 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1087 |
ASSERT(ds->ds_object == ds->ds_dir->dd_phys->dd_head_dataset_obj); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1088 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1089 |
if (ds->ds_phys->ds_prev_snap_obj != 0) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1090 |
mrs_used = ds->ds_prev->ds_phys->ds_used_bytes; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1091 |
else |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1092 |
mrs_used = 0; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1093 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1094 |
VERIFY(0 == bplist_space(&ds->ds_deadlist, &dlused, &dlcomp, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1095 |
&dluncomp)); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1096 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1097 |
ASSERT3U(dlused, <=, mrs_used); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1098 |
ds->ds_phys->ds_unique_bytes = |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1099 |
ds->ds_phys->ds_used_bytes - (mrs_used - dlused); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1100 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1101 |
if (!DS_UNIQUE_IS_ACCURATE(ds) && |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1102 |
spa_version(ds->ds_dir->dd_pool->dp_spa) >= |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1103 |
SPA_VERSION_UNIQUE_ACCURATE) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1104 |
ds->ds_phys->ds_flags |= DS_FLAG_UNIQUE_ACCURATE; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1105 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1106 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1107 |
static uint64_t |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1108 |
dsl_dataset_unique(dsl_dataset_t *ds) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1109 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1110 |
if (!DS_UNIQUE_IS_ACCURATE(ds) && !dsl_dataset_is_snapshot(ds)) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1111 |
dsl_dataset_recalc_head_uniq(ds); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1112 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1113 |
return (ds->ds_phys->ds_unique_bytes); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1114 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1115 |
|
789 | 1116 |
struct killarg { |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1117 |
int64_t *usedp; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1118 |
int64_t *compressedp; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1119 |
int64_t *uncompressedp; |
789 | 1120 |
zio_t *zio; |
1121 |
dmu_tx_t *tx; |
|
1122 |
}; |
|
1123 |
||
1124 |
static int |
|
1125 |
kill_blkptr(traverse_blk_cache_t *bc, spa_t *spa, void *arg) |
|
1126 |
{ |
|
1127 |
struct killarg *ka = arg; |
|
1128 |
blkptr_t *bp = &bc->bc_blkptr; |
|
1129 |
||
1130 |
ASSERT3U(bc->bc_errno, ==, 0); |
|
1131 |
||
1132 |
/* |
|
1133 |
* Since this callback is not called concurrently, no lock is |
|
1134 |
* needed on the accounting values. |
|
1135 |
*/ |
|
2082 | 1136 |
*ka->usedp += bp_get_dasize(spa, bp); |
789 | 1137 |
*ka->compressedp += BP_GET_PSIZE(bp); |
1138 |
*ka->uncompressedp += BP_GET_UCSIZE(bp); |
|
1139 |
/* XXX check for EIO? */ |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1140 |
(void) dsl_free(ka->zio, spa_get_dsl(spa), ka->tx->tx_txg, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1141 |
bp, NULL, NULL, ARC_NOWAIT); |
789 | 1142 |
return (0); |
1143 |
} |
|
1144 |
||
1145 |
/* ARGSUSED */ |
|
2199 | 1146 |
static int |
1147 |
dsl_dataset_rollback_check(void *arg1, void *arg2, dmu_tx_t *tx) |
|
789 | 1148 |
{ |
2199 | 1149 |
dsl_dataset_t *ds = arg1; |
5367 | 1150 |
dmu_objset_type_t *ost = arg2; |
789 | 1151 |
|
2199 | 1152 |
/* |
5367 | 1153 |
* We can only roll back to emptyness if it is a ZPL objset. |
2199 | 1154 |
*/ |
5367 | 1155 |
if (*ost != DMU_OST_ZFS && ds->ds_phys->ds_prev_snap_txg == 0) |
789 | 1156 |
return (EINVAL); |
1157 |
||
2199 | 1158 |
/* |
1159 |
* This must not be a snapshot. |
|
1160 |
*/ |
|
1161 |
if (ds->ds_phys->ds_next_snap_obj != 0) |
|
1162 |
return (EINVAL); |
|
789 | 1163 |
|
1164 |
/* |
|
1165 |
* If we made changes this txg, traverse_dsl_dataset won't find |
|
1166 |
* them. Try again. |
|
1167 |
*/ |
|
2199 | 1168 |
if (ds->ds_phys->ds_bp.blk_birth >= tx->tx_txg) |
789 | 1169 |
return (EAGAIN); |
2199 | 1170 |
|
1171 |
return (0); |
|
1172 |
} |
|
789 | 1173 |
|
2199 | 1174 |
/* ARGSUSED */ |
1175 |
static void |
|
4543 | 1176 |
dsl_dataset_rollback_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) |
2199 | 1177 |
{ |
1178 |
dsl_dataset_t *ds = arg1; |
|
5367 | 1179 |
dmu_objset_type_t *ost = arg2; |
2199 | 1180 |
objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset; |
789 | 1181 |
|
1182 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
|
1183 |
||
4967
8d0de61ff354
6597381 BAD TRAP: type=e (#pf Page fault) rp=ffffff00043a48f0 addr=28 occurred in module "<unknown>" due to
perrin
parents:
4935
diff
changeset
|
1184 |
/* |
8d0de61ff354
6597381 BAD TRAP: type=e (#pf Page fault) rp=ffffff00043a48f0 addr=28 occurred in module "<unknown>" due to
perrin
parents:
4935
diff
changeset
|
1185 |
* Before the roll back destroy the zil. |
8d0de61ff354
6597381 BAD TRAP: type=e (#pf Page fault) rp=ffffff00043a48f0 addr=28 occurred in module "<unknown>" due to
perrin
parents:
4935
diff
changeset
|
1186 |
*/ |
8d0de61ff354
6597381 BAD TRAP: type=e (#pf Page fault) rp=ffffff00043a48f0 addr=28 occurred in module "<unknown>" due to
perrin
parents:
4935
diff
changeset
|
1187 |
if (ds->ds_user_ptr != NULL) { |
8d0de61ff354
6597381 BAD TRAP: type=e (#pf Page fault) rp=ffffff00043a48f0 addr=28 occurred in module "<unknown>" due to
perrin
parents:
4935
diff
changeset
|
1188 |
zil_rollback_destroy( |
8d0de61ff354
6597381 BAD TRAP: type=e (#pf Page fault) rp=ffffff00043a48f0 addr=28 occurred in module "<unknown>" due to
perrin
parents:
4935
diff
changeset
|
1189 |
((objset_impl_t *)ds->ds_user_ptr)->os_zil, tx); |
5367 | 1190 |
|
1191 |
/* |
|
1192 |
* We need to make sure that the objset_impl_t is reopened after |
|
1193 |
* we do the rollback, otherwise it will have the wrong |
|
1194 |
* objset_phys_t. Normally this would happen when this |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1195 |
* dataset-open is closed, thus causing the |
5367 | 1196 |
* dataset to be immediately evicted. But when doing "zfs recv |
1197 |
* -F", we reopen the objset before that, so that there is no |
|
1198 |
* window where the dataset is closed and inconsistent. |
|
1199 |
*/ |
|
1200 |
ds->ds_user_evict_func(ds, ds->ds_user_ptr); |
|
1201 |
ds->ds_user_ptr = NULL; |
|
4967
8d0de61ff354
6597381 BAD TRAP: type=e (#pf Page fault) rp=ffffff00043a48f0 addr=28 occurred in module "<unknown>" due to
perrin
parents:
4935
diff
changeset
|
1202 |
} |
4935
c80bf0e6f4aa
6534949 Stale need for range locking comment in zvol.c
perrin
parents:
4787
diff
changeset
|
1203 |
|
789 | 1204 |
/* Zero out the deadlist. */ |
1205 |
bplist_close(&ds->ds_deadlist); |
|
1206 |
bplist_destroy(mos, ds->ds_phys->ds_deadlist_obj, tx); |
|
1207 |
ds->ds_phys->ds_deadlist_obj = |
|
1208 |
bplist_create(mos, DSL_DEADLIST_BLOCKSIZE, tx); |
|
1544 | 1209 |
VERIFY(0 == bplist_open(&ds->ds_deadlist, mos, |
1210 |
ds->ds_phys->ds_deadlist_obj)); |
|
789 | 1211 |
|
1212 |
{ |
|
1213 |
/* Free blkptrs that we gave birth to */ |
|
1214 |
zio_t *zio; |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1215 |
int64_t used = 0, compressed = 0, uncompressed = 0; |
789 | 1216 |
struct killarg ka; |
5518
85721e07d1fa
6630707 assertion failed: used >= 0 || dd->dd_used_bytes >= -used, file: dsl_dir.c, line: 904
ck153898
parents:
5481
diff
changeset
|
1217 |
int64_t delta; |
789 | 1218 |
|
1219 |
zio = zio_root(tx->tx_pool->dp_spa, NULL, NULL, |
|
1220 |
ZIO_FLAG_MUSTSUCCEED); |
|
1221 |
ka.usedp = &used; |
|
1222 |
ka.compressedp = &compressed; |
|
1223 |
ka.uncompressedp = &uncompressed; |
|
1224 |
ka.zio = zio; |
|
1225 |
ka.tx = tx; |
|
1226 |
(void) traverse_dsl_dataset(ds, ds->ds_phys->ds_prev_snap_txg, |
|
1227 |
ADVANCE_POST, kill_blkptr, &ka); |
|
1228 |
(void) zio_wait(zio); |
|
1229 |
||
5518
85721e07d1fa
6630707 assertion failed: used >= 0 || dd->dd_used_bytes >= -used, file: dsl_dir.c, line: 904
ck153898
parents:
5481
diff
changeset
|
1230 |
/* only deduct space beyond any refreservation */ |
85721e07d1fa
6630707 assertion failed: used >= 0 || dd->dd_used_bytes >= -used, file: dsl_dir.c, line: 904
ck153898
parents:
5481
diff
changeset
|
1231 |
delta = parent_delta(ds, -used); |
2199 | 1232 |
dsl_dir_diduse_space(ds->ds_dir, |
5518
85721e07d1fa
6630707 assertion failed: used >= 0 || dd->dd_used_bytes >= -used, file: dsl_dir.c, line: 904
ck153898
parents:
5481
diff
changeset
|
1233 |
delta, -compressed, -uncompressed, tx); |
789 | 1234 |
} |
1235 |
||
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1236 |
if (ds->ds_prev && ds->ds_prev != ds->ds_dir->dd_pool->dp_origin_snap) { |
5367 | 1237 |
/* Change our contents to that of the prev snapshot */ |
1238 |
ASSERT3U(ds->ds_prev->ds_object, ==, |
|
1239 |
ds->ds_phys->ds_prev_snap_obj); |
|
1240 |
ds->ds_phys->ds_bp = ds->ds_prev->ds_phys->ds_bp; |
|
1241 |
ds->ds_phys->ds_used_bytes = |
|
1242 |
ds->ds_prev->ds_phys->ds_used_bytes; |
|
1243 |
ds->ds_phys->ds_compressed_bytes = |
|
1244 |
ds->ds_prev->ds_phys->ds_compressed_bytes; |
|
1245 |
ds->ds_phys->ds_uncompressed_bytes = |
|
1246 |
ds->ds_prev->ds_phys->ds_uncompressed_bytes; |
|
1247 |
ds->ds_phys->ds_flags = ds->ds_prev->ds_phys->ds_flags; |
|
1248 |
ds->ds_phys->ds_unique_bytes = 0; |
|
789 | 1249 |
|
5367 | 1250 |
if (ds->ds_prev->ds_phys->ds_next_snap_obj == ds->ds_object) { |
1251 |
dmu_buf_will_dirty(ds->ds_prev->ds_dbuf, tx); |
|
1252 |
ds->ds_prev->ds_phys->ds_unique_bytes = 0; |
|
1253 |
} |
|
1254 |
} else { |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1255 |
objset_impl_t *osi; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1256 |
|
5367 | 1257 |
/* Zero out our contents, recreate objset */ |
1258 |
bzero(&ds->ds_phys->ds_bp, sizeof (blkptr_t)); |
|
1259 |
ds->ds_phys->ds_used_bytes = 0; |
|
1260 |
ds->ds_phys->ds_compressed_bytes = 0; |
|
1261 |
ds->ds_phys->ds_uncompressed_bytes = 0; |
|
1262 |
ds->ds_phys->ds_flags = 0; |
|
1263 |
ds->ds_phys->ds_unique_bytes = 0; |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1264 |
osi = dmu_objset_create_impl(ds->ds_dir->dd_pool->dp_spa, ds, |
5367 | 1265 |
&ds->ds_phys->ds_bp, *ost, tx); |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1266 |
#ifdef _KERNEL |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1267 |
zfs_create_fs(&osi->os, kcred, NULL, tx); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1268 |
#endif |
2532
752725c22841
6448999 panic: used == ds->ds_phys->ds_unique_bytes
ahrens
parents:
2417
diff
changeset
|
1269 |
} |
4543 | 1270 |
|
1271 |
spa_history_internal_log(LOG_DS_ROLLBACK, ds->ds_dir->dd_pool->dp_spa, |
|
1272 |
tx, cr, "dataset = %llu", ds->ds_object); |
|
789 | 1273 |
} |
1274 |
||
1731
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1275 |
/* ARGSUSED */ |
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1276 |
static int |
2199 | 1277 |
dsl_dataset_destroy_begin_check(void *arg1, void *arg2, dmu_tx_t *tx) |
1731
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1278 |
{ |
2199 | 1279 |
dsl_dataset_t *ds = arg1; |
5367 | 1280 |
objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset; |
1281 |
uint64_t count; |
|
1282 |
int err; |
|
1731
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1283 |
|
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1284 |
/* |
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1285 |
* Can't delete a head dataset if there are snapshots of it. |
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1286 |
* (Except if the only snapshots are from the branch we cloned |
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1287 |
* from.) |
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1288 |
*/ |
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1289 |
if (ds->ds_prev != NULL && |
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1290 |
ds->ds_prev->ds_phys->ds_next_snap_obj == ds->ds_object) |
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1291 |
return (EINVAL); |
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1292 |
|
5367 | 1293 |
/* |
1294 |
* This is really a dsl_dir thing, but check it here so that |
|
1295 |
* we'll be less likely to leave this dataset inconsistent & |
|
1296 |
* nearly destroyed. |
|
1297 |
*/ |
|
1298 |
err = zap_count(mos, ds->ds_dir->dd_phys->dd_child_dir_zapobj, &count); |
|
1299 |
if (err) |
|
1300 |
return (err); |
|
1301 |
if (count != 0) |
|
1302 |
return (EEXIST); |
|
1303 |
||
1731
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1304 |
return (0); |
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1305 |
} |
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1306 |
|
2199 | 1307 |
/* ARGSUSED */ |
1308 |
static void |
|
4543 | 1309 |
dsl_dataset_destroy_begin_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) |
789 | 1310 |
{ |
2199 | 1311 |
dsl_dataset_t *ds = arg1; |
4543 | 1312 |
dsl_pool_t *dp = ds->ds_dir->dd_pool; |
789 | 1313 |
|
2199 | 1314 |
/* Mark it as inconsistent on-disk, in case we crash */ |
1315 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
|
1316 |
ds->ds_phys->ds_flags |= DS_FLAG_INCONSISTENT; |
|
4543 | 1317 |
|
1318 |
spa_history_internal_log(LOG_DS_DESTROY_BEGIN, dp->dp_spa, tx, |
|
1319 |
cr, "dataset = %llu", ds->ds_object); |
|
2199 | 1320 |
} |
789 | 1321 |
|
2199 | 1322 |
/* ARGSUSED */ |
5367 | 1323 |
int |
2199 | 1324 |
dsl_dataset_destroy_check(void *arg1, void *arg2, dmu_tx_t *tx) |
1325 |
{ |
|
1326 |
dsl_dataset_t *ds = arg1; |
|
789 | 1327 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1328 |
/* we have an owner hold, so noone else can destroy us */ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1329 |
ASSERT(!DSL_DATASET_IS_DESTROYED(ds)); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1330 |
|
789 | 1331 |
/* Can't delete a branch point. */ |
2199 | 1332 |
if (ds->ds_phys->ds_num_children > 1) |
1333 |
return (EEXIST); |
|
789 | 1334 |
|
1335 |
/* |
|
1336 |
* Can't delete a head dataset if there are snapshots of it. |
|
1337 |
* (Except if the only snapshots are from the branch we cloned |
|
1338 |
* from.) |
|
1339 |
*/ |
|
1340 |
if (ds->ds_prev != NULL && |
|
2199 | 1341 |
ds->ds_prev->ds_phys->ds_next_snap_obj == ds->ds_object) |
789 | 1342 |
return (EINVAL); |
1343 |
||
1344 |
/* |
|
1345 |
* If we made changes this txg, traverse_dsl_dataset won't find |
|
1346 |
* them. Try again. |
|
1347 |
*/ |
|
2199 | 1348 |
if (ds->ds_phys->ds_bp.blk_birth >= tx->tx_txg) |
789 | 1349 |
return (EAGAIN); |
2199 | 1350 |
|
1351 |
/* XXX we should do some i/o error checking... */ |
|
1352 |
return (0); |
|
1353 |
} |
|
1354 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1355 |
struct refsarg { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1356 |
kmutex_t lock; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1357 |
boolean_t gone; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1358 |
kcondvar_t cv; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1359 |
}; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1360 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1361 |
/* ARGSUSED */ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1362 |
static void |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1363 |
dsl_dataset_refs_gone(dmu_buf_t *db, void *argv) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1364 |
{ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1365 |
struct refsarg *arg = argv; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1366 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1367 |
mutex_enter(&arg->lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1368 |
arg->gone = TRUE; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1369 |
cv_signal(&arg->cv); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1370 |
mutex_exit(&arg->lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1371 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1372 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1373 |
static void |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1374 |
dsl_dataset_drain_refs(dsl_dataset_t *ds, void *tag) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1375 |
{ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1376 |
struct refsarg arg; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1377 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1378 |
mutex_init(&arg.lock, NULL, MUTEX_DEFAULT, NULL); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1379 |
cv_init(&arg.cv, NULL, CV_DEFAULT, NULL); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1380 |
arg.gone = FALSE; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1381 |
(void) dmu_buf_update_user(ds->ds_dbuf, ds, &arg, &ds->ds_phys, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1382 |
dsl_dataset_refs_gone); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1383 |
dmu_buf_rele(ds->ds_dbuf, tag); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1384 |
mutex_enter(&arg.lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1385 |
while (!arg.gone) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1386 |
cv_wait(&arg.cv, &arg.lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1387 |
ASSERT(arg.gone); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1388 |
mutex_exit(&arg.lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1389 |
ds->ds_dbuf = NULL; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1390 |
ds->ds_phys = NULL; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1391 |
mutex_destroy(&arg.lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1392 |
cv_destroy(&arg.cv); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1393 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1394 |
|
5367 | 1395 |
void |
4543 | 1396 |
dsl_dataset_destroy_sync(void *arg1, void *tag, cred_t *cr, dmu_tx_t *tx) |
2199 | 1397 |
{ |
1398 |
dsl_dataset_t *ds = arg1; |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1399 |
int64_t used = 0, compressed = 0, uncompressed = 0; |
2199 | 1400 |
zio_t *zio; |
1401 |
int err; |
|
1402 |
int after_branch_point = FALSE; |
|
1403 |
dsl_pool_t *dp = ds->ds_dir->dd_pool; |
|
1404 |
objset_t *mos = dp->dp_meta_objset; |
|
1405 |
dsl_dataset_t *ds_prev = NULL; |
|
1406 |
uint64_t obj; |
|
1407 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1408 |
ASSERT(ds->ds_owner); |
2199 | 1409 |
ASSERT3U(ds->ds_phys->ds_num_children, <=, 1); |
1410 |
ASSERT(ds->ds_prev == NULL || |
|
1411 |
ds->ds_prev->ds_phys->ds_next_snap_obj != ds->ds_object); |
|
1412 |
ASSERT3U(ds->ds_phys->ds_bp.blk_birth, <=, tx->tx_txg); |
|
1413 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1414 |
/* signal any waiters that this dataset is going away */ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1415 |
mutex_enter(&ds->ds_lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1416 |
ds->ds_owner = dsl_reaper; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1417 |
cv_broadcast(&ds->ds_exclusive_cv); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1418 |
mutex_exit(&ds->ds_lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1419 |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1420 |
/* Remove our reservation */ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1421 |
if (ds->ds_reserved != 0) { |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1422 |
uint64_t val = 0; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1423 |
dsl_dataset_set_reservation_sync(ds, &val, cr, tx); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1424 |
ASSERT3U(ds->ds_reserved, ==, 0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1425 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1426 |
|
2199 | 1427 |
ASSERT(RW_WRITE_HELD(&dp->dp_config_rwlock)); |
1428 |
||
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1429 |
dsl_pool_ds_destroyed(ds, tx); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1430 |
|
2199 | 1431 |
obj = ds->ds_object; |
789 | 1432 |
|
1433 |
if (ds->ds_phys->ds_prev_snap_obj != 0) { |
|
1434 |
if (ds->ds_prev) { |
|
1435 |
ds_prev = ds->ds_prev; |
|
1436 |
} else { |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1437 |
VERIFY(0 == dsl_dataset_hold_obj(dp, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1438 |
ds->ds_phys->ds_prev_snap_obj, FTAG, &ds_prev)); |
789 | 1439 |
} |
1440 |
after_branch_point = |
|
1441 |
(ds_prev->ds_phys->ds_next_snap_obj != obj); |
|
1442 |
||
1443 |
dmu_buf_will_dirty(ds_prev->ds_dbuf, tx); |
|
1444 |
if (after_branch_point && |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1445 |
ds_prev->ds_phys->ds_next_clones_obj != 0) { |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1446 |
VERIFY(0 == zap_remove_int(mos, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1447 |
ds_prev->ds_phys->ds_next_clones_obj, obj, tx)); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1448 |
if (ds->ds_phys->ds_next_snap_obj != 0) { |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1449 |
VERIFY(0 == zap_add_int(mos, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1450 |
ds_prev->ds_phys->ds_next_clones_obj, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1451 |
ds->ds_phys->ds_next_snap_obj, tx)); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1452 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1453 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1454 |
if (after_branch_point && |
789 | 1455 |
ds->ds_phys->ds_next_snap_obj == 0) { |
1456 |
/* This clone is toast. */ |
|
1457 |
ASSERT(ds_prev->ds_phys->ds_num_children > 1); |
|
1458 |
ds_prev->ds_phys->ds_num_children--; |
|
1459 |
} else if (!after_branch_point) { |
|
1460 |
ds_prev->ds_phys->ds_next_snap_obj = |
|
1461 |
ds->ds_phys->ds_next_snap_obj; |
|
1462 |
} |
|
1463 |
} |
|
1464 |
||
1465 |
zio = zio_root(dp->dp_spa, NULL, NULL, ZIO_FLAG_MUSTSUCCEED); |
|
1466 |
||
1467 |
if (ds->ds_phys->ds_next_snap_obj != 0) { |
|
2199 | 1468 |
blkptr_t bp; |
789 | 1469 |
dsl_dataset_t *ds_next; |
1470 |
uint64_t itor = 0; |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1471 |
uint64_t old_unique; |
789 | 1472 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1473 |
VERIFY(0 == dsl_dataset_hold_obj(dp, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1474 |
ds->ds_phys->ds_next_snap_obj, FTAG, &ds_next)); |
789 | 1475 |
ASSERT3U(ds_next->ds_phys->ds_prev_snap_obj, ==, obj); |
1476 |
||
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1477 |
old_unique = dsl_dataset_unique(ds_next); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1478 |
|
789 | 1479 |
dmu_buf_will_dirty(ds_next->ds_dbuf, tx); |
1480 |
ds_next->ds_phys->ds_prev_snap_obj = |
|
1481 |
ds->ds_phys->ds_prev_snap_obj; |
|
1482 |
ds_next->ds_phys->ds_prev_snap_txg = |
|
1483 |
ds->ds_phys->ds_prev_snap_txg; |
|
1484 |
ASSERT3U(ds->ds_phys->ds_prev_snap_txg, ==, |
|
1485 |
ds_prev ? ds_prev->ds_phys->ds_creation_txg : 0); |
|
1486 |
||
1487 |
/* |
|
1488 |
* Transfer to our deadlist (which will become next's |
|
1489 |
* new deadlist) any entries from next's current |
|
1490 |
* deadlist which were born before prev, and free the |
|
1491 |
* other entries. |
|
1492 |
* |
|
1493 |
* XXX we're doing this long task with the config lock held |
|
1494 |
*/ |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1495 |
while (bplist_iterate(&ds_next->ds_deadlist, &itor, &bp) == 0) { |
789 | 1496 |
if (bp.blk_birth <= ds->ds_phys->ds_prev_snap_txg) { |
1544 | 1497 |
VERIFY(0 == bplist_enqueue(&ds->ds_deadlist, |
1498 |
&bp, tx)); |
|
789 | 1499 |
if (ds_prev && !after_branch_point && |
1500 |
bp.blk_birth > |
|
1501 |
ds_prev->ds_phys->ds_prev_snap_txg) { |
|
1502 |
ds_prev->ds_phys->ds_unique_bytes += |
|
2082 | 1503 |
bp_get_dasize(dp->dp_spa, &bp); |
789 | 1504 |
} |
1505 |
} else { |
|
2082 | 1506 |
used += bp_get_dasize(dp->dp_spa, &bp); |
789 | 1507 |
compressed += BP_GET_PSIZE(&bp); |
1508 |
uncompressed += BP_GET_UCSIZE(&bp); |
|
1509 |
/* XXX check return value? */ |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1510 |
(void) dsl_free(zio, dp, tx->tx_txg, |
789 | 1511 |
&bp, NULL, NULL, ARC_NOWAIT); |
1512 |
} |
|
1513 |
} |
|
1514 |
||
1515 |
/* free next's deadlist */ |
|
1516 |
bplist_close(&ds_next->ds_deadlist); |
|
1517 |
bplist_destroy(mos, ds_next->ds_phys->ds_deadlist_obj, tx); |
|
1518 |
||
1519 |
/* set next's deadlist to our deadlist */ |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1520 |
bplist_close(&ds->ds_deadlist); |
789 | 1521 |
ds_next->ds_phys->ds_deadlist_obj = |
1522 |
ds->ds_phys->ds_deadlist_obj; |
|
1544 | 1523 |
VERIFY(0 == bplist_open(&ds_next->ds_deadlist, mos, |
1524 |
ds_next->ds_phys->ds_deadlist_obj)); |
|
789 | 1525 |
ds->ds_phys->ds_deadlist_obj = 0; |
1526 |
||
1527 |
if (ds_next->ds_phys->ds_next_snap_obj != 0) { |
|
1528 |
/* |
|
1529 |
* Update next's unique to include blocks which |
|
1530 |
* were previously shared by only this snapshot |
|
1531 |
* and it. Those blocks will be born after the |
|
1532 |
* prev snap and before this snap, and will have |
|
1533 |
* died after the next snap and before the one |
|
1534 |
* after that (ie. be on the snap after next's |
|
1535 |
* deadlist). |
|
1536 |
* |
|
1537 |
* XXX we're doing this long task with the |
|
1538 |
* config lock held |
|
1539 |
*/ |
|
1540 |
dsl_dataset_t *ds_after_next; |
|
1541 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1542 |
VERIFY(0 == dsl_dataset_hold_obj(dp, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1543 |
ds_next->ds_phys->ds_next_snap_obj, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1544 |
FTAG, &ds_after_next)); |
789 | 1545 |
itor = 0; |
1546 |
while (bplist_iterate(&ds_after_next->ds_deadlist, |
|
1547 |
&itor, &bp) == 0) { |
|
1548 |
if (bp.blk_birth > |
|
1549 |
ds->ds_phys->ds_prev_snap_txg && |
|
1550 |
bp.blk_birth <= |
|
1551 |
ds->ds_phys->ds_creation_txg) { |
|
1552 |
ds_next->ds_phys->ds_unique_bytes += |
|
2082 | 1553 |
bp_get_dasize(dp->dp_spa, &bp); |
789 | 1554 |
} |
1555 |
} |
|
1556 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1557 |
dsl_dataset_rele(ds_after_next, FTAG); |
789 | 1558 |
ASSERT3P(ds_next->ds_prev, ==, NULL); |
1559 |
} else { |
|
1560 |
ASSERT3P(ds_next->ds_prev, ==, ds); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1561 |
dsl_dataset_drop_ref(ds_next->ds_prev, ds_next); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1562 |
ds_next->ds_prev = NULL; |
789 | 1563 |
if (ds_prev) { |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1564 |
VERIFY(0 == dsl_dataset_get_ref(dp, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1565 |
ds->ds_phys->ds_prev_snap_obj, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1566 |
ds_next, &ds_next->ds_prev)); |
789 | 1567 |
} |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1568 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1569 |
dsl_dataset_recalc_head_uniq(ds_next); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1570 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1571 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1572 |
* Reduce the amount of our unconsmed refreservation |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1573 |
* being charged to our parent by the amount of |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1574 |
* new unique data we have gained. |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1575 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1576 |
if (old_unique < ds_next->ds_reserved) { |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1577 |
int64_t mrsdelta; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1578 |
uint64_t new_unique = |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1579 |
ds_next->ds_phys->ds_unique_bytes; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1580 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1581 |
ASSERT(old_unique <= new_unique); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1582 |
mrsdelta = MIN(new_unique - old_unique, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1583 |
ds_next->ds_reserved - old_unique); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1584 |
dsl_dir_diduse_space(ds->ds_dir, -mrsdelta, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1585 |
0, 0, tx); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1586 |
} |
789 | 1587 |
} |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1588 |
dsl_dataset_rele(ds_next, FTAG); |
789 | 1589 |
|
1590 |
/* |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1591 |
* NB: unique_bytes might not be accurate for the head objset. |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1592 |
* Before SPA_VERSION 9, we didn't update its value when we |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1593 |
* deleted the most recent snapshot. |
789 | 1594 |
*/ |
1595 |
ASSERT3U(used, ==, ds->ds_phys->ds_unique_bytes); |
|
1596 |
} else { |
|
1597 |
/* |
|
1598 |
* There's no next snapshot, so this is a head dataset. |
|
1599 |
* Destroy the deadlist. Unless it's a clone, the |
|
1600 |
* deadlist should be empty. (If it's a clone, it's |
|
1601 |
* safe to ignore the deadlist contents.) |
|
1602 |
*/ |
|
1603 |
struct killarg ka; |
|
1604 |
||
1605 |
ASSERT(after_branch_point || bplist_empty(&ds->ds_deadlist)); |
|
1606 |
bplist_close(&ds->ds_deadlist); |
|
1607 |
bplist_destroy(mos, ds->ds_phys->ds_deadlist_obj, tx); |
|
1608 |
ds->ds_phys->ds_deadlist_obj = 0; |
|
1609 |
||
1610 |
/* |
|
1611 |
* Free everything that we point to (that's born after |
|
1612 |
* the previous snapshot, if we are a clone) |
|
1613 |
* |
|
1614 |
* XXX we're doing this long task with the config lock held |
|
1615 |
*/ |
|
1616 |
ka.usedp = &used; |
|
1617 |
ka.compressedp = &compressed; |
|
1618 |
ka.uncompressedp = &uncompressed; |
|
1619 |
ka.zio = zio; |
|
1620 |
ka.tx = tx; |
|
1621 |
err = traverse_dsl_dataset(ds, ds->ds_phys->ds_prev_snap_txg, |
|
1622 |
ADVANCE_POST, kill_blkptr, &ka); |
|
1623 |
ASSERT3U(err, ==, 0); |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1624 |
ASSERT(spa_version(dp->dp_spa) < |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1625 |
SPA_VERSION_UNIQUE_ACCURATE || |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1626 |
used == ds->ds_phys->ds_unique_bytes); |
789 | 1627 |
} |
1628 |
||
1629 |
err = zio_wait(zio); |
|
1630 |
ASSERT3U(err, ==, 0); |
|
1631 |
||
2199 | 1632 |
dsl_dir_diduse_space(ds->ds_dir, -used, -compressed, -uncompressed, tx); |
789 | 1633 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1634 |
if (ds->ds_dir->dd_phys->dd_head_dataset_obj == ds->ds_object) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1635 |
/* Erase the link in the dir */ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1636 |
dmu_buf_will_dirty(ds->ds_dir->dd_dbuf, tx); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1637 |
ds->ds_dir->dd_phys->dd_head_dataset_obj = 0; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1638 |
ASSERT(ds->ds_phys->ds_snapnames_zapobj != 0); |
789 | 1639 |
err = zap_destroy(mos, ds->ds_phys->ds_snapnames_zapobj, tx); |
1640 |
ASSERT(err == 0); |
|
1641 |
} else { |
|
1642 |
/* remove from snapshot namespace */ |
|
1643 |
dsl_dataset_t *ds_head; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1644 |
ASSERT(ds->ds_phys->ds_snapnames_zapobj == 0); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1645 |
VERIFY(0 == dsl_dataset_hold_obj(dp, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1646 |
ds->ds_dir->dd_phys->dd_head_dataset_obj, FTAG, &ds_head)); |
2207
47efcb3433a7
6439370 assertion failures possible in dsl_dataset_destroy_sync()
ahrens
parents:
2199
diff
changeset
|
1647 |
VERIFY(0 == dsl_dataset_get_snapname(ds)); |
789 | 1648 |
#ifdef ZFS_DEBUG |
1649 |
{ |
|
1650 |
uint64_t val; |
|
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
1651 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1652 |
err = dsl_dataset_snap_lookup(ds_head, |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
1653 |
ds->ds_snapname, &val); |
789 | 1654 |
ASSERT3U(err, ==, 0); |
1655 |
ASSERT3U(val, ==, obj); |
|
1656 |
} |
|
1657 |
#endif |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1658 |
err = dsl_dataset_snap_remove(ds_head, ds->ds_snapname, tx); |
789 | 1659 |
ASSERT(err == 0); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1660 |
dsl_dataset_rele(ds_head, FTAG); |
789 | 1661 |
} |
1662 |
||
1663 |
if (ds_prev && ds->ds_prev != ds_prev) |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1664 |
dsl_dataset_rele(ds_prev, FTAG); |
789 | 1665 |
|
5094 | 1666 |
spa_prop_clear_bootfs(dp->dp_spa, ds->ds_object, tx); |
4543 | 1667 |
spa_history_internal_log(LOG_DS_DESTROY, dp->dp_spa, tx, |
1668 |
cr, "dataset = %llu", ds->ds_object); |
|
1669 |
||
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1670 |
if (ds->ds_phys->ds_next_clones_obj != 0) { |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1671 |
uint64_t count; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1672 |
ASSERT(0 == zap_count(mos, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1673 |
ds->ds_phys->ds_next_clones_obj, &count) && count == 0); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1674 |
VERIFY(0 == dmu_object_free(mos, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1675 |
ds->ds_phys->ds_next_clones_obj, tx)); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1676 |
} |
7265 | 1677 |
if (ds->ds_phys->ds_props_obj != 0) { |
1678 |
VERIFY(0 == zap_destroy(mos, |
|
1679 |
ds->ds_phys->ds_props_obj, tx)); |
|
1680 |
} |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1681 |
dsl_dir_close(ds->ds_dir, ds); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1682 |
ds->ds_dir = NULL; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1683 |
dsl_dataset_drain_refs(ds, tag); |
2199 | 1684 |
VERIFY(0 == dmu_object_free(mos, obj, tx)); |
1685 |
} |
|
1686 |
||
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1687 |
static int |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1688 |
dsl_dataset_snapshot_reserve_space(dsl_dataset_t *ds, dmu_tx_t *tx) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1689 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1690 |
uint64_t asize; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1691 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1692 |
if (!dmu_tx_is_syncing(tx)) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1693 |
return (0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1694 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1695 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1696 |
* If there's an fs-only reservation, any blocks that might become |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1697 |
* owned by the snapshot dataset must be accommodated by space |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1698 |
* outside of the reservation. |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1699 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1700 |
asize = MIN(dsl_dataset_unique(ds), ds->ds_reserved); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1701 |
if (asize > dsl_dir_space_available(ds->ds_dir, NULL, 0, FALSE)) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1702 |
return (ENOSPC); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1703 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1704 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1705 |
* Propogate any reserved space for this snapshot to other |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1706 |
* snapshot checks in this sync group. |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1707 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1708 |
if (asize > 0) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1709 |
dsl_dir_willuse_space(ds->ds_dir, asize, tx); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1710 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1711 |
return (0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1712 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1713 |
|
2199 | 1714 |
/* ARGSUSED */ |
1715 |
int |
|
1716 |
dsl_dataset_snapshot_check(void *arg1, void *arg2, dmu_tx_t *tx) |
|
1717 |
{ |
|
5367 | 1718 |
dsl_dataset_t *ds = arg1; |
2199 | 1719 |
const char *snapname = arg2; |
1720 |
int err; |
|
1721 |
uint64_t value; |
|
789 | 1722 |
|
1723 |
/* |
|
2199 | 1724 |
* We don't allow multiple snapshots of the same txg. If there |
1725 |
* is already one, try again. |
|
1726 |
*/ |
|
1727 |
if (ds->ds_phys->ds_prev_snap_txg >= tx->tx_txg) |
|
1728 |
return (EAGAIN); |
|
1729 |
||
1730 |
/* |
|
1731 |
* Check for conflicting name snapshot name. |
|
789 | 1732 |
*/ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1733 |
err = dsl_dataset_snap_lookup(ds, snapname, &value); |
2199 | 1734 |
if (err == 0) |
1735 |
return (EEXIST); |
|
1736 |
if (err != ENOENT) |
|
1737 |
return (err); |
|
789 | 1738 |
|
3978
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
1739 |
/* |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
1740 |
* Check that the dataset's name is not too long. Name consists |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
1741 |
* of the dataset's length + 1 for the @-sign + snapshot name's length |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
1742 |
*/ |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
1743 |
if (dsl_dataset_namelen(ds) + 1 + strlen(snapname) >= MAXNAMELEN) |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
1744 |
return (ENAMETOOLONG); |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
1745 |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1746 |
err = dsl_dataset_snapshot_reserve_space(ds, tx); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1747 |
if (err) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1748 |
return (err); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1749 |
|
2199 | 1750 |
ds->ds_trysnap_txg = tx->tx_txg; |
789 | 1751 |
return (0); |
1752 |
} |
|
1753 |
||
2199 | 1754 |
void |
4543 | 1755 |
dsl_dataset_snapshot_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) |
789 | 1756 |
{ |
5367 | 1757 |
dsl_dataset_t *ds = arg1; |
2199 | 1758 |
const char *snapname = arg2; |
1759 |
dsl_pool_t *dp = ds->ds_dir->dd_pool; |
|
789 | 1760 |
dmu_buf_t *dbuf; |
1761 |
dsl_dataset_phys_t *dsphys; |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1762 |
uint64_t dsobj, crtxg; |
789 | 1763 |
objset_t *mos = dp->dp_meta_objset; |
1764 |
int err; |
|
1765 |
||
2199 | 1766 |
ASSERT(RW_WRITE_HELD(&dp->dp_config_rwlock)); |
789 | 1767 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1768 |
/* |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1769 |
* The origin's ds_creation_txg has to be < TXG_INITIAL |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1770 |
*/ |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1771 |
if (strcmp(snapname, ORIGIN_DIR_NAME) == 0) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1772 |
crtxg = 1; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1773 |
else |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1774 |
crtxg = tx->tx_txg; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1775 |
|
928
36d72fe4da29
6349314 dmu_object_type names incorrect for DSL Directories and DSL Datasets
tabriz
parents:
885
diff
changeset
|
1776 |
dsobj = dmu_object_alloc(mos, DMU_OT_DSL_DATASET, 0, |
36d72fe4da29
6349314 dmu_object_type names incorrect for DSL Directories and DSL Datasets
tabriz
parents:
885
diff
changeset
|
1777 |
DMU_OT_DSL_DATASET, sizeof (dsl_dataset_phys_t), tx); |
1544 | 1778 |
VERIFY(0 == dmu_bonus_hold(mos, dsobj, FTAG, &dbuf)); |
789 | 1779 |
dmu_buf_will_dirty(dbuf, tx); |
1780 |
dsphys = dbuf->db_data; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1781 |
bzero(dsphys, sizeof (dsl_dataset_phys_t)); |
2199 | 1782 |
dsphys->ds_dir_obj = ds->ds_dir->dd_object; |
789 | 1783 |
dsphys->ds_fsid_guid = unique_create(); |
1784 |
(void) random_get_pseudo_bytes((void*)&dsphys->ds_guid, |
|
1785 |
sizeof (dsphys->ds_guid)); |
|
1786 |
dsphys->ds_prev_snap_obj = ds->ds_phys->ds_prev_snap_obj; |
|
1787 |
dsphys->ds_prev_snap_txg = ds->ds_phys->ds_prev_snap_txg; |
|
1788 |
dsphys->ds_next_snap_obj = ds->ds_object; |
|
1789 |
dsphys->ds_num_children = 1; |
|
1790 |
dsphys->ds_creation_time = gethrestime_sec(); |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1791 |
dsphys->ds_creation_txg = crtxg; |
789 | 1792 |
dsphys->ds_deadlist_obj = ds->ds_phys->ds_deadlist_obj; |
1793 |
dsphys->ds_used_bytes = ds->ds_phys->ds_used_bytes; |
|
1794 |
dsphys->ds_compressed_bytes = ds->ds_phys->ds_compressed_bytes; |
|
1795 |
dsphys->ds_uncompressed_bytes = ds->ds_phys->ds_uncompressed_bytes; |
|
2082 | 1796 |
dsphys->ds_flags = ds->ds_phys->ds_flags; |
789 | 1797 |
dsphys->ds_bp = ds->ds_phys->ds_bp; |
1544 | 1798 |
dmu_buf_rele(dbuf, FTAG); |
789 | 1799 |
|
2199 | 1800 |
ASSERT3U(ds->ds_prev != 0, ==, ds->ds_phys->ds_prev_snap_obj != 0); |
1801 |
if (ds->ds_prev) { |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1802 |
uint64_t next_clones_obj = |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1803 |
ds->ds_prev->ds_phys->ds_next_clones_obj; |
2199 | 1804 |
ASSERT(ds->ds_prev->ds_phys->ds_next_snap_obj == |
789 | 1805 |
ds->ds_object || |
2199 | 1806 |
ds->ds_prev->ds_phys->ds_num_children > 1); |
1807 |
if (ds->ds_prev->ds_phys->ds_next_snap_obj == ds->ds_object) { |
|
1808 |
dmu_buf_will_dirty(ds->ds_prev->ds_dbuf, tx); |
|
789 | 1809 |
ASSERT3U(ds->ds_phys->ds_prev_snap_txg, ==, |
2199 | 1810 |
ds->ds_prev->ds_phys->ds_creation_txg); |
1811 |
ds->ds_prev->ds_phys->ds_next_snap_obj = dsobj; |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1812 |
} else if (next_clones_obj != 0) { |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1813 |
VERIFY3U(0, ==, zap_remove_int(mos, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1814 |
next_clones_obj, dsphys->ds_next_snap_obj, tx)); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1815 |
VERIFY3U(0, ==, zap_add_int(mos, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1816 |
next_clones_obj, dsobj, tx)); |
789 | 1817 |
} |
1818 |
} |
|
1819 |
||
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1820 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1821 |
* If we have a reference-reservation on this dataset, we will |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1822 |
* need to increase the amount of refreservation being charged |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1823 |
* since our unique space is going to zero. |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1824 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1825 |
if (ds->ds_reserved) { |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1826 |
int64_t add = MIN(dsl_dataset_unique(ds), ds->ds_reserved); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1827 |
dsl_dir_diduse_space(ds->ds_dir, add, 0, 0, tx); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1828 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1829 |
|
789 | 1830 |
bplist_close(&ds->ds_deadlist); |
1831 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
|
5712
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5569
diff
changeset
|
1832 |
ASSERT3U(ds->ds_phys->ds_prev_snap_txg, <, tx->tx_txg); |
789 | 1833 |
ds->ds_phys->ds_prev_snap_obj = dsobj; |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1834 |
ds->ds_phys->ds_prev_snap_txg = crtxg; |
789 | 1835 |
ds->ds_phys->ds_unique_bytes = 0; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1836 |
if (spa_version(dp->dp_spa) >= SPA_VERSION_UNIQUE_ACCURATE) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1837 |
ds->ds_phys->ds_flags |= DS_FLAG_UNIQUE_ACCURATE; |
789 | 1838 |
ds->ds_phys->ds_deadlist_obj = |
1839 |
bplist_create(mos, DSL_DEADLIST_BLOCKSIZE, tx); |
|
1544 | 1840 |
VERIFY(0 == bplist_open(&ds->ds_deadlist, mos, |
1841 |
ds->ds_phys->ds_deadlist_obj)); |
|
789 | 1842 |
|
1843 |
dprintf("snap '%s' -> obj %llu\n", snapname, dsobj); |
|
1844 |
err = zap_add(mos, ds->ds_phys->ds_snapnames_zapobj, |
|
1845 |
snapname, 8, 1, &dsobj, tx); |
|
1846 |
ASSERT(err == 0); |
|
1847 |
||
1848 |
if (ds->ds_prev) |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1849 |
dsl_dataset_drop_ref(ds->ds_prev, ds); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1850 |
VERIFY(0 == dsl_dataset_get_ref(dp, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1851 |
ds->ds_phys->ds_prev_snap_obj, ds, &ds->ds_prev)); |
4543 | 1852 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1853 |
dsl_pool_ds_snapshotted(ds, tx); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1854 |
|
4543 | 1855 |
spa_history_internal_log(LOG_DS_SNAPSHOT, dp->dp_spa, tx, cr, |
4603
c7840c367d00
6494569 zfs recv -d pool/<doesn't exist> core dumps for top-level filesystem backups
ahrens
parents:
4577
diff
changeset
|
1856 |
"dataset = %llu", dsobj); |
789 | 1857 |
} |
1858 |
||
1859 |
void |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
1860 |
dsl_dataset_sync(dsl_dataset_t *ds, zio_t *zio, dmu_tx_t *tx) |
789 | 1861 |
{ |
1862 |
ASSERT(dmu_tx_is_syncing(tx)); |
|
1863 |
ASSERT(ds->ds_user_ptr != NULL); |
|
1864 |
ASSERT(ds->ds_phys->ds_next_snap_obj == 0); |
|
1865 |
||
4787 | 1866 |
/* |
1867 |
* in case we had to change ds_fsid_guid when we opened it, |
|
1868 |
* sync it out now. |
|
1869 |
*/ |
|
1870 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
|
1871 |
ds->ds_phys->ds_fsid_guid = ds->ds_fsid_guid; |
|
1872 |
||
789 | 1873 |
dsl_dir_dirty(ds->ds_dir, tx); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
1874 |
dmu_objset_sync(ds->ds_user_ptr, zio, tx); |
789 | 1875 |
} |
1876 |
||
1877 |
void |
|
2885 | 1878 |
dsl_dataset_stats(dsl_dataset_t *ds, nvlist_t *nv) |
789 | 1879 |
{ |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1880 |
uint64_t refd, avail, uobjs, aobjs; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1881 |
|
2885 | 1882 |
dsl_dir_stats(ds->ds_dir, nv); |
789 | 1883 |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1884 |
dsl_dataset_space(ds, &refd, &avail, &uobjs, &aobjs); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1885 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_AVAILABLE, avail); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1886 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_REFERENCED, refd); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1887 |
|
2885 | 1888 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_CREATION, |
1889 |
ds->ds_phys->ds_creation_time); |
|
1890 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_CREATETXG, |
|
1891 |
ds->ds_phys->ds_creation_txg); |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1892 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_REFQUOTA, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1893 |
ds->ds_quota); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1894 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_REFRESERVATION, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1895 |
ds->ds_reserved); |
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6502
diff
changeset
|
1896 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_GUID, |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6502
diff
changeset
|
1897 |
ds->ds_phys->ds_guid); |
789 | 1898 |
|
1899 |
if (ds->ds_phys->ds_next_snap_obj) { |
|
1900 |
/* |
|
1901 |
* This is a snapshot; override the dd's space used with |
|
2885 | 1902 |
* our unique space and compression ratio. |
789 | 1903 |
*/ |
2885 | 1904 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USED, |
1905 |
ds->ds_phys->ds_unique_bytes); |
|
1906 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_COMPRESSRATIO, |
|
1907 |
ds->ds_phys->ds_compressed_bytes == 0 ? 100 : |
|
1908 |
(ds->ds_phys->ds_uncompressed_bytes * 100 / |
|
1909 |
ds->ds_phys->ds_compressed_bytes)); |
|
789 | 1910 |
} |
1911 |
} |
|
1912 |
||
2885 | 1913 |
void |
1914 |
dsl_dataset_fast_stat(dsl_dataset_t *ds, dmu_objset_stats_t *stat) |
|
789 | 1915 |
{ |
2885 | 1916 |
stat->dds_creation_txg = ds->ds_phys->ds_creation_txg; |
1917 |
stat->dds_inconsistent = ds->ds_phys->ds_flags & DS_FLAG_INCONSISTENT; |
|
5367 | 1918 |
stat->dds_guid = ds->ds_phys->ds_guid; |
2885 | 1919 |
if (ds->ds_phys->ds_next_snap_obj) { |
1920 |
stat->dds_is_snapshot = B_TRUE; |
|
1921 |
stat->dds_num_clones = ds->ds_phys->ds_num_children - 1; |
|
1922 |
} |
|
1923 |
||
1924 |
/* clone origin is really a dsl_dir thing... */ |
|
5446 | 1925 |
rw_enter(&ds->ds_dir->dd_pool->dp_config_rwlock, RW_READER); |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1926 |
if (dsl_dir_is_clone(ds->ds_dir)) { |
2885 | 1927 |
dsl_dataset_t *ods; |
1928 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1929 |
VERIFY(0 == dsl_dataset_get_ref(ds->ds_dir->dd_pool, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1930 |
ds->ds_dir->dd_phys->dd_origin_obj, FTAG, &ods)); |
5367 | 1931 |
dsl_dataset_name(ods, stat->dds_origin); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1932 |
dsl_dataset_drop_ref(ods, FTAG); |
2885 | 1933 |
} |
5446 | 1934 |
rw_exit(&ds->ds_dir->dd_pool->dp_config_rwlock); |
2885 | 1935 |
} |
1936 |
||
1937 |
uint64_t |
|
1938 |
dsl_dataset_fsid_guid(dsl_dataset_t *ds) |
|
1939 |
{ |
|
4787 | 1940 |
return (ds->ds_fsid_guid); |
2885 | 1941 |
} |
1942 |
||
1943 |
void |
|
1944 |
dsl_dataset_space(dsl_dataset_t *ds, |
|
1945 |
uint64_t *refdbytesp, uint64_t *availbytesp, |
|
1946 |
uint64_t *usedobjsp, uint64_t *availobjsp) |
|
1947 |
{ |
|
1948 |
*refdbytesp = ds->ds_phys->ds_used_bytes; |
|
1949 |
*availbytesp = dsl_dir_space_available(ds->ds_dir, NULL, 0, TRUE); |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1950 |
if (ds->ds_reserved > ds->ds_phys->ds_unique_bytes) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1951 |
*availbytesp += ds->ds_reserved - ds->ds_phys->ds_unique_bytes; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1952 |
if (ds->ds_quota != 0) { |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1953 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1954 |
* Adjust available bytes according to refquota |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1955 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1956 |
if (*refdbytesp < ds->ds_quota) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1957 |
*availbytesp = MIN(*availbytesp, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1958 |
ds->ds_quota - *refdbytesp); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1959 |
else |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1960 |
*availbytesp = 0; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1961 |
} |
2885 | 1962 |
*usedobjsp = ds->ds_phys->ds_bp.blk_fill; |
1963 |
*availobjsp = DN_MAX_OBJECT - *usedobjsp; |
|
789 | 1964 |
} |
1965 |
||
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
1966 |
boolean_t |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
1967 |
dsl_dataset_modified_since_lastsnap(dsl_dataset_t *ds) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
1968 |
{ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
1969 |
dsl_pool_t *dp = ds->ds_dir->dd_pool; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
1970 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
1971 |
ASSERT(RW_LOCK_HELD(&dp->dp_config_rwlock) || |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
1972 |
dsl_pool_sync_context(dp)); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
1973 |
if (ds->ds_prev == NULL) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
1974 |
return (B_FALSE); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
1975 |
if (ds->ds_phys->ds_bp.blk_birth > |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
1976 |
ds->ds_prev->ds_phys->ds_creation_txg) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
1977 |
return (B_TRUE); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
1978 |
return (B_FALSE); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
1979 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
1980 |
|
2199 | 1981 |
/* ARGSUSED */ |
789 | 1982 |
static int |
2199 | 1983 |
dsl_dataset_snapshot_rename_check(void *arg1, void *arg2, dmu_tx_t *tx) |
789 | 1984 |
{ |
2199 | 1985 |
dsl_dataset_t *ds = arg1; |
1986 |
char *newsnapname = arg2; |
|
1987 |
dsl_dir_t *dd = ds->ds_dir; |
|
1988 |
dsl_dataset_t *hds; |
|
1989 |
uint64_t val; |
|
789 | 1990 |
int err; |
1991 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1992 |
err = dsl_dataset_hold_obj(dd->dd_pool, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1993 |
dd->dd_phys->dd_head_dataset_obj, FTAG, &hds); |
789 | 1994 |
if (err) |
1995 |
return (err); |
|
1996 |
||
2199 | 1997 |
/* new name better not be in use */ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1998 |
err = dsl_dataset_snap_lookup(hds, newsnapname, &val); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1999 |
dsl_dataset_rele(hds, FTAG); |
789 | 2000 |
|
2199 | 2001 |
if (err == 0) |
2002 |
err = EEXIST; |
|
2003 |
else if (err == ENOENT) |
|
2004 |
err = 0; |
|
4007 | 2005 |
|
2006 |
/* dataset name + 1 for the "@" + the new snapshot name must fit */ |
|
2007 |
if (dsl_dir_namelen(ds->ds_dir) + 1 + strlen(newsnapname) >= MAXNAMELEN) |
|
2008 |
err = ENAMETOOLONG; |
|
2009 |
||
2199 | 2010 |
return (err); |
2011 |
} |
|
789 | 2012 |
|
2199 | 2013 |
static void |
4543 | 2014 |
dsl_dataset_snapshot_rename_sync(void *arg1, void *arg2, |
2015 |
cred_t *cr, dmu_tx_t *tx) |
|
2199 | 2016 |
{ |
2017 |
dsl_dataset_t *ds = arg1; |
|
4543 | 2018 |
const char *newsnapname = arg2; |
2199 | 2019 |
dsl_dir_t *dd = ds->ds_dir; |
2020 |
objset_t *mos = dd->dd_pool->dp_meta_objset; |
|
2021 |
dsl_dataset_t *hds; |
|
2022 |
int err; |
|
789 | 2023 |
|
2199 | 2024 |
ASSERT(ds->ds_phys->ds_next_snap_obj != 0); |
789 | 2025 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2026 |
VERIFY(0 == dsl_dataset_hold_obj(dd->dd_pool, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2027 |
dd->dd_phys->dd_head_dataset_obj, FTAG, &hds)); |
789 | 2028 |
|
2199 | 2029 |
VERIFY(0 == dsl_dataset_get_snapname(ds)); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2030 |
err = dsl_dataset_snap_remove(hds, ds->ds_snapname, tx); |
789 | 2031 |
ASSERT3U(err, ==, 0); |
2199 | 2032 |
mutex_enter(&ds->ds_lock); |
2033 |
(void) strcpy(ds->ds_snapname, newsnapname); |
|
2034 |
mutex_exit(&ds->ds_lock); |
|
2035 |
err = zap_add(mos, hds->ds_phys->ds_snapnames_zapobj, |
|
2036 |
ds->ds_snapname, 8, 1, &ds->ds_object, tx); |
|
789 | 2037 |
ASSERT3U(err, ==, 0); |
2038 |
||
4543 | 2039 |
spa_history_internal_log(LOG_DS_RENAME, dd->dd_pool->dp_spa, tx, |
2040 |
cr, "dataset = %llu", ds->ds_object); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2041 |
dsl_dataset_rele(hds, FTAG); |
789 | 2042 |
} |
2043 |
||
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2044 |
struct renamesnaparg { |
4007 | 2045 |
dsl_sync_task_group_t *dstg; |
2046 |
char failed[MAXPATHLEN]; |
|
2047 |
char *oldsnap; |
|
2048 |
char *newsnap; |
|
2049 |
}; |
|
2050 |
||
2051 |
static int |
|
2052 |
dsl_snapshot_rename_one(char *name, void *arg) |
|
2053 |
{ |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2054 |
struct renamesnaparg *ra = arg; |
4007 | 2055 |
dsl_dataset_t *ds = NULL; |
2056 |
char *cp; |
|
2057 |
int err; |
|
2058 |
||
2059 |
cp = name + strlen(name); |
|
2060 |
*cp = '@'; |
|
2061 |
(void) strcpy(cp + 1, ra->oldsnap); |
|
4543 | 2062 |
|
2063 |
/* |
|
2064 |
* For recursive snapshot renames the parent won't be changing |
|
2065 |
* so we just pass name for both the to/from argument. |
|
2066 |
*/ |
|
2067 |
if (err = zfs_secpolicy_rename_perms(name, name, CRED())) { |
|
2068 |
(void) strcpy(ra->failed, name); |
|
2069 |
return (err); |
|
2070 |
} |
|
2071 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2072 |
#ifdef _KERNEL |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2073 |
/* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2074 |
* For all filesystems undergoing rename, we'll need to unmount it. |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2075 |
*/ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2076 |
(void) zfs_unmount_snap(name, NULL); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2077 |
#endif |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2078 |
err = dsl_dataset_hold(name, ra->dstg, &ds); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2079 |
*cp = '\0'; |
4007 | 2080 |
if (err == ENOENT) { |
2081 |
return (0); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2082 |
} else if (err) { |
4007 | 2083 |
(void) strcpy(ra->failed, name); |
2084 |
return (err); |
|
2085 |
} |
|
2086 |
||
2087 |
dsl_sync_task_create(ra->dstg, dsl_dataset_snapshot_rename_check, |
|
2088 |
dsl_dataset_snapshot_rename_sync, ds, ra->newsnap, 0); |
|
2089 |
||
2090 |
return (0); |
|
2091 |
} |
|
2092 |
||
2093 |
static int |
|
2094 |
dsl_recursive_rename(char *oldname, const char *newname) |
|
2095 |
{ |
|
2096 |
int err; |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2097 |
struct renamesnaparg *ra; |
4007 | 2098 |
dsl_sync_task_t *dst; |
2099 |
spa_t *spa; |
|
2100 |
char *cp, *fsname = spa_strdup(oldname); |
|
2101 |
int len = strlen(oldname); |
|
2102 |
||
2103 |
/* truncate the snapshot name to get the fsname */ |
|
2104 |
cp = strchr(fsname, '@'); |
|
2105 |
*cp = '\0'; |
|
2106 |
||
4603
c7840c367d00
6494569 zfs recv -d pool/<doesn't exist> core dumps for top-level filesystem backups
ahrens
parents:
4577
diff
changeset
|
2107 |
err = spa_open(fsname, &spa, FTAG); |
4007 | 2108 |
if (err) { |
2109 |
kmem_free(fsname, len + 1); |
|
2110 |
return (err); |
|
2111 |
} |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2112 |
ra = kmem_alloc(sizeof (struct renamesnaparg), KM_SLEEP); |
4007 | 2113 |
ra->dstg = dsl_sync_task_group_create(spa_get_dsl(spa)); |
2114 |
||
2115 |
ra->oldsnap = strchr(oldname, '@') + 1; |
|
2116 |
ra->newsnap = strchr(newname, '@') + 1; |
|
2117 |
*ra->failed = '\0'; |
|
2118 |
||
2119 |
err = dmu_objset_find(fsname, dsl_snapshot_rename_one, ra, |
|
2120 |
DS_FIND_CHILDREN); |
|
2121 |
kmem_free(fsname, len + 1); |
|
2122 |
||
2123 |
if (err == 0) { |
|
2124 |
err = dsl_sync_task_group_wait(ra->dstg); |
|
2125 |
} |
|
2126 |
||
2127 |
for (dst = list_head(&ra->dstg->dstg_tasks); dst; |
|
2128 |
dst = list_next(&ra->dstg->dstg_tasks, dst)) { |
|
2129 |
dsl_dataset_t *ds = dst->dst_arg1; |
|
2130 |
if (dst->dst_err) { |
|
2131 |
dsl_dir_name(ds->ds_dir, ra->failed); |
|
4009
1a9b4fbc0d2a
6479884 want 'zfs rename -r' to recursively rename snapshots (fix lint)
mmusante
parents:
4007
diff
changeset
|
2132 |
(void) strcat(ra->failed, "@"); |
1a9b4fbc0d2a
6479884 want 'zfs rename -r' to recursively rename snapshots (fix lint)
mmusante
parents:
4007
diff
changeset
|
2133 |
(void) strcat(ra->failed, ra->newsnap); |
4007 | 2134 |
} |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2135 |
dsl_dataset_rele(ds, ra->dstg); |
4007 | 2136 |
} |
2137 |
||
4543 | 2138 |
if (err) |
2139 |
(void) strcpy(oldname, ra->failed); |
|
4007 | 2140 |
|
2141 |
dsl_sync_task_group_destroy(ra->dstg); |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2142 |
kmem_free(ra, sizeof (struct renamesnaparg)); |
4007 | 2143 |
spa_close(spa, FTAG); |
2144 |
return (err); |
|
2145 |
} |
|
2146 |
||
4569
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2147 |
static int |
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2148 |
dsl_valid_rename(char *oldname, void *arg) |
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2149 |
{ |
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2150 |
int delta = *(int *)arg; |
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2151 |
|
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2152 |
if (strlen(oldname) + delta >= MAXNAMELEN) |
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2153 |
return (ENAMETOOLONG); |
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2154 |
|
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2155 |
return (0); |
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2156 |
} |
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2157 |
|
789 | 2158 |
#pragma weak dmu_objset_rename = dsl_dataset_rename |
2159 |
int |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2160 |
dsl_dataset_rename(char *oldname, const char *newname, boolean_t recursive) |
789 | 2161 |
{ |
2162 |
dsl_dir_t *dd; |
|
2199 | 2163 |
dsl_dataset_t *ds; |
789 | 2164 |
const char *tail; |
2165 |
int err; |
|
2166 |
||
2199 | 2167 |
err = dsl_dir_open(oldname, FTAG, &dd, &tail); |
1544 | 2168 |
if (err) |
2169 |
return (err); |
|
789 | 2170 |
if (tail == NULL) { |
4569
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2171 |
int delta = strlen(newname) - strlen(oldname); |
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2172 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2173 |
/* if we're growing, validate child name lengths */ |
4569
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2174 |
if (delta > 0) |
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2175 |
err = dmu_objset_find(oldname, dsl_valid_rename, |
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2176 |
&delta, DS_FIND_CHILDREN | DS_FIND_SNAPSHOTS); |
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2177 |
|
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2178 |
if (!err) |
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2179 |
err = dsl_dir_rename(dd, newname); |
789 | 2180 |
dsl_dir_close(dd, FTAG); |
2181 |
return (err); |
|
2182 |
} |
|
2183 |
if (tail[0] != '@') { |
|
2184 |
/* the name ended in a nonexistant component */ |
|
2185 |
dsl_dir_close(dd, FTAG); |
|
2186 |
return (ENOENT); |
|
2187 |
} |
|
2188 |
||
2199 | 2189 |
dsl_dir_close(dd, FTAG); |
2190 |
||
2191 |
/* new name must be snapshot in same filesystem */ |
|
2192 |
tail = strchr(newname, '@'); |
|
2193 |
if (tail == NULL) |
|
2194 |
return (EINVAL); |
|
2195 |
tail++; |
|
2196 |
if (strncmp(oldname, newname, tail - newname) != 0) |
|
2197 |
return (EXDEV); |
|
789 | 2198 |
|
4007 | 2199 |
if (recursive) { |
2200 |
err = dsl_recursive_rename(oldname, newname); |
|
2201 |
} else { |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2202 |
err = dsl_dataset_hold(oldname, FTAG, &ds); |
4007 | 2203 |
if (err) |
2204 |
return (err); |
|
2199 | 2205 |
|
4007 | 2206 |
err = dsl_sync_task_do(ds->ds_dir->dd_pool, |
2207 |
dsl_dataset_snapshot_rename_check, |
|
2208 |
dsl_dataset_snapshot_rename_sync, ds, (char *)tail, 1); |
|
2199 | 2209 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2210 |
dsl_dataset_rele(ds, FTAG); |
4007 | 2211 |
} |
2199 | 2212 |
|
789 | 2213 |
return (err); |
2214 |
} |
|
2082 | 2215 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2216 |
struct promotenode { |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2217 |
list_node_t link; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2218 |
dsl_dataset_t *ds; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2219 |
}; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2220 |
|
2199 | 2221 |
struct promotearg { |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2222 |
list_t snap_list; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2223 |
dsl_dataset_t *clone_origin, *old_head; |
2199 | 2224 |
uint64_t used, comp, uncomp, unique; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2225 |
uint64_t newnext_obj; |
2199 | 2226 |
}; |
2227 |
||
4543 | 2228 |
/* ARGSUSED */ |
2082 | 2229 |
static int |
2199 | 2230 |
dsl_dataset_promote_check(void *arg1, void *arg2, dmu_tx_t *tx) |
2082 | 2231 |
{ |
2199 | 2232 |
dsl_dataset_t *hds = arg1; |
2233 |
struct promotearg *pa = arg2; |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2234 |
struct promotenode *snap = list_head(&pa->snap_list); |
2199 | 2235 |
dsl_pool_t *dp = hds->ds_dir->dd_pool; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2236 |
dsl_dataset_t *origin_ds = snap->ds; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2237 |
dsl_dataset_t *newnext_ds; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2238 |
char *name; |
2199 | 2239 |
uint64_t itor = 0; |
2082 | 2240 |
blkptr_t bp; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2241 |
int err; |
2199 | 2242 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2243 |
/* Check that it is a real clone */ |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2244 |
if (!dsl_dir_is_clone(hds->ds_dir)) |
2082 | 2245 |
return (EINVAL); |
2246 |
||
2199 | 2247 |
/* Since this is so expensive, don't do the preliminary check */ |
2248 |
if (!dmu_tx_is_syncing(tx)) |
|
2249 |
return (0); |
|
2250 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2251 |
if (hds->ds_phys->ds_flags & DS_FLAG_NOPROMOTE) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2252 |
return (EXDEV); |
2082 | 2253 |
|
5367 | 2254 |
/* find origin's new next ds */ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2255 |
newnext_ds = hds; |
5367 | 2256 |
while (newnext_ds->ds_phys->ds_prev_snap_obj != origin_ds->ds_object) { |
2082 | 2257 |
dsl_dataset_t *prev; |
2258 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2259 |
err = dsl_dataset_hold_obj(dp, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2260 |
newnext_ds->ds_phys->ds_prev_snap_obj, FTAG, &prev); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2261 |
if (newnext_ds != hds) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2262 |
dsl_dataset_rele(newnext_ds, FTAG); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2263 |
if (err) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2264 |
return (err); |
2082 | 2265 |
newnext_ds = prev; |
2266 |
} |
|
2199 | 2267 |
pa->newnext_obj = newnext_ds->ds_object; |
2082 | 2268 |
|
5367 | 2269 |
/* compute origin's new unique space */ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2270 |
pa->unique = 0; |
2082 | 2271 |
while ((err = bplist_iterate(&newnext_ds->ds_deadlist, |
2272 |
&itor, &bp)) == 0) { |
|
5367 | 2273 |
if (bp.blk_birth > origin_ds->ds_phys->ds_prev_snap_txg) |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2274 |
pa->unique += bp_get_dasize(dp->dp_spa, &bp); |
2082 | 2275 |
} |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2276 |
if (newnext_ds != hds) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2277 |
dsl_dataset_rele(newnext_ds, FTAG); |
2082 | 2278 |
if (err != ENOENT) |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2279 |
return (err); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2280 |
|
2082 | 2281 |
name = kmem_alloc(MAXPATHLEN, KM_SLEEP); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2282 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2283 |
/* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2284 |
* Walk the snapshots that we are moving |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2285 |
* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2286 |
* Compute space to transfer. Each snapshot gave birth to: |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2287 |
* (my used) - (prev's used) + (deadlist's used) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2288 |
* So a sequence would look like: |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2289 |
* uN - u(N-1) + dN + ... + u1 - u0 + d1 + u0 - 0 + d0 |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2290 |
* Which simplifies to: |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2291 |
* uN + dN + ... + d1 + d0 |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2292 |
* Note however, if we stop before we reach the ORIGIN we get: |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2293 |
* uN + dN + ... + dM - uM-1 |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2294 |
*/ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2295 |
pa->used = origin_ds->ds_phys->ds_used_bytes; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2296 |
pa->comp = origin_ds->ds_phys->ds_compressed_bytes; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2297 |
pa->uncomp = origin_ds->ds_phys->ds_uncompressed_bytes; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2298 |
do { |
2082 | 2299 |
uint64_t val, dlused, dlcomp, dluncomp; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2300 |
dsl_dataset_t *ds = snap->ds; |
2082 | 2301 |
|
2302 |
/* Check that the snapshot name does not conflict */ |
|
2303 |
dsl_dataset_name(ds, name); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2304 |
err = dsl_dataset_snap_lookup(hds, ds->ds_snapname, &val); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2305 |
if (err == 0) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2306 |
err = EEXIST; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2307 |
if (err != ENOENT) |
2082 | 2308 |
break; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2309 |
err = 0; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2310 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2311 |
/* The very first snapshot does not have a deadlist */ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2312 |
if (ds->ds_phys->ds_prev_snap_obj != 0) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2313 |
if (err = bplist_space(&ds->ds_deadlist, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2314 |
&dlused, &dlcomp, &dluncomp)) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2315 |
break; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2316 |
pa->used += dlused; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2317 |
pa->comp += dlcomp; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2318 |
pa->uncomp += dluncomp; |
2082 | 2319 |
} |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2320 |
} while (snap = list_next(&pa->snap_list, snap)); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2321 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2322 |
/* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2323 |
* If we are a clone of a clone then we never reached ORIGIN, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2324 |
* so we need to subtract out the clone origin's used space. |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2325 |
*/ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2326 |
if (pa->clone_origin) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2327 |
pa->used -= pa->clone_origin->ds_phys->ds_used_bytes; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2328 |
pa->comp -= pa->clone_origin->ds_phys->ds_compressed_bytes; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2329 |
pa->uncomp -= pa->clone_origin->ds_phys->ds_uncompressed_bytes; |
2082 | 2330 |
} |
2331 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2332 |
kmem_free(name, MAXPATHLEN); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2333 |
|
2082 | 2334 |
/* Check that there is enough space here */ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2335 |
if (err == 0) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2336 |
dsl_dir_t *odd = origin_ds->ds_dir; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2337 |
err = dsl_dir_transfer_possible(odd, hds->ds_dir, pa->used); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2338 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2339 |
|
2199 | 2340 |
return (err); |
2341 |
} |
|
2082 | 2342 |
|
2199 | 2343 |
static void |
4543 | 2344 |
dsl_dataset_promote_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) |
2199 | 2345 |
{ |
2346 |
dsl_dataset_t *hds = arg1; |
|
2347 |
struct promotearg *pa = arg2; |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2348 |
struct promotenode *snap = list_head(&pa->snap_list); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2349 |
dsl_dataset_t *origin_ds = snap->ds; |
2199 | 2350 |
dsl_dir_t *dd = hds->ds_dir; |
2351 |
dsl_pool_t *dp = hds->ds_dir->dd_pool; |
|
5367 | 2352 |
dsl_dir_t *odd = NULL; |
2199 | 2353 |
char *name; |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2354 |
uint64_t oldnext_obj; |
2199 | 2355 |
|
2356 |
ASSERT(0 == (hds->ds_phys->ds_flags & DS_FLAG_NOPROMOTE)); |
|
2357 |
||
2417 | 2358 |
/* |
5367 | 2359 |
* We need to explicitly open odd, since origin_ds's dd will be |
2417 | 2360 |
* changing. |
2361 |
*/ |
|
5367 | 2362 |
VERIFY(0 == dsl_dir_open_obj(dp, origin_ds->ds_dir->dd_object, |
2363 |
NULL, FTAG, &odd)); |
|
2082 | 2364 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2365 |
/* change origin's next snap */ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2366 |
dmu_buf_will_dirty(origin_ds->ds_dbuf, tx); |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2367 |
oldnext_obj = origin_ds->ds_phys->ds_next_snap_obj; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2368 |
origin_ds->ds_phys->ds_next_snap_obj = pa->newnext_obj; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2369 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2370 |
/* change the origin's next clone */ |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2371 |
if (origin_ds->ds_phys->ds_next_clones_obj) { |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2372 |
VERIFY3U(0, ==, zap_remove_int(dp->dp_meta_objset, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2373 |
origin_ds->ds_phys->ds_next_clones_obj, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2374 |
pa->newnext_obj, tx)); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2375 |
VERIFY3U(0, ==, zap_add_int(dp->dp_meta_objset, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2376 |
origin_ds->ds_phys->ds_next_clones_obj, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2377 |
oldnext_obj, tx)); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2378 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2379 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2380 |
/* change origin */ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2381 |
dmu_buf_will_dirty(dd->dd_dbuf, tx); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2382 |
ASSERT3U(dd->dd_phys->dd_origin_obj, ==, origin_ds->ds_object); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2383 |
dd->dd_phys->dd_origin_obj = odd->dd_phys->dd_origin_obj; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2384 |
dmu_buf_will_dirty(odd->dd_dbuf, tx); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2385 |
odd->dd_phys->dd_origin_obj = origin_ds->ds_object; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2386 |
|
2082 | 2387 |
/* move snapshots to this dir */ |
2199 | 2388 |
name = kmem_alloc(MAXPATHLEN, KM_SLEEP); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2389 |
do { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2390 |
dsl_dataset_t *ds = snap->ds; |
2082 | 2391 |
|
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7077
diff
changeset
|
2392 |
/* unregister props as dsl_dir is changing */ |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7077
diff
changeset
|
2393 |
if (ds->ds_user_ptr) { |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7077
diff
changeset
|
2394 |
ds->ds_user_evict_func(ds, ds->ds_user_ptr); |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7077
diff
changeset
|
2395 |
ds->ds_user_ptr = NULL; |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7077
diff
changeset
|
2396 |
} |
2082 | 2397 |
/* move snap name entry */ |
2398 |
dsl_dataset_name(ds, name); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2399 |
VERIFY(0 == dsl_dataset_snap_remove(pa->old_head, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2400 |
ds->ds_snapname, tx)); |
2199 | 2401 |
VERIFY(0 == zap_add(dp->dp_meta_objset, |
2082 | 2402 |
hds->ds_phys->ds_snapnames_zapobj, ds->ds_snapname, |
2403 |
8, 1, &ds->ds_object, tx)); |
|
2404 |
/* change containing dsl_dir */ |
|
2405 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
|
5367 | 2406 |
ASSERT3U(ds->ds_phys->ds_dir_obj, ==, odd->dd_object); |
2082 | 2407 |
ds->ds_phys->ds_dir_obj = dd->dd_object; |
5367 | 2408 |
ASSERT3P(ds->ds_dir, ==, odd); |
2082 | 2409 |
dsl_dir_close(ds->ds_dir, ds); |
2199 | 2410 |
VERIFY(0 == dsl_dir_open_obj(dp, dd->dd_object, |
2082 | 2411 |
NULL, ds, &ds->ds_dir)); |
2412 |
||
2413 |
ASSERT3U(dsl_prop_numcb(ds), ==, 0); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2414 |
} while (snap = list_next(&pa->snap_list, snap)); |
2082 | 2415 |
|
2416 |
/* change space accounting */ |
|
5367 | 2417 |
dsl_dir_diduse_space(odd, -pa->used, -pa->comp, -pa->uncomp, tx); |
2199 | 2418 |
dsl_dir_diduse_space(dd, pa->used, pa->comp, pa->uncomp, tx); |
5367 | 2419 |
origin_ds->ds_phys->ds_unique_bytes = pa->unique; |
2082 | 2420 |
|
4543 | 2421 |
/* log history record */ |
2422 |
spa_history_internal_log(LOG_DS_PROMOTE, dd->dd_pool->dp_spa, tx, |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2423 |
cr, "dataset = %llu", hds->ds_object); |
4543 | 2424 |
|
5367 | 2425 |
dsl_dir_close(odd, FTAG); |
2199 | 2426 |
kmem_free(name, MAXPATHLEN); |
2082 | 2427 |
} |
2428 |
||
2429 |
int |
|
2430 |
dsl_dataset_promote(const char *name) |
|
2431 |
{ |
|
2432 |
dsl_dataset_t *ds; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2433 |
dsl_dir_t *dd; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2434 |
dsl_pool_t *dp; |
2082 | 2435 |
dmu_object_info_t doi; |
2199 | 2436 |
struct promotearg pa; |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2437 |
struct promotenode *snap; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2438 |
uint64_t snap_obj; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2439 |
uint64_t last_snap = 0; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2440 |
int err; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2441 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2442 |
err = dsl_dataset_hold(name, FTAG, &ds); |
2082 | 2443 |
if (err) |
2444 |
return (err); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2445 |
dd = ds->ds_dir; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2446 |
dp = dd->dd_pool; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2447 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2448 |
err = dmu_object_info(dp->dp_meta_objset, |
2082 | 2449 |
ds->ds_phys->ds_snapnames_zapobj, &doi); |
2450 |
if (err) { |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2451 |
dsl_dataset_rele(ds, FTAG); |
2082 | 2452 |
return (err); |
2453 |
} |
|
2454 |
||
2455 |
/* |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2456 |
* We are going to inherit all the snapshots taken before our |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2457 |
* origin (i.e., our new origin will be our parent's origin). |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2458 |
* Take ownership of them so that we can rename them into our |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2459 |
* namespace. |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2460 |
*/ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2461 |
pa.clone_origin = NULL; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2462 |
list_create(&pa.snap_list, |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2463 |
sizeof (struct promotenode), offsetof(struct promotenode, link)); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2464 |
rw_enter(&dp->dp_config_rwlock, RW_READER); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2465 |
ASSERT(dd->dd_phys->dd_origin_obj != 0); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2466 |
snap_obj = dd->dd_phys->dd_origin_obj; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2467 |
while (snap_obj) { |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2468 |
dsl_dataset_t *snapds; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2469 |
|
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2470 |
/* |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2471 |
* NB: this would be handled by the below check for |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2472 |
* clone of a clone, but then we'd always own_obj() the |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2473 |
* $ORIGIN, thus causing unnecessary EBUSYs. We don't |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2474 |
* need to set pa.clone_origin because the $ORIGIN has |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2475 |
* no data to account for. |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2476 |
*/ |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2477 |
if (dp->dp_origin_snap && |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2478 |
snap_obj == dp->dp_origin_snap->ds_object) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2479 |
break; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2480 |
|
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2481 |
err = dsl_dataset_own_obj(dp, snap_obj, 0, FTAG, &snapds); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2482 |
if (err == ENOENT) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2483 |
/* lost race with snapshot destroy */ |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2484 |
struct promotenode *last = list_tail(&pa.snap_list); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2485 |
ASSERT(snap_obj != last->ds->ds_phys->ds_prev_snap_obj); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2486 |
snap_obj = last->ds->ds_phys->ds_prev_snap_obj; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2487 |
continue; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2488 |
} else if (err) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2489 |
rw_exit(&dp->dp_config_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2490 |
goto out; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2491 |
} |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2492 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2493 |
/* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2494 |
* We could be a clone of a clone. If we reach our |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2495 |
* parent's branch point, we're done. |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2496 |
*/ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2497 |
if (last_snap && |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2498 |
snapds->ds_phys->ds_next_snap_obj != last_snap) { |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2499 |
pa.clone_origin = snapds; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2500 |
break; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2501 |
} |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2502 |
|
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2503 |
snap = kmem_alloc(sizeof (struct promotenode), KM_SLEEP); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2504 |
snap->ds = snapds; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2505 |
list_insert_tail(&pa.snap_list, snap); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2506 |
last_snap = snap_obj; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2507 |
snap_obj = snap->ds->ds_phys->ds_prev_snap_obj; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2508 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2509 |
snap = list_head(&pa.snap_list); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2510 |
ASSERT(snap != NULL); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2511 |
err = dsl_dataset_hold_obj(dp, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2512 |
snap->ds->ds_dir->dd_phys->dd_head_dataset_obj, FTAG, &pa.old_head); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2513 |
rw_exit(&dp->dp_config_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2514 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2515 |
if (err) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2516 |
goto out; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2517 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2518 |
/* |
2082 | 2519 |
* Add in 128x the snapnames zapobj size, since we will be moving |
2520 |
* a bunch of snapnames to the promoted ds, and dirtying their |
|
2521 |
* bonus buffers. |
|
2522 |
*/ |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2523 |
err = dsl_sync_task_do(dp, dsl_dataset_promote_check, |
2199 | 2524 |
dsl_dataset_promote_sync, ds, &pa, 2 + 2 * doi.doi_physical_blks); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2525 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2526 |
dsl_dataset_rele(pa.old_head, FTAG); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2527 |
out: |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2528 |
while ((snap = list_tail(&pa.snap_list)) != NULL) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2529 |
list_remove(&pa.snap_list, snap); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2530 |
dsl_dataset_disown(snap->ds, FTAG); |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2531 |
kmem_free(snap, sizeof (struct promotenode)); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2532 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2533 |
list_destroy(&pa.snap_list); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2534 |
if (pa.clone_origin) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2535 |
dsl_dataset_disown(pa.clone_origin, FTAG); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2536 |
dsl_dataset_rele(ds, FTAG); |
2082 | 2537 |
return (err); |
2538 |
} |
|
3912 | 2539 |
|
5367 | 2540 |
struct cloneswaparg { |
2541 |
dsl_dataset_t *cds; /* clone dataset */ |
|
2542 |
dsl_dataset_t *ohds; /* origin's head dataset */ |
|
2543 |
boolean_t force; |
|
5481
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2544 |
int64_t unused_refres_delta; /* change in unconsumed refreservation */ |
5367 | 2545 |
}; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2546 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2547 |
/* ARGSUSED */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2548 |
static int |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2549 |
dsl_dataset_clone_swap_check(void *arg1, void *arg2, dmu_tx_t *tx) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2550 |
{ |
5367 | 2551 |
struct cloneswaparg *csa = arg1; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2552 |
|
5367 | 2553 |
/* they should both be heads */ |
2554 |
if (dsl_dataset_is_snapshot(csa->cds) || |
|
2555 |
dsl_dataset_is_snapshot(csa->ohds)) |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2556 |
return (EINVAL); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2557 |
|
5367 | 2558 |
/* the branch point should be just before them */ |
2559 |
if (csa->cds->ds_prev != csa->ohds->ds_prev) |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2560 |
return (EINVAL); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2561 |
|
5367 | 2562 |
/* cds should be the clone */ |
2563 |
if (csa->cds->ds_prev->ds_phys->ds_next_snap_obj != |
|
2564 |
csa->ohds->ds_object) |
|
2565 |
return (EINVAL); |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2566 |
|
5367 | 2567 |
/* the clone should be a child of the origin */ |
2568 |
if (csa->cds->ds_dir->dd_parent != csa->ohds->ds_dir) |
|
2569 |
return (EINVAL); |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2570 |
|
5367 | 2571 |
/* ohds shouldn't be modified unless 'force' */ |
2572 |
if (!csa->force && dsl_dataset_modified_since_lastsnap(csa->ohds)) |
|
2573 |
return (ETXTBSY); |
|
5481
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2574 |
|
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2575 |
/* adjust amount of any unconsumed refreservation */ |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2576 |
csa->unused_refres_delta = |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2577 |
(int64_t)MIN(csa->ohds->ds_reserved, |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2578 |
csa->ohds->ds_phys->ds_unique_bytes) - |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2579 |
(int64_t)MIN(csa->ohds->ds_reserved, |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2580 |
csa->cds->ds_phys->ds_unique_bytes); |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2581 |
|
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2582 |
if (csa->unused_refres_delta > 0 && |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2583 |
csa->unused_refres_delta > |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2584 |
dsl_dir_space_available(csa->ohds->ds_dir, NULL, 0, TRUE)) |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2585 |
return (ENOSPC); |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2586 |
|
5367 | 2587 |
return (0); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2588 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2589 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2590 |
/* ARGSUSED */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2591 |
static void |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2592 |
dsl_dataset_clone_swap_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2593 |
{ |
5367 | 2594 |
struct cloneswaparg *csa = arg1; |
2595 |
dsl_pool_t *dp = csa->cds->ds_dir->dd_pool; |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2596 |
uint64_t itor = 0; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2597 |
blkptr_t bp; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2598 |
uint64_t unique = 0; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2599 |
int err; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2600 |
|
5481
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2601 |
ASSERT(csa->cds->ds_reserved == 0); |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2602 |
ASSERT(csa->cds->ds_quota == csa->ohds->ds_quota); |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2603 |
|
5367 | 2604 |
dmu_buf_will_dirty(csa->cds->ds_dbuf, tx); |
2605 |
dmu_buf_will_dirty(csa->ohds->ds_dbuf, tx); |
|
2606 |
dmu_buf_will_dirty(csa->cds->ds_prev->ds_dbuf, tx); |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2607 |
|
5367 | 2608 |
if (csa->cds->ds_user_ptr != NULL) { |
2609 |
csa->cds->ds_user_evict_func(csa->cds, csa->cds->ds_user_ptr); |
|
2610 |
csa->cds->ds_user_ptr = NULL; |
|
2611 |
} |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2612 |
|
5367 | 2613 |
if (csa->ohds->ds_user_ptr != NULL) { |
2614 |
csa->ohds->ds_user_evict_func(csa->ohds, |
|
2615 |
csa->ohds->ds_user_ptr); |
|
2616 |
csa->ohds->ds_user_ptr = NULL; |
|
2617 |
} |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2618 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2619 |
/* compute unique space */ |
5367 | 2620 |
while ((err = bplist_iterate(&csa->cds->ds_deadlist, |
2621 |
&itor, &bp)) == 0) { |
|
2622 |
if (bp.blk_birth > csa->cds->ds_prev->ds_phys->ds_prev_snap_txg) |
|
2623 |
unique += bp_get_dasize(dp->dp_spa, &bp); |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2624 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2625 |
VERIFY(err == ENOENT); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2626 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2627 |
/* reset origin's unique bytes */ |
5367 | 2628 |
csa->cds->ds_prev->ds_phys->ds_unique_bytes = unique; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2629 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2630 |
/* swap blkptrs */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2631 |
{ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2632 |
blkptr_t tmp; |
5367 | 2633 |
tmp = csa->ohds->ds_phys->ds_bp; |
2634 |
csa->ohds->ds_phys->ds_bp = csa->cds->ds_phys->ds_bp; |
|
2635 |
csa->cds->ds_phys->ds_bp = tmp; |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2636 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2637 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2638 |
/* set dd_*_bytes */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2639 |
{ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2640 |
int64_t dused, dcomp, duncomp; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2641 |
uint64_t cdl_used, cdl_comp, cdl_uncomp; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2642 |
uint64_t odl_used, odl_comp, odl_uncomp; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2643 |
|
5367 | 2644 |
VERIFY(0 == bplist_space(&csa->cds->ds_deadlist, &cdl_used, |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2645 |
&cdl_comp, &cdl_uncomp)); |
5367 | 2646 |
VERIFY(0 == bplist_space(&csa->ohds->ds_deadlist, &odl_used, |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2647 |
&odl_comp, &odl_uncomp)); |
5367 | 2648 |
dused = csa->cds->ds_phys->ds_used_bytes + cdl_used - |
2649 |
(csa->ohds->ds_phys->ds_used_bytes + odl_used); |
|
2650 |
dcomp = csa->cds->ds_phys->ds_compressed_bytes + cdl_comp - |
|
2651 |
(csa->ohds->ds_phys->ds_compressed_bytes + odl_comp); |
|
2652 |
duncomp = csa->cds->ds_phys->ds_uncompressed_bytes + |
|
2653 |
cdl_uncomp - |
|
2654 |
(csa->ohds->ds_phys->ds_uncompressed_bytes + odl_uncomp); |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2655 |
|
5367 | 2656 |
dsl_dir_diduse_space(csa->ohds->ds_dir, |
2657 |
dused, dcomp, duncomp, tx); |
|
2658 |
dsl_dir_diduse_space(csa->cds->ds_dir, |
|
2659 |
-dused, -dcomp, -duncomp, tx); |
|
2660 |
} |
|
2661 |
||
2662 |
#define SWITCH64(x, y) \ |
|
2663 |
{ \ |
|
2664 |
uint64_t __tmp = (x); \ |
|
2665 |
(x) = (y); \ |
|
2666 |
(y) = __tmp; \ |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2667 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2668 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2669 |
/* swap ds_*_bytes */ |
5367 | 2670 |
SWITCH64(csa->ohds->ds_phys->ds_used_bytes, |
2671 |
csa->cds->ds_phys->ds_used_bytes); |
|
2672 |
SWITCH64(csa->ohds->ds_phys->ds_compressed_bytes, |
|
2673 |
csa->cds->ds_phys->ds_compressed_bytes); |
|
2674 |
SWITCH64(csa->ohds->ds_phys->ds_uncompressed_bytes, |
|
2675 |
csa->cds->ds_phys->ds_uncompressed_bytes); |
|
5481
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2676 |
SWITCH64(csa->ohds->ds_phys->ds_unique_bytes, |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2677 |
csa->cds->ds_phys->ds_unique_bytes); |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2678 |
|
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2679 |
/* apply any parent delta for change in unconsumed refreservation */ |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2680 |
dsl_dir_diduse_space(csa->ohds->ds_dir, csa->unused_refres_delta, |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2681 |
0, 0, tx); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2682 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2683 |
/* swap deadlists */ |
5367 | 2684 |
bplist_close(&csa->cds->ds_deadlist); |
2685 |
bplist_close(&csa->ohds->ds_deadlist); |
|
2686 |
SWITCH64(csa->ohds->ds_phys->ds_deadlist_obj, |
|
2687 |
csa->cds->ds_phys->ds_deadlist_obj); |
|
2688 |
VERIFY(0 == bplist_open(&csa->cds->ds_deadlist, dp->dp_meta_objset, |
|
2689 |
csa->cds->ds_phys->ds_deadlist_obj)); |
|
2690 |
VERIFY(0 == bplist_open(&csa->ohds->ds_deadlist, dp->dp_meta_objset, |
|
2691 |
csa->ohds->ds_phys->ds_deadlist_obj)); |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2692 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2693 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2694 |
/* |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2695 |
* Swap 'clone' with its origin head file system. Used at the end |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2696 |
* of "online recv" to swizzle the file system to the new version. |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2697 |
*/ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2698 |
int |
5367 | 2699 |
dsl_dataset_clone_swap(dsl_dataset_t *clone, dsl_dataset_t *origin_head, |
2700 |
boolean_t force) |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2701 |
{ |
5367 | 2702 |
struct cloneswaparg csa; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2703 |
int error; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2704 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2705 |
ASSERT(clone->ds_owner); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2706 |
ASSERT(origin_head->ds_owner); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2707 |
retry: |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2708 |
/* Need exclusive access for the swap */ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2709 |
rw_enter(&clone->ds_rwlock, RW_WRITER); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2710 |
if (!rw_tryenter(&origin_head->ds_rwlock, RW_WRITER)) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2711 |
rw_exit(&clone->ds_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2712 |
rw_enter(&origin_head->ds_rwlock, RW_WRITER); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2713 |
if (!rw_tryenter(&clone->ds_rwlock, RW_WRITER)) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2714 |
rw_exit(&origin_head->ds_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2715 |
goto retry; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2716 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2717 |
} |
5367 | 2718 |
csa.cds = clone; |
2719 |
csa.ohds = origin_head; |
|
2720 |
csa.force = force; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2721 |
error = dsl_sync_task_do(clone->ds_dir->dd_pool, |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2722 |
dsl_dataset_clone_swap_check, |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2723 |
dsl_dataset_clone_swap_sync, &csa, NULL, 9); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2724 |
return (error); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2725 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2726 |
|
3912 | 2727 |
/* |
2728 |
* Given a pool name and a dataset object number in that pool, |
|
2729 |
* return the name of that dataset. |
|
2730 |
*/ |
|
2731 |
int |
|
2732 |
dsl_dsobj_to_dsname(char *pname, uint64_t obj, char *buf) |
|
2733 |
{ |
|
2734 |
spa_t *spa; |
|
2735 |
dsl_pool_t *dp; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2736 |
dsl_dataset_t *ds; |
3912 | 2737 |
int error; |
2738 |
||
2739 |
if ((error = spa_open(pname, &spa, FTAG)) != 0) |
|
2740 |
return (error); |
|
2741 |
dp = spa_get_dsl(spa); |
|
2742 |
rw_enter(&dp->dp_config_rwlock, RW_READER); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2743 |
if ((error = dsl_dataset_hold_obj(dp, obj, FTAG, &ds)) == 0) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2744 |
dsl_dataset_name(ds, buf); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2745 |
dsl_dataset_rele(ds, FTAG); |
3912 | 2746 |
} |
2747 |
rw_exit(&dp->dp_config_rwlock); |
|
2748 |
spa_close(spa, FTAG); |
|
2749 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2750 |
return (error); |
3912 | 2751 |
} |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2752 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2753 |
int |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2754 |
dsl_dataset_check_quota(dsl_dataset_t *ds, boolean_t check_quota, |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2755 |
uint64_t asize, uint64_t inflight, uint64_t *used, uint64_t *ref_rsrv) |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2756 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2757 |
int error = 0; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2758 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2759 |
ASSERT3S(asize, >, 0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2760 |
|
5831
48655d6b290b
6630761 In sub-filesystem, available space is less than refreservation space
ck153898
parents:
5712
diff
changeset
|
2761 |
/* |
48655d6b290b
6630761 In sub-filesystem, available space is less than refreservation space
ck153898
parents:
5712
diff
changeset
|
2762 |
* *ref_rsrv is the portion of asize that will come from any |
48655d6b290b
6630761 In sub-filesystem, available space is less than refreservation space
ck153898
parents:
5712
diff
changeset
|
2763 |
* unconsumed refreservation space. |
48655d6b290b
6630761 In sub-filesystem, available space is less than refreservation space
ck153898
parents:
5712
diff
changeset
|
2764 |
*/ |
48655d6b290b
6630761 In sub-filesystem, available space is less than refreservation space
ck153898
parents:
5712
diff
changeset
|
2765 |
*ref_rsrv = 0; |
48655d6b290b
6630761 In sub-filesystem, available space is less than refreservation space
ck153898
parents:
5712
diff
changeset
|
2766 |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2767 |
mutex_enter(&ds->ds_lock); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2768 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2769 |
* Make a space adjustment for reserved bytes. |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2770 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2771 |
if (ds->ds_reserved > ds->ds_phys->ds_unique_bytes) { |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2772 |
ASSERT3U(*used, >=, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2773 |
ds->ds_reserved - ds->ds_phys->ds_unique_bytes); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2774 |
*used -= (ds->ds_reserved - ds->ds_phys->ds_unique_bytes); |
5831
48655d6b290b
6630761 In sub-filesystem, available space is less than refreservation space
ck153898
parents:
5712
diff
changeset
|
2775 |
*ref_rsrv = |
48655d6b290b
6630761 In sub-filesystem, available space is less than refreservation space
ck153898
parents:
5712
diff
changeset
|
2776 |
asize - MIN(asize, parent_delta(ds, asize + inflight)); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2777 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2778 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2779 |
if (!check_quota || ds->ds_quota == 0) { |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2780 |
mutex_exit(&ds->ds_lock); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2781 |
return (0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2782 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2783 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2784 |
* If they are requesting more space, and our current estimate |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2785 |
* is over quota, they get to try again unless the actual |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2786 |
* on-disk is over quota and there are no pending changes (which |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2787 |
* may free up space for us). |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2788 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2789 |
if (ds->ds_phys->ds_used_bytes + inflight >= ds->ds_quota) { |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2790 |
if (inflight > 0 || ds->ds_phys->ds_used_bytes < ds->ds_quota) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2791 |
error = ERESTART; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2792 |
else |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2793 |
error = EDQUOT; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2794 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2795 |
mutex_exit(&ds->ds_lock); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2796 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2797 |
return (error); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2798 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2799 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2800 |
/* ARGSUSED */ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2801 |
static int |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2802 |
dsl_dataset_set_quota_check(void *arg1, void *arg2, dmu_tx_t *tx) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2803 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2804 |
dsl_dataset_t *ds = arg1; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2805 |
uint64_t *quotap = arg2; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2806 |
uint64_t new_quota = *quotap; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2807 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2808 |
if (spa_version(ds->ds_dir->dd_pool->dp_spa) < SPA_VERSION_REFQUOTA) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2809 |
return (ENOTSUP); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2810 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2811 |
if (new_quota == 0) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2812 |
return (0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2813 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2814 |
if (new_quota < ds->ds_phys->ds_used_bytes || |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2815 |
new_quota < ds->ds_reserved) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2816 |
return (ENOSPC); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2817 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2818 |
return (0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2819 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2820 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2821 |
/* ARGSUSED */ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2822 |
void |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2823 |
dsl_dataset_set_quota_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2824 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2825 |
dsl_dataset_t *ds = arg1; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2826 |
uint64_t *quotap = arg2; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2827 |
uint64_t new_quota = *quotap; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2828 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2829 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2830 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2831 |
ds->ds_quota = new_quota; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2832 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2833 |
dsl_prop_set_uint64_sync(ds->ds_dir, "refquota", new_quota, cr, tx); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2834 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2835 |
spa_history_internal_log(LOG_DS_REFQUOTA, ds->ds_dir->dd_pool->dp_spa, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2836 |
tx, cr, "%lld dataset = %llu ", |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2837 |
(longlong_t)new_quota, ds->ds_object); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2838 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2839 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2840 |
int |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2841 |
dsl_dataset_set_quota(const char *dsname, uint64_t quota) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2842 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2843 |
dsl_dataset_t *ds; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2844 |
int err; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2845 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2846 |
err = dsl_dataset_hold(dsname, FTAG, &ds); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2847 |
if (err) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2848 |
return (err); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2849 |
|
5481
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2850 |
if (quota != ds->ds_quota) { |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2851 |
/* |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2852 |
* If someone removes a file, then tries to set the quota, we |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2853 |
* want to make sure the file freeing takes effect. |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2854 |
*/ |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2855 |
txg_wait_open(ds->ds_dir->dd_pool, 0); |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2856 |
|
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2857 |
err = dsl_sync_task_do(ds->ds_dir->dd_pool, |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2858 |
dsl_dataset_set_quota_check, dsl_dataset_set_quota_sync, |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2859 |
ds, "a, 0); |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
2860 |
} |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2861 |
dsl_dataset_rele(ds, FTAG); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2862 |
return (err); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2863 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2864 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2865 |
static int |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2866 |
dsl_dataset_set_reservation_check(void *arg1, void *arg2, dmu_tx_t *tx) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2867 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2868 |
dsl_dataset_t *ds = arg1; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2869 |
uint64_t *reservationp = arg2; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2870 |
uint64_t new_reservation = *reservationp; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2871 |
int64_t delta; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2872 |
uint64_t unique; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2873 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2874 |
if (new_reservation > INT64_MAX) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2875 |
return (EOVERFLOW); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2876 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2877 |
if (spa_version(ds->ds_dir->dd_pool->dp_spa) < |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2878 |
SPA_VERSION_REFRESERVATION) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2879 |
return (ENOTSUP); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2880 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2881 |
if (dsl_dataset_is_snapshot(ds)) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2882 |
return (EINVAL); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2883 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2884 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2885 |
* If we are doing the preliminary check in open context, the |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2886 |
* space estimates may be inaccurate. |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2887 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2888 |
if (!dmu_tx_is_syncing(tx)) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2889 |
return (0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2890 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2891 |
mutex_enter(&ds->ds_lock); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2892 |
unique = dsl_dataset_unique(ds); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2893 |
delta = MAX(unique, new_reservation) - MAX(unique, ds->ds_reserved); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2894 |
mutex_exit(&ds->ds_lock); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2895 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2896 |
if (delta > 0 && |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2897 |
delta > dsl_dir_space_available(ds->ds_dir, NULL, 0, TRUE)) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2898 |
return (ENOSPC); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2899 |
if (delta > 0 && ds->ds_quota > 0 && |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2900 |
new_reservation > ds->ds_quota) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2901 |
return (ENOSPC); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2902 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2903 |
return (0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2904 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2905 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2906 |
/* ARGSUSED */ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2907 |
static void |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2908 |
dsl_dataset_set_reservation_sync(void *arg1, void *arg2, cred_t *cr, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2909 |
dmu_tx_t *tx) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2910 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2911 |
dsl_dataset_t *ds = arg1; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2912 |
uint64_t *reservationp = arg2; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2913 |
uint64_t new_reservation = *reservationp; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2914 |
uint64_t unique; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2915 |
int64_t delta; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2916 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2917 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2918 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2919 |
mutex_enter(&ds->ds_lock); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2920 |
unique = dsl_dataset_unique(ds); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2921 |
delta = MAX(0, (int64_t)(new_reservation - unique)) - |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2922 |
MAX(0, (int64_t)(ds->ds_reserved - unique)); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2923 |
ds->ds_reserved = new_reservation; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2924 |
mutex_exit(&ds->ds_lock); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2925 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2926 |
dsl_prop_set_uint64_sync(ds->ds_dir, "refreservation", |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2927 |
new_reservation, cr, tx); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2928 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2929 |
dsl_dir_diduse_space(ds->ds_dir, delta, 0, 0, tx); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2930 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2931 |
spa_history_internal_log(LOG_DS_REFRESERV, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2932 |
ds->ds_dir->dd_pool->dp_spa, tx, cr, "%lld dataset = %llu", |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2933 |
(longlong_t)new_reservation, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2934 |
ds->ds_dir->dd_phys->dd_head_dataset_obj); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2935 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2936 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2937 |
int |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2938 |
dsl_dataset_set_reservation(const char *dsname, uint64_t reservation) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2939 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2940 |
dsl_dataset_t *ds; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2941 |
int err; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2942 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2943 |
err = dsl_dataset_hold(dsname, FTAG, &ds); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2944 |
if (err) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2945 |
return (err); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2946 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2947 |
err = dsl_sync_task_do(ds->ds_dir->dd_pool, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2948 |
dsl_dataset_set_reservation_check, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2949 |
dsl_dataset_set_reservation_sync, ds, &reservation, 0); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2950 |
dsl_dataset_rele(ds, FTAG); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2951 |
return (err); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2952 |
} |