author | Christopher Siden <chris.siden@delphix.com> |
Mon, 21 May 2012 12:11:39 -0700 | |
changeset 13700 | 2889e2596bd6 |
parent 13686 | 4bc0783f6064 |
child 13743 | 95aba6e49b9f |
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 |
/* |
|
12115
3655f38d3bea
6942295 use-after-free panic in dsl_dataset_user_release_one
Chris Kirby <Chris.Kirby@oracle.com>
parents:
11823
diff
changeset
|
22 |
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
23 |
* Copyright (c) 2012 by Delphix. All rights reserved. |
13686
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13524
diff
changeset
|
24 |
* Copyright (c) 2012, Joyent, Inc. All rights reserved. |
789 | 25 |
*/ |
26 |
||
27 |
#include <sys/dmu_objset.h> |
|
28 |
#include <sys/dsl_dataset.h> |
|
29 |
#include <sys/dsl_dir.h> |
|
2082 | 30 |
#include <sys/dsl_prop.h> |
2199 | 31 |
#include <sys/dsl_synctask.h> |
789 | 32 |
#include <sys/dmu_traverse.h> |
13686
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13524
diff
changeset
|
33 |
#include <sys/dmu_impl.h> |
789 | 34 |
#include <sys/dmu_tx.h> |
35 |
#include <sys/arc.h> |
|
36 |
#include <sys/zio.h> |
|
37 |
#include <sys/zap.h> |
|
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
38 |
#include <sys/zfeature.h> |
789 | 39 |
#include <sys/unique.h> |
40 |
#include <sys/zfs_context.h> |
|
4007 | 41 |
#include <sys/zfs_ioctl.h> |
4543 | 42 |
#include <sys/spa.h> |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
43 |
#include <sys/zfs_znode.h> |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12470
diff
changeset
|
44 |
#include <sys/zfs_onexit.h> |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
45 |
#include <sys/zvol.h> |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
46 |
#include <sys/dsl_scan.h> |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
47 |
#include <sys/dsl_deadlist.h> |
789 | 48 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
49 |
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
|
50 |
|
2199 | 51 |
static dsl_checkfunc_t dsl_dataset_destroy_begin_check; |
52 |
static dsl_syncfunc_t dsl_dataset_destroy_begin_sync; |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
53 |
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
|
54 |
|
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
55 |
#define SWITCH64(x, y) \ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
56 |
{ \ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
57 |
uint64_t __tmp = (x); \ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
58 |
(x) = (y); \ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
59 |
(y) = __tmp; \ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
60 |
} |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
61 |
|
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3025
diff
changeset
|
62 |
#define DS_REF_MAX (1ULL << 62) |
789 | 63 |
|
64 |
#define DSL_DEADLIST_BLOCKSIZE SPA_MAXBLOCKSIZE |
|
65 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
66 |
#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
|
67 |
|
789 | 68 |
|
5378
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 |
* 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
|
71 |
* 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
|
72 |
* partially accounted for in our ancestors. |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
73 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
74 |
static int64_t |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
75 |
parent_delta(dsl_dataset_t *ds, int64_t delta) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
76 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
77 |
uint64_t old_bytes, new_bytes; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
78 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
79 |
if (ds->ds_reserved == 0) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
80 |
return (delta); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
81 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
82 |
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
|
83 |
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
|
84 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
85 |
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
|
86 |
return (new_bytes - old_bytes); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
87 |
} |
789 | 88 |
|
89 |
void |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
90 |
dsl_dataset_block_born(dsl_dataset_t *ds, const blkptr_t *bp, dmu_tx_t *tx) |
789 | 91 |
{ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
92 |
int used = bp_get_dsize_sync(tx->tx_pool->dp_spa, bp); |
789 | 93 |
int compressed = BP_GET_PSIZE(bp); |
94 |
int uncompressed = BP_GET_UCSIZE(bp); |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
95 |
int64_t delta; |
789 | 96 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
97 |
dprintf_bp(bp, "ds=%p", ds); |
789 | 98 |
|
99 |
ASSERT(dmu_tx_is_syncing(tx)); |
|
100 |
/* It could have been compressed away to nothing */ |
|
101 |
if (BP_IS_HOLE(bp)) |
|
102 |
return; |
|
103 |
ASSERT(BP_GET_TYPE(bp) != DMU_OT_NONE); |
|
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
104 |
ASSERT(DMU_OT_IS_VALID(BP_GET_TYPE(bp))); |
789 | 105 |
if (ds == NULL) { |
106 |
/* |
|
107 |
* Account for the meta-objset space in its placeholder |
|
108 |
* dsl_dir. |
|
109 |
*/ |
|
110 |
ASSERT3U(compressed, ==, uncompressed); /* it's all metadata */ |
|
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
111 |
dsl_dir_diduse_space(tx->tx_pool->dp_mos_dir, DD_USED_HEAD, |
789 | 112 |
used, compressed, uncompressed, tx); |
113 |
dsl_dir_dirty(tx->tx_pool->dp_mos_dir, tx); |
|
114 |
return; |
|
115 |
} |
|
116 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
117 |
|
7595
2ff5700c7efc
6747355 finish closing race condition when setting refreservation
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7525
diff
changeset
|
118 |
mutex_enter(&ds->ds_dir->dd_lock); |
789 | 119 |
mutex_enter(&ds->ds_lock); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
120 |
delta = parent_delta(ds, used); |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
121 |
ds->ds_phys->ds_referenced_bytes += used; |
789 | 122 |
ds->ds_phys->ds_compressed_bytes += compressed; |
123 |
ds->ds_phys->ds_uncompressed_bytes += uncompressed; |
|
124 |
ds->ds_phys->ds_unique_bytes += used; |
|
125 |
mutex_exit(&ds->ds_lock); |
|
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
126 |
dsl_dir_diduse_space(ds->ds_dir, DD_USED_HEAD, delta, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
127 |
compressed, uncompressed, tx); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
128 |
dsl_dir_transfer_space(ds->ds_dir, used - delta, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
129 |
DD_USED_REFRSRV, DD_USED_HEAD, tx); |
7595
2ff5700c7efc
6747355 finish closing race condition when setting refreservation
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7525
diff
changeset
|
130 |
mutex_exit(&ds->ds_dir->dd_lock); |
789 | 131 |
} |
132 |
||
6992 | 133 |
int |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
134 |
dsl_dataset_block_kill(dsl_dataset_t *ds, const blkptr_t *bp, dmu_tx_t *tx, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
135 |
boolean_t async) |
789 | 136 |
{ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
137 |
if (BP_IS_HOLE(bp)) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
138 |
return (0); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
139 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
140 |
ASSERT(dmu_tx_is_syncing(tx)); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
141 |
ASSERT(bp->blk_birth <= tx->tx_txg); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
142 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
143 |
int used = bp_get_dsize_sync(tx->tx_pool->dp_spa, bp); |
789 | 144 |
int compressed = BP_GET_PSIZE(bp); |
145 |
int uncompressed = BP_GET_UCSIZE(bp); |
|
146 |
||
147 |
ASSERT(used > 0); |
|
148 |
if (ds == NULL) { |
|
149 |
/* |
|
150 |
* Account for the meta-objset space in its placeholder |
|
151 |
* dataset. |
|
152 |
*/ |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
153 |
dsl_free(tx->tx_pool, tx->tx_txg, bp); |
789 | 154 |
|
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
155 |
dsl_dir_diduse_space(tx->tx_pool->dp_mos_dir, DD_USED_HEAD, |
789 | 156 |
-used, -compressed, -uncompressed, tx); |
157 |
dsl_dir_dirty(tx->tx_pool->dp_mos_dir, tx); |
|
6992 | 158 |
return (used); |
789 | 159 |
} |
160 |
ASSERT3P(tx->tx_pool, ==, ds->ds_dir->dd_pool); |
|
161 |
||
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
162 |
ASSERT(!dsl_dataset_is_snapshot(ds)); |
789 | 163 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
164 |
||
165 |
if (bp->blk_birth > ds->ds_phys->ds_prev_snap_txg) { |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
166 |
int64_t delta; |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
167 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
168 |
dprintf_bp(bp, "freeing ds=%llu", ds->ds_object); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
169 |
dsl_free(tx->tx_pool, tx->tx_txg, bp); |
789 | 170 |
|
7595
2ff5700c7efc
6747355 finish closing race condition when setting refreservation
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7525
diff
changeset
|
171 |
mutex_enter(&ds->ds_dir->dd_lock); |
789 | 172 |
mutex_enter(&ds->ds_lock); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
173 |
ASSERT(ds->ds_phys->ds_unique_bytes >= used || |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
174 |
!DS_UNIQUE_IS_ACCURATE(ds)); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
175 |
delta = parent_delta(ds, -used); |
789 | 176 |
ds->ds_phys->ds_unique_bytes -= used; |
177 |
mutex_exit(&ds->ds_lock); |
|
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
178 |
dsl_dir_diduse_space(ds->ds_dir, DD_USED_HEAD, |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
179 |
delta, -compressed, -uncompressed, tx); |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
180 |
dsl_dir_transfer_space(ds->ds_dir, -used - delta, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
181 |
DD_USED_REFRSRV, DD_USED_HEAD, tx); |
7595
2ff5700c7efc
6747355 finish closing race condition when setting refreservation
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7525
diff
changeset
|
182 |
mutex_exit(&ds->ds_dir->dd_lock); |
789 | 183 |
} else { |
184 |
dprintf_bp(bp, "putting on dead list: %s", ""); |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
185 |
if (async) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
186 |
/* |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
187 |
* We are here as part of zio's write done callback, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
188 |
* which means we're a zio interrupt thread. We can't |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
189 |
* call dsl_deadlist_insert() now because it may block |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
190 |
* waiting for I/O. Instead, put bp on the deferred |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
191 |
* queue and let dsl_pool_sync() finish the job. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
192 |
*/ |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
193 |
bplist_append(&ds->ds_pending_deadlist, bp); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
194 |
} else { |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
195 |
dsl_deadlist_insert(&ds->ds_deadlist, bp, tx); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
196 |
} |
5712
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5569
diff
changeset
|
197 |
ASSERT3U(ds->ds_prev->ds_object, ==, |
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5569
diff
changeset
|
198 |
ds->ds_phys->ds_prev_snap_obj); |
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5569
diff
changeset
|
199 |
ASSERT(ds->ds_prev->ds_phys->ds_num_children > 0); |
789 | 200 |
/* 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
|
201 |
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
|
202 |
ds->ds_object && bp->blk_birth > |
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5569
diff
changeset
|
203 |
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
|
204 |
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
|
205 |
mutex_enter(&ds->ds_prev->ds_lock); |
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5569
diff
changeset
|
206 |
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
|
207 |
mutex_exit(&ds->ds_prev->ds_lock); |
789 | 208 |
} |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
209 |
if (bp->blk_birth > ds->ds_dir->dd_origin_txg) { |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
210 |
dsl_dir_transfer_space(ds->ds_dir, used, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
211 |
DD_USED_HEAD, DD_USED_SNAP, tx); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
212 |
} |
789 | 213 |
} |
214 |
mutex_enter(&ds->ds_lock); |
|
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
215 |
ASSERT3U(ds->ds_phys->ds_referenced_bytes, >=, used); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
216 |
ds->ds_phys->ds_referenced_bytes -= used; |
789 | 217 |
ASSERT3U(ds->ds_phys->ds_compressed_bytes, >=, compressed); |
218 |
ds->ds_phys->ds_compressed_bytes -= compressed; |
|
219 |
ASSERT3U(ds->ds_phys->ds_uncompressed_bytes, >=, uncompressed); |
|
220 |
ds->ds_phys->ds_uncompressed_bytes -= uncompressed; |
|
221 |
mutex_exit(&ds->ds_lock); |
|
6992 | 222 |
|
223 |
return (used); |
|
789 | 224 |
} |
225 |
||
1544 | 226 |
uint64_t |
227 |
dsl_dataset_prev_snap_txg(dsl_dataset_t *ds) |
|
789 | 228 |
{ |
2885 | 229 |
uint64_t trysnap = 0; |
230 |
||
789 | 231 |
if (ds == NULL) |
1544 | 232 |
return (0); |
789 | 233 |
/* |
234 |
* The snapshot creation could fail, but that would cause an |
|
235 |
* incorrect FALSE return, which would only result in an |
|
236 |
* overestimation of the amount of space that an operation would |
|
237 |
* consume, which is OK. |
|
238 |
* |
|
239 |
* There's also a small window where we could miss a pending |
|
240 |
* snapshot, because we could set the sync task in the quiescing |
|
241 |
* phase. So this should only be used as a guess. |
|
242 |
*/ |
|
2885 | 243 |
if (ds->ds_trysnap_txg > |
244 |
spa_last_synced_txg(ds->ds_dir->dd_pool->dp_spa)) |
|
245 |
trysnap = ds->ds_trysnap_txg; |
|
246 |
return (MAX(ds->ds_phys->ds_prev_snap_txg, trysnap)); |
|
1544 | 247 |
} |
248 |
||
9653
a70048a304d1
6664765 Unable to remove files when using fat-zap and quota exceeded on ZFS filesystem
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
9396
diff
changeset
|
249 |
boolean_t |
12450
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
250 |
dsl_dataset_block_freeable(dsl_dataset_t *ds, const blkptr_t *bp, |
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
251 |
uint64_t blk_birth) |
1544 | 252 |
{ |
12450
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
253 |
if (blk_birth <= dsl_dataset_prev_snap_txg(ds)) |
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
254 |
return (B_FALSE); |
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
255 |
|
12587
16aef3d16470
6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents:
12527
diff
changeset
|
256 |
ddt_prefetch(dsl_dataset_get_spa(ds), bp); |
12450
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
257 |
|
c77e20e4e046
6938089 dedup-induced latency causes FC initiator logouts/FC port resets
George Wilson <George.Wilson@Sun.COM>
parents:
12296
diff
changeset
|
258 |
return (B_TRUE); |
789 | 259 |
} |
260 |
||
261 |
/* ARGSUSED */ |
|
262 |
static void |
|
263 |
dsl_dataset_evict(dmu_buf_t *db, void *dsv) |
|
264 |
{ |
|
265 |
dsl_dataset_t *ds = dsv; |
|
266 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
267 |
ASSERT(ds->ds_owner == NULL || DSL_DATASET_IS_DESTROYED(ds)); |
789 | 268 |
|
4787 | 269 |
unique_remove(ds->ds_fsid_guid); |
789 | 270 |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
271 |
if (ds->ds_objset != NULL) |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
272 |
dmu_objset_evict(ds->ds_objset); |
789 | 273 |
|
274 |
if (ds->ds_prev) { |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
275 |
dsl_dataset_drop_ref(ds->ds_prev, ds); |
789 | 276 |
ds->ds_prev = NULL; |
277 |
} |
|
278 |
||
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
279 |
bplist_destroy(&ds->ds_pending_deadlist); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
280 |
if (db != NULL) { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
281 |
dsl_deadlist_close(&ds->ds_deadlist); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
282 |
} else { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
283 |
ASSERT(ds->ds_deadlist.dl_dbuf == NULL); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
284 |
ASSERT(!ds->ds_deadlist.dl_oldfmt); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
285 |
} |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
286 |
if (ds->ds_dir) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
287 |
dsl_dir_close(ds->ds_dir, ds); |
789 | 288 |
|
4787 | 289 |
ASSERT(!list_link_active(&ds->ds_synced_link)); |
789 | 290 |
|
2856 | 291 |
mutex_destroy(&ds->ds_lock); |
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10002
diff
changeset
|
292 |
mutex_destroy(&ds->ds_recvlock); |
4787 | 293 |
mutex_destroy(&ds->ds_opening_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
294 |
rw_destroy(&ds->ds_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
295 |
cv_destroy(&ds->ds_exclusive_cv); |
2856 | 296 |
|
789 | 297 |
kmem_free(ds, sizeof (dsl_dataset_t)); |
298 |
} |
|
299 |
||
1544 | 300 |
static int |
789 | 301 |
dsl_dataset_get_snapname(dsl_dataset_t *ds) |
302 |
{ |
|
303 |
dsl_dataset_phys_t *headphys; |
|
304 |
int err; |
|
305 |
dmu_buf_t *headdbuf; |
|
306 |
dsl_pool_t *dp = ds->ds_dir->dd_pool; |
|
307 |
objset_t *mos = dp->dp_meta_objset; |
|
308 |
||
309 |
if (ds->ds_snapname[0]) |
|
1544 | 310 |
return (0); |
789 | 311 |
if (ds->ds_phys->ds_next_snap_obj == 0) |
1544 | 312 |
return (0); |
789 | 313 |
|
1544 | 314 |
err = dmu_bonus_hold(mos, ds->ds_dir->dd_phys->dd_head_dataset_obj, |
315 |
FTAG, &headdbuf); |
|
316 |
if (err) |
|
317 |
return (err); |
|
789 | 318 |
headphys = headdbuf->db_data; |
319 |
err = zap_value_search(dp->dp_meta_objset, |
|
4577 | 320 |
headphys->ds_snapnames_zapobj, ds->ds_object, 0, ds->ds_snapname); |
1544 | 321 |
dmu_buf_rele(headdbuf, FTAG); |
322 |
return (err); |
|
789 | 323 |
} |
324 |
||
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
325 |
static int |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
326 |
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
|
327 |
{ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
328 |
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
|
329 |
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
|
330 |
matchtype_t mt; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
331 |
int err; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
332 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
333 |
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
|
334 |
mt = MT_FIRST; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
335 |
else |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
336 |
mt = MT_EXACT; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
337 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
338 |
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
|
339 |
value, mt, NULL, 0, NULL); |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
340 |
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
|
341 |
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
|
342 |
return (err); |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
343 |
} |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
344 |
|
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
345 |
static int |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
346 |
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
|
347 |
{ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
348 |
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
|
349 |
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
|
350 |
matchtype_t mt; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
351 |
int err; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
352 |
|
10373
bcf97ee54990
6395956 snapshot dir needs real c/mtime
Chris Kirby <chris.kirby@sun.com>
parents:
10342
diff
changeset
|
353 |
dsl_dir_snap_cmtime_update(ds->ds_dir); |
bcf97ee54990
6395956 snapshot dir needs real c/mtime
Chris Kirby <chris.kirby@sun.com>
parents:
10342
diff
changeset
|
354 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
355 |
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
|
356 |
mt = MT_FIRST; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
357 |
else |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
358 |
mt = MT_EXACT; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
359 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
360 |
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
|
361 |
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
|
362 |
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
|
363 |
return (err); |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
364 |
} |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
365 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
366 |
static int |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
367 |
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
|
368 |
dsl_dataset_t **dsp) |
789 | 369 |
{ |
370 |
objset_t *mos = dp->dp_meta_objset; |
|
371 |
dmu_buf_t *dbuf; |
|
372 |
dsl_dataset_t *ds; |
|
1544 | 373 |
int err; |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
374 |
dmu_object_info_t doi; |
789 | 375 |
|
376 |
ASSERT(RW_LOCK_HELD(&dp->dp_config_rwlock) || |
|
377 |
dsl_pool_sync_context(dp)); |
|
378 |
||
1544 | 379 |
err = dmu_bonus_hold(mos, dsobj, tag, &dbuf); |
380 |
if (err) |
|
381 |
return (err); |
|
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
382 |
|
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
383 |
/* Make sure dsobj has the correct object type. */ |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
384 |
dmu_object_info_from_db(dbuf, &doi); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
385 |
if (doi.doi_type != DMU_OT_DSL_DATASET) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
386 |
return (EINVAL); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
387 |
|
789 | 388 |
ds = dmu_buf_get_user(dbuf); |
389 |
if (ds == NULL) { |
|
390 |
dsl_dataset_t *winner; |
|
391 |
||
392 |
ds = kmem_zalloc(sizeof (dsl_dataset_t), KM_SLEEP); |
|
393 |
ds->ds_dbuf = dbuf; |
|
394 |
ds->ds_object = dsobj; |
|
395 |
ds->ds_phys = dbuf->db_data; |
|
396 |
||
2856 | 397 |
mutex_init(&ds->ds_lock, NULL, MUTEX_DEFAULT, NULL); |
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10002
diff
changeset
|
398 |
mutex_init(&ds->ds_recvlock, NULL, MUTEX_DEFAULT, NULL); |
4787 | 399 |
mutex_init(&ds->ds_opening_lock, NULL, MUTEX_DEFAULT, NULL); |
13686
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13524
diff
changeset
|
400 |
mutex_init(&ds->ds_sendstream_lock, NULL, MUTEX_DEFAULT, NULL); |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13524
diff
changeset
|
401 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
402 |
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
|
403 |
cv_init(&ds->ds_exclusive_cv, NULL, CV_DEFAULT, NULL); |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
404 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
405 |
bplist_create(&ds->ds_pending_deadlist); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
406 |
dsl_deadlist_open(&ds->ds_deadlist, |
789 | 407 |
mos, ds->ds_phys->ds_deadlist_obj); |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
408 |
|
13686
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13524
diff
changeset
|
409 |
list_create(&ds->ds_sendstreams, sizeof (dmu_sendarg_t), |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13524
diff
changeset
|
410 |
offsetof(dmu_sendarg_t, dsa_link)); |
4bc0783f6064
2703 add mechanism to report ZFS send progress
Bill Pijewski <wdp@joyent.com>
parents:
13524
diff
changeset
|
411 |
|
1544 | 412 |
if (err == 0) { |
413 |
err = dsl_dir_open_obj(dp, |
|
414 |
ds->ds_phys->ds_dir_obj, NULL, ds, &ds->ds_dir); |
|
415 |
} |
|
416 |
if (err) { |
|
2856 | 417 |
mutex_destroy(&ds->ds_lock); |
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10002
diff
changeset
|
418 |
mutex_destroy(&ds->ds_recvlock); |
4787 | 419 |
mutex_destroy(&ds->ds_opening_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
420 |
rw_destroy(&ds->ds_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
421 |
cv_destroy(&ds->ds_exclusive_cv); |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
422 |
bplist_destroy(&ds->ds_pending_deadlist); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
423 |
dsl_deadlist_close(&ds->ds_deadlist); |
1544 | 424 |
kmem_free(ds, sizeof (dsl_dataset_t)); |
425 |
dmu_buf_rele(dbuf, tag); |
|
426 |
return (err); |
|
427 |
} |
|
789 | 428 |
|
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
429 |
if (!dsl_dataset_is_snapshot(ds)) { |
789 | 430 |
ds->ds_snapname[0] = '\0'; |
431 |
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
|
432 |
err = dsl_dataset_get_ref(dp, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
433 |
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
|
434 |
ds, &ds->ds_prev); |
789 | 435 |
} |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
436 |
} else { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
437 |
if (zfs_flags & ZFS_DEBUG_SNAPNAMES) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
438 |
err = dsl_dataset_get_snapname(ds); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
439 |
if (err == 0 && ds->ds_phys->ds_userrefs_obj != 0) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
440 |
err = zap_count( |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
441 |
ds->ds_dir->dd_pool->dp_meta_objset, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
442 |
ds->ds_phys->ds_userrefs_obj, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
443 |
&ds->ds_userrefs); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
444 |
} |
789 | 445 |
} |
446 |
||
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
447 |
if (err == 0 && !dsl_dataset_is_snapshot(ds)) { |
5569
d3caac36d311
6634062 dsl_dataset_open_obj misuses RW_LOCK_HELD
ck153898
parents:
5518
diff
changeset
|
448 |
/* |
d3caac36d311
6634062 dsl_dataset_open_obj misuses RW_LOCK_HELD
ck153898
parents:
5518
diff
changeset
|
449 |
* 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
|
450 |
* 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
|
451 |
* we're always called with the read lock held. |
d3caac36d311
6634062 dsl_dataset_open_obj misuses RW_LOCK_HELD
ck153898
parents:
5518
diff
changeset
|
452 |
*/ |
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
|
453 |
boolean_t need_lock = |
5569
d3caac36d311
6634062 dsl_dataset_open_obj misuses RW_LOCK_HELD
ck153898
parents:
5518
diff
changeset
|
454 |
!RW_WRITE_HELD(&dp->dp_config_rwlock) && |
d3caac36d311
6634062 dsl_dataset_open_obj misuses RW_LOCK_HELD
ck153898
parents:
5518
diff
changeset
|
455 |
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
|
456 |
|
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
457 |
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
|
458 |
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
|
459 |
|
7265 | 460 |
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
|
461 |
"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
|
462 |
&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
|
463 |
if (err == 0) { |
7265 | 464 |
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
|
465 |
"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
|
466 |
&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
|
467 |
} |
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
468 |
|
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
469 |
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
|
470 |
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
|
471 |
} 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
|
472 |
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
|
473 |
} |
e140313199cc
6626338 assertion failed: 0 == dsl_prop_get_ds_locked(ds->ds_dir, "refreservation", sizeof (uint64_t), 1, &d
ck153898
parents:
5446
diff
changeset
|
474 |
|
1544 | 475 |
if (err == 0) { |
476 |
winner = dmu_buf_set_user_ie(dbuf, ds, &ds->ds_phys, |
|
477 |
dsl_dataset_evict); |
|
478 |
} |
|
479 |
if (err || winner) { |
|
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
480 |
bplist_destroy(&ds->ds_pending_deadlist); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
481 |
dsl_deadlist_close(&ds->ds_deadlist); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
482 |
if (ds->ds_prev) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
483 |
dsl_dataset_drop_ref(ds->ds_prev, ds); |
789 | 484 |
dsl_dir_close(ds->ds_dir, ds); |
2856 | 485 |
mutex_destroy(&ds->ds_lock); |
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10002
diff
changeset
|
486 |
mutex_destroy(&ds->ds_recvlock); |
4787 | 487 |
mutex_destroy(&ds->ds_opening_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
488 |
rw_destroy(&ds->ds_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
489 |
cv_destroy(&ds->ds_exclusive_cv); |
789 | 490 |
kmem_free(ds, sizeof (dsl_dataset_t)); |
1544 | 491 |
if (err) { |
492 |
dmu_buf_rele(dbuf, tag); |
|
493 |
return (err); |
|
494 |
} |
|
789 | 495 |
ds = winner; |
496 |
} else { |
|
4787 | 497 |
ds->ds_fsid_guid = |
789 | 498 |
unique_insert(ds->ds_phys->ds_fsid_guid); |
499 |
} |
|
500 |
} |
|
501 |
ASSERT3P(ds->ds_dbuf, ==, dbuf); |
|
502 |
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
|
503 |
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
|
504 |
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
|
505 |
dp->dp_origin_snap == NULL || ds == dp->dp_origin_snap); |
789 | 506 |
mutex_enter(&ds->ds_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
507 |
if (!dsl_pool_sync_context(dp) && DSL_DATASET_IS_DESTROYED(ds)) { |
789 | 508 |
mutex_exit(&ds->ds_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
509 |
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
|
510 |
return (ENOENT); |
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 |
mutex_exit(&ds->ds_lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
513 |
*dsp = ds; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
514 |
return (0); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
515 |
} |
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 |
static int |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
518 |
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
|
519 |
{ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
520 |
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
|
521 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
522 |
/* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
523 |
* 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
|
524 |
* 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
|
525 |
* 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
|
526 |
* 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
|
527 |
* doing anything while we are active. |
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 |
if (dsl_pool_sync_context(dp)) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
530 |
ASSERT(!DSL_DATASET_IS_DESTROYED(ds)); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
531 |
return (0); |
789 | 532 |
} |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
533 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
534 |
/* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
535 |
* 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
|
536 |
* 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
|
537 |
* 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
|
538 |
* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
539 |
* 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
|
540 |
* 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
|
541 |
* 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
|
542 |
* 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
|
543 |
* 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
|
544 |
* the dataset is determined. |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
545 |
*/ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
546 |
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
|
547 |
mutex_enter(&ds->ds_lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
548 |
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
|
549 |
rw_exit(&dp->dp_config_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
550 |
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
|
551 |
if (DSL_DATASET_IS_DESTROYED(ds)) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
552 |
mutex_exit(&ds->ds_lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
553 |
dsl_dataset_drop_ref(ds, tag); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
554 |
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
|
555 |
return (ENOENT); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
556 |
} |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
557 |
/* |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
558 |
* The dp_config_rwlock lives above the ds_lock. And |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
559 |
* we need to check DSL_DATASET_IS_DESTROYED() while |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
560 |
* holding the ds_lock, so we have to drop and reacquire |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
561 |
* the ds_lock here. |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
562 |
*/ |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
563 |
mutex_exit(&ds->ds_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
564 |
rw_enter(&dp->dp_config_rwlock, RW_READER); |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
565 |
mutex_enter(&ds->ds_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
566 |
} |
789 | 567 |
mutex_exit(&ds->ds_lock); |
1544 | 568 |
return (0); |
789 | 569 |
} |
570 |
||
571 |
int |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
572 |
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
|
573 |
dsl_dataset_t **dsp) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
574 |
{ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
575 |
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
|
576 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
577 |
if (err) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
578 |
return (err); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
579 |
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
|
580 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
581 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
582 |
int |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
583 |
dsl_dataset_own_obj(dsl_pool_t *dp, uint64_t dsobj, boolean_t inconsistentok, |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
584 |
void *tag, dsl_dataset_t **dsp) |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
585 |
{ |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
586 |
int err = dsl_dataset_hold_obj(dp, dsobj, tag, dsp); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
587 |
if (err) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
588 |
return (err); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
589 |
if (!dsl_dataset_tryown(*dsp, inconsistentok, tag)) { |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
590 |
dsl_dataset_rele(*dsp, tag); |
8779
f164e0e90508
6784924 panic while ludelete (zfs destroy)
Mark J Musante <Mark.Musante@Sun.COM>
parents:
8746
diff
changeset
|
591 |
*dsp = NULL; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
592 |
return (EBUSY); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
593 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
594 |
return (0); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
595 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
596 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
597 |
int |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
598 |
dsl_dataset_hold(const char *name, void *tag, dsl_dataset_t **dsp) |
789 | 599 |
{ |
600 |
dsl_dir_t *dd; |
|
601 |
dsl_pool_t *dp; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
602 |
const char *snapname; |
789 | 603 |
uint64_t obj; |
604 |
int err = 0; |
|
605 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
606 |
err = dsl_dir_open_spa(NULL, name, FTAG, &dd, &snapname); |
1544 | 607 |
if (err) |
608 |
return (err); |
|
789 | 609 |
|
610 |
dp = dd->dd_pool; |
|
611 |
obj = dd->dd_phys->dd_head_dataset_obj; |
|
612 |
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
|
613 |
if (obj) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
614 |
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
|
615 |
else |
789 | 616 |
err = ENOENT; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
617 |
if (err) |
789 | 618 |
goto out; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
619 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
620 |
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
|
621 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
622 |
/* 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
|
623 |
if (err == 0 && snapname != NULL) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
624 |
dsl_dataset_t *ds = NULL; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
625 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
626 |
if (*snapname++ != '@') { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
627 |
dsl_dataset_rele(*dsp, tag); |
789 | 628 |
err = ENOENT; |
629 |
goto out; |
|
630 |
} |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
631 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
632 |
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
|
633 |
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
|
634 |
if (err == 0) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
635 |
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
|
636 |
dsl_dataset_rele(*dsp, tag); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
637 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
638 |
ASSERT3U((err == 0), ==, (ds != NULL)); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
639 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
640 |
if (ds) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
641 |
mutex_enter(&ds->ds_lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
642 |
if (ds->ds_snapname[0] == 0) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
643 |
(void) strlcpy(ds->ds_snapname, snapname, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
644 |
sizeof (ds->ds_snapname)); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
645 |
mutex_exit(&ds->ds_lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
646 |
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
|
647 |
*dsp = err ? NULL : ds; |
789 | 648 |
} |
649 |
} |
|
650 |
out: |
|
651 |
rw_exit(&dp->dp_config_rwlock); |
|
652 |
dsl_dir_close(dd, FTAG); |
|
653 |
return (err); |
|
654 |
} |
|
655 |
||
656 |
int |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
657 |
dsl_dataset_own(const char *name, boolean_t inconsistentok, |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
658 |
void *tag, dsl_dataset_t **dsp) |
789 | 659 |
{ |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
660 |
int err = dsl_dataset_hold(name, tag, dsp); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
661 |
if (err) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
662 |
return (err); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
663 |
if (!dsl_dataset_tryown(*dsp, inconsistentok, tag)) { |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
664 |
dsl_dataset_rele(*dsp, tag); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
665 |
return (EBUSY); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
666 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
667 |
return (0); |
789 | 668 |
} |
669 |
||
670 |
void |
|
671 |
dsl_dataset_name(dsl_dataset_t *ds, char *name) |
|
672 |
{ |
|
673 |
if (ds == NULL) { |
|
674 |
(void) strcpy(name, "mos"); |
|
675 |
} else { |
|
676 |
dsl_dir_name(ds->ds_dir, name); |
|
1544 | 677 |
VERIFY(0 == dsl_dataset_get_snapname(ds)); |
789 | 678 |
if (ds->ds_snapname[0]) { |
679 |
(void) strcat(name, "@"); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
680 |
/* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
681 |
* 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
|
682 |
* 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
|
683 |
*/ |
789 | 684 |
if (!MUTEX_HELD(&ds->ds_lock)) { |
685 |
mutex_enter(&ds->ds_lock); |
|
686 |
(void) strcat(name, ds->ds_snapname); |
|
687 |
mutex_exit(&ds->ds_lock); |
|
688 |
} else { |
|
689 |
(void) strcat(name, ds->ds_snapname); |
|
690 |
} |
|
691 |
} |
|
692 |
} |
|
693 |
} |
|
694 |
||
3978
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
695 |
static int |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
696 |
dsl_dataset_namelen(dsl_dataset_t *ds) |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
697 |
{ |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
698 |
int result; |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
699 |
|
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
700 |
if (ds == NULL) { |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
701 |
result = 3; /* "mos" */ |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
702 |
} else { |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
703 |
result = dsl_dir_namelen(ds->ds_dir); |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
704 |
VERIFY(0 == dsl_dataset_get_snapname(ds)); |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
705 |
if (ds->ds_snapname[0]) { |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
706 |
++result; /* adding one for the @-sign */ |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
707 |
if (!MUTEX_HELD(&ds->ds_lock)) { |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
708 |
mutex_enter(&ds->ds_lock); |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
709 |
result += strlen(ds->ds_snapname); |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
710 |
mutex_exit(&ds->ds_lock); |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
711 |
} else { |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
712 |
result += strlen(ds->ds_snapname); |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
713 |
} |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
714 |
} |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
715 |
} |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
716 |
|
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
717 |
return (result); |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
718 |
} |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
719 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
720 |
void |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
721 |
dsl_dataset_drop_ref(dsl_dataset_t *ds, void *tag) |
789 | 722 |
{ |
1544 | 723 |
dmu_buf_rele(ds->ds_dbuf, tag); |
789 | 724 |
} |
725 |
||
726 |
void |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
727 |
dsl_dataset_rele(dsl_dataset_t *ds, void *tag) |
5367 | 728 |
{ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
729 |
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
|
730 |
rw_exit(&ds->ds_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
731 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
732 |
dsl_dataset_drop_ref(ds, tag); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
733 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
734 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
735 |
void |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
736 |
dsl_dataset_disown(dsl_dataset_t *ds, void *tag) |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
737 |
{ |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
738 |
ASSERT((ds->ds_owner == tag && ds->ds_dbuf) || |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
739 |
(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
|
740 |
|
5367 | 741 |
mutex_enter(&ds->ds_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
742 |
ds->ds_owner = NULL; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
743 |
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
|
744 |
rw_exit(&ds->ds_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
745 |
cv_broadcast(&ds->ds_exclusive_cv); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
746 |
} |
5367 | 747 |
mutex_exit(&ds->ds_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
748 |
if (ds->ds_dbuf) |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
749 |
dsl_dataset_drop_ref(ds, tag); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
750 |
else |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
751 |
dsl_dataset_evict(NULL, ds); |
5367 | 752 |
} |
753 |
||
754 |
boolean_t |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
755 |
dsl_dataset_tryown(dsl_dataset_t *ds, boolean_t inconsistentok, void *tag) |
5367 | 756 |
{ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
757 |
boolean_t gotit = FALSE; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
758 |
|
5367 | 759 |
mutex_enter(&ds->ds_lock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
760 |
if (ds->ds_owner == NULL && |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
761 |
(!DS_IS_INCONSISTENT(ds) || inconsistentok)) { |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
762 |
ds->ds_owner = tag; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
763 |
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
|
764 |
rw_exit(&ds->ds_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
765 |
gotit = TRUE; |
5367 | 766 |
} |
767 |
mutex_exit(&ds->ds_lock); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
768 |
return (gotit); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
769 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
770 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
771 |
void |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
772 |
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
|
773 |
{ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
774 |
ASSERT3P(owner, ==, ds->ds_owner); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
775 |
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
|
776 |
rw_enter(&ds->ds_rwlock, RW_WRITER); |
5367 | 777 |
} |
778 |
||
2199 | 779 |
uint64_t |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
780 |
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
|
781 |
uint64_t flags, dmu_tx_t *tx) |
789 | 782 |
{ |
5367 | 783 |
dsl_pool_t *dp = dd->dd_pool; |
789 | 784 |
dmu_buf_t *dbuf; |
785 |
dsl_dataset_phys_t *dsphys; |
|
5367 | 786 |
uint64_t dsobj; |
789 | 787 |
objset_t *mos = dp->dp_meta_objset; |
788 |
||
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
789 |
if (origin == NULL) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
790 |
origin = dp->dp_origin_snap; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
791 |
|
5367 | 792 |
ASSERT(origin == NULL || origin->ds_dir->dd_pool == dp); |
793 |
ASSERT(origin == NULL || origin->ds_phys->ds_num_children > 0); |
|
789 | 794 |
ASSERT(dmu_tx_is_syncing(tx)); |
5367 | 795 |
ASSERT(dd->dd_phys->dd_head_dataset_obj == 0); |
789 | 796 |
|
928
36d72fe4da29
6349314 dmu_object_type names incorrect for DSL Directories and DSL Datasets
tabriz
parents:
885
diff
changeset
|
797 |
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
|
798 |
DMU_OT_DSL_DATASET, sizeof (dsl_dataset_phys_t), tx); |
1544 | 799 |
VERIFY(0 == dmu_bonus_hold(mos, dsobj, FTAG, &dbuf)); |
789 | 800 |
dmu_buf_will_dirty(dbuf, tx); |
801 |
dsphys = dbuf->db_data; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
802 |
bzero(dsphys, sizeof (dsl_dataset_phys_t)); |
789 | 803 |
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
|
804 |
dsphys->ds_flags = flags; |
789 | 805 |
dsphys->ds_fsid_guid = unique_create(); |
806 |
(void) random_get_pseudo_bytes((void*)&dsphys->ds_guid, |
|
807 |
sizeof (dsphys->ds_guid)); |
|
808 |
dsphys->ds_snapnames_zapobj = |
|
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
809 |
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
|
810 |
DMU_OT_NONE, 0, tx); |
789 | 811 |
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
|
812 |
dsphys->ds_creation_txg = tx->tx_txg == TXG_INITIAL ? 1 : tx->tx_txg; |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
813 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
814 |
if (origin == NULL) { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
815 |
dsphys->ds_deadlist_obj = dsl_deadlist_alloc(mos, tx); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
816 |
} else { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
817 |
dsl_dataset_t *ohds; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
818 |
|
5367 | 819 |
dsphys->ds_prev_snap_obj = origin->ds_object; |
789 | 820 |
dsphys->ds_prev_snap_txg = |
5367 | 821 |
origin->ds_phys->ds_creation_txg; |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
822 |
dsphys->ds_referenced_bytes = |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
823 |
origin->ds_phys->ds_referenced_bytes; |
789 | 824 |
dsphys->ds_compressed_bytes = |
5367 | 825 |
origin->ds_phys->ds_compressed_bytes; |
789 | 826 |
dsphys->ds_uncompressed_bytes = |
5367 | 827 |
origin->ds_phys->ds_uncompressed_bytes; |
828 |
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
|
829 |
dsphys->ds_flags |= origin->ds_phys->ds_flags; |
789 | 830 |
|
5367 | 831 |
dmu_buf_will_dirty(origin->ds_dbuf, tx); |
832 |
origin->ds_phys->ds_num_children++; |
|
789 | 833 |
|
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
834 |
VERIFY3U(0, ==, dsl_dataset_hold_obj(dp, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
835 |
origin->ds_dir->dd_phys->dd_head_dataset_obj, FTAG, &ohds)); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
836 |
dsphys->ds_deadlist_obj = dsl_deadlist_clone(&ohds->ds_deadlist, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
837 |
dsphys->ds_prev_snap_txg, dsphys->ds_prev_snap_obj, tx); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
838 |
dsl_dataset_rele(ohds, FTAG); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
839 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
840 |
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
|
841 |
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
|
842 |
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
|
843 |
zap_create(mos, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
844 |
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
|
845 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
846 |
VERIFY(0 == zap_add_int(mos, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
847 |
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
|
848 |
dsobj, tx)); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
849 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
850 |
|
789 | 851 |
dmu_buf_will_dirty(dd->dd_dbuf, tx); |
5367 | 852 |
dd->dd_phys->dd_origin_obj = origin->ds_object; |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
853 |
if (spa_version(dp->dp_spa) >= SPA_VERSION_DIR_CLONES) { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
854 |
if (origin->ds_dir->dd_phys->dd_clones == 0) { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
855 |
dmu_buf_will_dirty(origin->ds_dir->dd_dbuf, tx); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
856 |
origin->ds_dir->dd_phys->dd_clones = |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
857 |
zap_create(mos, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
858 |
DMU_OT_DSL_CLONES, DMU_OT_NONE, 0, tx); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
859 |
} |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
860 |
VERIFY3U(0, ==, zap_add_int(mos, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
861 |
origin->ds_dir->dd_phys->dd_clones, dsobj, tx)); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
862 |
} |
789 | 863 |
} |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
864 |
|
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
865 |
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
|
866 |
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
|
867 |
|
1544 | 868 |
dmu_buf_rele(dbuf, FTAG); |
789 | 869 |
|
870 |
dmu_buf_will_dirty(dd->dd_dbuf, tx); |
|
871 |
dd->dd_phys->dd_head_dataset_obj = dsobj; |
|
5367 | 872 |
|
873 |
return (dsobj); |
|
874 |
} |
|
875 |
||
876 |
uint64_t |
|
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
877 |
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
|
878 |
dsl_dataset_t *origin, uint64_t flags, cred_t *cr, dmu_tx_t *tx) |
5367 | 879 |
{ |
880 |
dsl_pool_t *dp = pdd->dd_pool; |
|
881 |
uint64_t dsobj, ddobj; |
|
882 |
dsl_dir_t *dd; |
|
883 |
||
884 |
ASSERT(lastname[0] != '@'); |
|
885 |
||
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
886 |
ddobj = dsl_dir_create_sync(dp, pdd, lastname, tx); |
5367 | 887 |
VERIFY(0 == dsl_dir_open_obj(dp, ddobj, lastname, FTAG, &dd)); |
888 |
||
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
889 |
dsobj = dsl_dataset_create_sync_dd(dd, origin, flags, tx); |
5367 | 890 |
|
891 |
dsl_deleg_set_create_perms(dd, tx, cr); |
|
892 |
||
789 | 893 |
dsl_dir_close(dd, FTAG); |
894 |
||
12982
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
895 |
/* |
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
896 |
* If we are creating a clone, make sure we zero out any stale |
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
897 |
* data from the origin snapshots zil header. |
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
898 |
*/ |
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
899 |
if (origin != NULL) { |
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
900 |
dsl_dataset_t *ds; |
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
901 |
objset_t *os; |
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
902 |
|
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
903 |
VERIFY3U(0, ==, dsl_dataset_hold_obj(dp, dsobj, FTAG, &ds)); |
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
904 |
VERIFY3U(0, ==, dmu_objset_from_ds(ds, &os)); |
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
905 |
bzero(&os->os_zil_header, sizeof (os->os_zil_header)); |
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
906 |
dsl_dataset_dirty(ds, tx); |
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
907 |
dsl_dataset_rele(ds, FTAG); |
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
908 |
} |
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
909 |
|
2199 | 910 |
return (dsobj); |
911 |
} |
|
912 |
||
913 |
/* |
|
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
914 |
* The snapshots must all be in the same pool. |
2199 | 915 |
*/ |
916 |
int |
|
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
917 |
dmu_snapshots_destroy_nvl(nvlist_t *snaps, boolean_t defer, char *failed) |
2199 | 918 |
{ |
919 |
int err; |
|
920 |
dsl_sync_task_t *dst; |
|
921 |
spa_t *spa; |
|
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
922 |
nvpair_t *pair; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
923 |
dsl_sync_task_group_t *dstg; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
924 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
925 |
pair = nvlist_next_nvpair(snaps, NULL); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
926 |
if (pair == NULL) |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
927 |
return (0); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
928 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
929 |
err = spa_open(nvpair_name(pair), &spa, FTAG); |
2199 | 930 |
if (err) |
931 |
return (err); |
|
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
932 |
dstg = dsl_sync_task_group_create(spa_get_dsl(spa)); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
933 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
934 |
for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
935 |
pair = nvlist_next_nvpair(snaps, pair)) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
936 |
dsl_dataset_t *ds; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
937 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
938 |
err = dsl_dataset_own(nvpair_name(pair), B_TRUE, dstg, &ds); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
939 |
if (err == 0) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
940 |
struct dsl_ds_destroyarg *dsda; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
941 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
942 |
dsl_dataset_make_exclusive(ds, dstg); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
943 |
dsda = kmem_zalloc(sizeof (struct dsl_ds_destroyarg), |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
944 |
KM_SLEEP); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
945 |
dsda->ds = ds; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
946 |
dsda->defer = defer; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
947 |
dsl_sync_task_create(dstg, dsl_dataset_destroy_check, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
948 |
dsl_dataset_destroy_sync, dsda, dstg, 0); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
949 |
} else if (err == ENOENT) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
950 |
err = 0; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
951 |
} else { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
952 |
(void) strcpy(failed, nvpair_name(pair)); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
953 |
break; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
954 |
} |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
955 |
} |
2199 | 956 |
|
957 |
if (err == 0) |
|
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
958 |
err = dsl_sync_task_group_wait(dstg); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
959 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
960 |
for (dst = list_head(&dstg->dstg_tasks); dst; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
961 |
dst = list_next(&dstg->dstg_tasks, dst)) { |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
962 |
struct dsl_ds_destroyarg *dsda = dst->dst_arg1; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
963 |
dsl_dataset_t *ds = dsda->ds; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
964 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
965 |
/* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
966 |
* 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
|
967 |
*/ |
2199 | 968 |
if (dst->dst_err) { |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
969 |
dsl_dataset_name(ds, failed); |
2199 | 970 |
} |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
971 |
ASSERT3P(dsda->rm_origin, ==, NULL); |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
972 |
dsl_dataset_disown(ds, dstg); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
973 |
kmem_free(dsda, sizeof (struct dsl_ds_destroyarg)); |
2199 | 974 |
} |
975 |
||
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
976 |
dsl_sync_task_group_destroy(dstg); |
2199 | 977 |
spa_close(spa, FTAG); |
978 |
return (err); |
|
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
979 |
|
2199 | 980 |
} |
981 |
||
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
982 |
static boolean_t |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
983 |
dsl_dataset_might_destroy_origin(dsl_dataset_t *ds) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
984 |
{ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
985 |
boolean_t might_destroy = B_FALSE; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
986 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
987 |
mutex_enter(&ds->ds_lock); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
988 |
if (ds->ds_phys->ds_num_children == 2 && ds->ds_userrefs == 0 && |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
989 |
DS_IS_DEFER_DESTROY(ds)) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
990 |
might_destroy = B_TRUE; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
991 |
mutex_exit(&ds->ds_lock); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
992 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
993 |
return (might_destroy); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
994 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
995 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
996 |
/* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
997 |
* If we're removing a clone, and these three conditions are true: |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
998 |
* 1) the clone's origin has no other children |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
999 |
* 2) the clone's origin has no user references |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1000 |
* 3) the clone's origin has been marked for deferred destruction |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1001 |
* Then, prepare to remove the origin as part of this sync task group. |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1002 |
*/ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1003 |
static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1004 |
dsl_dataset_origin_rm_prep(struct dsl_ds_destroyarg *dsda, void *tag) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1005 |
{ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1006 |
dsl_dataset_t *ds = dsda->ds; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1007 |
dsl_dataset_t *origin = ds->ds_prev; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1008 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1009 |
if (dsl_dataset_might_destroy_origin(origin)) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1010 |
char *name; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1011 |
int namelen; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1012 |
int error; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1013 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1014 |
namelen = dsl_dataset_namelen(origin) + 1; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1015 |
name = kmem_alloc(namelen, KM_SLEEP); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1016 |
dsl_dataset_name(origin, name); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1017 |
#ifdef _KERNEL |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1018 |
error = zfs_unmount_snap(name, NULL); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1019 |
if (error) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1020 |
kmem_free(name, namelen); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1021 |
return (error); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1022 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1023 |
#endif |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1024 |
error = dsl_dataset_own(name, B_TRUE, tag, &origin); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1025 |
kmem_free(name, namelen); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1026 |
if (error) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1027 |
return (error); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1028 |
dsda->rm_origin = origin; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1029 |
dsl_dataset_make_exclusive(origin, tag); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1030 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1031 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1032 |
return (0); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1033 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1034 |
|
5367 | 1035 |
/* |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1036 |
* 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
|
1037 |
* ds will be closed and caller can no longer dereference it. |
5367 | 1038 |
*/ |
789 | 1039 |
int |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1040 |
dsl_dataset_destroy(dsl_dataset_t *ds, void *tag, boolean_t defer) |
789 | 1041 |
{ |
1042 |
int err; |
|
2199 | 1043 |
dsl_sync_task_group_t *dstg; |
1044 |
objset_t *os; |
|
789 | 1045 |
dsl_dir_t *dd; |
2199 | 1046 |
uint64_t obj; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
1047 |
struct dsl_ds_destroyarg dsda = { 0 }; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
1048 |
dsl_dataset_t dummy_ds = { 0 }; |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1049 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1050 |
dsda.ds = ds; |
2199 | 1051 |
|
5367 | 1052 |
if (dsl_dataset_is_snapshot(ds)) { |
2199 | 1053 |
/* Destroying a snapshot is simpler */ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1054 |
dsl_dataset_make_exclusive(ds, tag); |
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7077
diff
changeset
|
1055 |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1056 |
dsda.defer = defer; |
2199 | 1057 |
err = dsl_sync_task_do(ds->ds_dir->dd_pool, |
1058 |
dsl_dataset_destroy_check, dsl_dataset_destroy_sync, |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1059 |
&dsda, tag, 0); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1060 |
ASSERT3P(dsda.rm_origin, ==, NULL); |
5367 | 1061 |
goto out; |
10385
21cb6e67d108
6873727 zfs destroy -d <fs> should fail more gracefully when children are present
Chris Kirby <chris.kirby@sun.com>
parents:
10373
diff
changeset
|
1062 |
} else if (defer) { |
21cb6e67d108
6873727 zfs destroy -d <fs> should fail more gracefully when children are present
Chris Kirby <chris.kirby@sun.com>
parents:
10373
diff
changeset
|
1063 |
err = EINVAL; |
21cb6e67d108
6873727 zfs destroy -d <fs> should fail more gracefully when children are present
Chris Kirby <chris.kirby@sun.com>
parents:
10373
diff
changeset
|
1064 |
goto out; |
2199 | 1065 |
} |
1066 |
||
1067 |
dd = ds->ds_dir; |
|
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
1068 |
dummy_ds.ds_dir = dd; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
1069 |
dummy_ds.ds_object = ds->ds_object; |
789 | 1070 |
|
2199 | 1071 |
/* |
1072 |
* Check for errors and mark this ds as inconsistent, in |
|
1073 |
* case we crash while freeing the objects. |
|
1074 |
*/ |
|
1075 |
err = dsl_sync_task_do(dd->dd_pool, dsl_dataset_destroy_begin_check, |
|
1076 |
dsl_dataset_destroy_begin_sync, ds, NULL, 0); |
|
5367 | 1077 |
if (err) |
1078 |
goto out; |
|
1079 |
||
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1080 |
err = dmu_objset_from_ds(ds, &os); |
5367 | 1081 |
if (err) |
1082 |
goto out; |
|
2199 | 1083 |
|
1084 |
/* |
|
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1085 |
* If async destruction is not enabled try to remove all objects |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1086 |
* while in the open context so that there is less work to do in |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1087 |
* the syncing context. |
2199 | 1088 |
*/ |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1089 |
if (!spa_feature_is_enabled(dsl_dataset_get_spa(ds), |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1090 |
&spa_feature_table[SPA_FEATURE_ASYNC_DESTROY])) { |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1091 |
for (obj = 0; err == 0; err = dmu_object_next(os, &obj, FALSE, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1092 |
ds->ds_phys->ds_prev_snap_txg)) { |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1093 |
/* |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1094 |
* Ignore errors, if there is not enough disk space |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1095 |
* we will deal with it in dsl_dataset_destroy_sync(). |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1096 |
*/ |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1097 |
(void) dmu_free_object(os, obj); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1098 |
} |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1099 |
if (err != ESRCH) |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1100 |
goto out; |
2199 | 1101 |
} |
1102 |
||
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9390
diff
changeset
|
1103 |
/* |
12982
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
1104 |
* Only the ZIL knows how to free log blocks. |
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
1105 |
*/ |
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
1106 |
zil_destroy(dmu_objset_zil(os), B_FALSE); |
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
1107 |
|
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
1108 |
/* |
5d7f2db1e620
6972862 rollback can leak log blocks
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
12840
diff
changeset
|
1109 |
* Sync out all in-flight IO. |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9390
diff
changeset
|
1110 |
*/ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9390
diff
changeset
|
1111 |
txg_wait_synced(dd->dd_pool, 0); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9390
diff
changeset
|
1112 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9390
diff
changeset
|
1113 |
/* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9390
diff
changeset
|
1114 |
* If we managed to free all the objects in open |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9390
diff
changeset
|
1115 |
* context, the user space accounting should be zero. |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9390
diff
changeset
|
1116 |
*/ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9390
diff
changeset
|
1117 |
if (ds->ds_phys->ds_bp.blk_fill == 0 && |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1118 |
dmu_objset_userused_enabled(os)) { |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9390
diff
changeset
|
1119 |
uint64_t count; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9390
diff
changeset
|
1120 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9390
diff
changeset
|
1121 |
ASSERT(zap_count(os, DMU_USERUSED_OBJECT, &count) != 0 || |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9390
diff
changeset
|
1122 |
count == 0); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9390
diff
changeset
|
1123 |
ASSERT(zap_count(os, DMU_GROUPUSED_OBJECT, &count) != 0 || |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9390
diff
changeset
|
1124 |
count == 0); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9390
diff
changeset
|
1125 |
} |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9390
diff
changeset
|
1126 |
|
6975
c511f317869e
6717522 panic in dmu_objset_stats() due to freed objset_impl_t
maybee
parents:
6689
diff
changeset
|
1127 |
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
|
1128 |
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
|
1129 |
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
|
1130 |
|
c511f317869e
6717522 panic in dmu_objset_stats() due to freed objset_impl_t
maybee
parents:
6689
diff
changeset
|
1131 |
if (err) |
c511f317869e
6717522 panic in dmu_objset_stats() due to freed objset_impl_t
maybee
parents:
6689
diff
changeset
|
1132 |
goto out; |
c511f317869e
6717522 panic in dmu_objset_stats() due to freed objset_impl_t
maybee
parents:
6689
diff
changeset
|
1133 |
|
2199 | 1134 |
/* |
1135 |
* Blow away the dsl_dir + head dataset. |
|
1136 |
*/ |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1137 |
dsl_dataset_make_exclusive(ds, tag); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1138 |
/* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1139 |
* If we're removing a clone, we might also need to remove its |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1140 |
* origin. |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1141 |
*/ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1142 |
do { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1143 |
dsda.need_prep = B_FALSE; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1144 |
if (dsl_dir_is_clone(dd)) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1145 |
err = dsl_dataset_origin_rm_prep(&dsda, tag); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1146 |
if (err) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1147 |
dsl_dir_close(dd, FTAG); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1148 |
goto out; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1149 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1150 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1151 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1152 |
dstg = dsl_sync_task_group_create(ds->ds_dir->dd_pool); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1153 |
dsl_sync_task_create(dstg, dsl_dataset_destroy_check, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1154 |
dsl_dataset_destroy_sync, &dsda, tag, 0); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1155 |
dsl_sync_task_create(dstg, dsl_dir_destroy_check, |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
1156 |
dsl_dir_destroy_sync, &dummy_ds, FTAG, 0); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1157 |
err = dsl_sync_task_group_wait(dstg); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1158 |
dsl_sync_task_group_destroy(dstg); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1159 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1160 |
/* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1161 |
* We could be racing against 'zfs release' or 'zfs destroy -d' |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1162 |
* on the origin snap, in which case we can get EBUSY if we |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1163 |
* needed to destroy the origin snap but were not ready to |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1164 |
* do so. |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1165 |
*/ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1166 |
if (dsda.need_prep) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1167 |
ASSERT(err == EBUSY); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1168 |
ASSERT(dsl_dir_is_clone(dd)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1169 |
ASSERT(dsda.rm_origin == NULL); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1170 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1171 |
} while (dsda.need_prep); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1172 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1173 |
if (dsda.rm_origin != NULL) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1174 |
dsl_dataset_disown(dsda.rm_origin, tag); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1175 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1176 |
/* if it is successful, dsl_dir_destroy_sync will close the dd */ |
5367 | 1177 |
if (err) |
2199 | 1178 |
dsl_dir_close(dd, FTAG); |
5367 | 1179 |
out: |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1180 |
dsl_dataset_disown(ds, tag); |
789 | 1181 |
return (err); |
1182 |
} |
|
1183 |
||
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
1184 |
blkptr_t * |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
1185 |
dsl_dataset_get_blkptr(dsl_dataset_t *ds) |
789 | 1186 |
{ |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
1187 |
return (&ds->ds_phys->ds_bp); |
789 | 1188 |
} |
1189 |
||
1190 |
void |
|
1191 |
dsl_dataset_set_blkptr(dsl_dataset_t *ds, blkptr_t *bp, dmu_tx_t *tx) |
|
1192 |
{ |
|
1193 |
ASSERT(dmu_tx_is_syncing(tx)); |
|
1194 |
/* If it's the meta-objset, set dp_meta_rootbp */ |
|
1195 |
if (ds == NULL) { |
|
1196 |
tx->tx_pool->dp_meta_rootbp = *bp; |
|
1197 |
} else { |
|
1198 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
|
1199 |
ds->ds_phys->ds_bp = *bp; |
|
1200 |
} |
|
1201 |
} |
|
1202 |
||
1203 |
spa_t * |
|
1204 |
dsl_dataset_get_spa(dsl_dataset_t *ds) |
|
1205 |
{ |
|
1206 |
return (ds->ds_dir->dd_pool->dp_spa); |
|
1207 |
} |
|
1208 |
||
1209 |
void |
|
1210 |
dsl_dataset_dirty(dsl_dataset_t *ds, dmu_tx_t *tx) |
|
1211 |
{ |
|
1212 |
dsl_pool_t *dp; |
|
1213 |
||
1214 |
if (ds == NULL) /* this is the meta-objset */ |
|
1215 |
return; |
|
1216 |
||
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1217 |
ASSERT(ds->ds_objset != NULL); |
2885 | 1218 |
|
1219 |
if (ds->ds_phys->ds_next_snap_obj != 0) |
|
1220 |
panic("dirtying snapshot!"); |
|
789 | 1221 |
|
1222 |
dp = ds->ds_dir->dd_pool; |
|
1223 |
||
1224 |
if (txg_list_add(&dp->dp_dirty_datasets, ds, tx->tx_txg) == 0) { |
|
1225 |
/* up the hold count until we can be written out */ |
|
1226 |
dmu_buf_add_ref(ds->ds_dbuf, ds); |
|
1227 |
} |
|
1228 |
} |
|
1229 |
||
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1230 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1231 |
* 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
|
1232 |
* 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
|
1233 |
* 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
|
1234 |
* 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
|
1235 |
* 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
|
1236 |
* has been freed up since the snapshot was taken. |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1237 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1238 |
static void |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1239 |
dsl_dataset_recalc_head_uniq(dsl_dataset_t *ds) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1240 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1241 |
uint64_t mrs_used; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1242 |
uint64_t dlused, dlcomp, dluncomp; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1243 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
1244 |
ASSERT(!dsl_dataset_is_snapshot(ds)); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1245 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1246 |
if (ds->ds_phys->ds_prev_snap_obj != 0) |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1247 |
mrs_used = ds->ds_prev->ds_phys->ds_referenced_bytes; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1248 |
else |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1249 |
mrs_used = 0; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1250 |
|
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1251 |
dsl_deadlist_space(&ds->ds_deadlist, &dlused, &dlcomp, &dluncomp); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1252 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1253 |
ASSERT3U(dlused, <=, mrs_used); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1254 |
ds->ds_phys->ds_unique_bytes = |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1255 |
ds->ds_phys->ds_referenced_bytes - (mrs_used - dlused); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1256 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
1257 |
if (spa_version(ds->ds_dir->dd_pool->dp_spa) >= |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1258 |
SPA_VERSION_UNIQUE_ACCURATE) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1259 |
ds->ds_phys->ds_flags |= DS_FLAG_UNIQUE_ACCURATE; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1260 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1261 |
|
789 | 1262 |
struct killarg { |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
1263 |
dsl_dataset_t *ds; |
789 | 1264 |
dmu_tx_t *tx; |
1265 |
}; |
|
1266 |
||
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
1267 |
/* ARGSUSED */ |
789 | 1268 |
static int |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
1269 |
kill_blkptr(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, arc_buf_t *pbuf, |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
1270 |
const zbookmark_t *zb, const dnode_phys_t *dnp, void *arg) |
789 | 1271 |
{ |
1272 |
struct killarg *ka = arg; |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
1273 |
dmu_tx_t *tx = ka->tx; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1274 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1275 |
if (bp == NULL) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1276 |
return (0); |
789 | 1277 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
1278 |
if (zb->zb_level == ZB_ZIL_LEVEL) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
1279 |
ASSERT(zilog != NULL); |
8746
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8525
diff
changeset
|
1280 |
/* |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8525
diff
changeset
|
1281 |
* It's a block in the intent log. It has no |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8525
diff
changeset
|
1282 |
* accounting, so just free it. |
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8525
diff
changeset
|
1283 |
*/ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
1284 |
dsl_free(ka->tx->tx_pool, ka->tx->tx_txg, bp); |
8746
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8525
diff
changeset
|
1285 |
} else { |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
1286 |
ASSERT(zilog == NULL); |
8746
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8525
diff
changeset
|
1287 |
ASSERT3U(bp->blk_birth, >, ka->ds->ds_phys->ds_prev_snap_txg); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
1288 |
(void) dsl_dataset_block_kill(ka->ds, bp, tx, B_FALSE); |
8746
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8525
diff
changeset
|
1289 |
} |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
1290 |
|
789 | 1291 |
return (0); |
1292 |
} |
|
1293 |
||
1294 |
/* ARGSUSED */ |
|
2199 | 1295 |
static int |
1296 |
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
|
1297 |
{ |
2199 | 1298 |
dsl_dataset_t *ds = arg1; |
5367 | 1299 |
objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset; |
1300 |
uint64_t count; |
|
1301 |
int err; |
|
1731
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1302 |
|
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1303 |
/* |
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1304 |
* 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
|
1305 |
* (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
|
1306 |
* from.) |
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1307 |
*/ |
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1308 |
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
|
1309 |
ds->ds_prev->ds_phys->ds_next_snap_obj == ds->ds_object) |
10816
731471f04028
6482588 zfs destroy -r aborts and dumps core when destroying a file system (while snapshotting is going on)
vitezslav batrla - Sun Microsystems - Prague Czech Republic <Vitezslav.Batrla@Sun.COM>
parents:
10801
diff
changeset
|
1310 |
return (EBUSY); |
1731
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1311 |
|
5367 | 1312 |
/* |
1313 |
* This is really a dsl_dir thing, but check it here so that |
|
1314 |
* we'll be less likely to leave this dataset inconsistent & |
|
1315 |
* nearly destroyed. |
|
1316 |
*/ |
|
1317 |
err = zap_count(mos, ds->ds_dir->dd_phys->dd_child_dir_zapobj, &count); |
|
1318 |
if (err) |
|
1319 |
return (err); |
|
1320 |
if (count != 0) |
|
1321 |
return (EEXIST); |
|
1322 |
||
1731
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1323 |
return (0); |
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1324 |
} |
1efa8b3d1296
6402598 'zfs destroy <fs>' can take a long time, stopping up the txg train
bonwick
parents:
1544
diff
changeset
|
1325 |
|
2199 | 1326 |
/* ARGSUSED */ |
1327 |
static void |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
1328 |
dsl_dataset_destroy_begin_sync(void *arg1, void *arg2, dmu_tx_t *tx) |
789 | 1329 |
{ |
2199 | 1330 |
dsl_dataset_t *ds = arg1; |
4543 | 1331 |
dsl_pool_t *dp = ds->ds_dir->dd_pool; |
789 | 1332 |
|
2199 | 1333 |
/* Mark it as inconsistent on-disk, in case we crash */ |
1334 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
|
1335 |
ds->ds_phys->ds_flags |= DS_FLAG_INCONSISTENT; |
|
4543 | 1336 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
1337 |
spa_history_log_internal(LOG_DS_DESTROY_BEGIN, dp->dp_spa, tx, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
1338 |
"dataset = %llu", ds->ds_object); |
2199 | 1339 |
} |
789 | 1340 |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1341 |
static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1342 |
dsl_dataset_origin_check(struct dsl_ds_destroyarg *dsda, void *tag, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1343 |
dmu_tx_t *tx) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1344 |
{ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1345 |
dsl_dataset_t *ds = dsda->ds; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1346 |
dsl_dataset_t *ds_prev = ds->ds_prev; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1347 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1348 |
if (dsl_dataset_might_destroy_origin(ds_prev)) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1349 |
struct dsl_ds_destroyarg ndsda = {0}; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1350 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1351 |
/* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1352 |
* If we're not prepared to remove the origin, don't remove |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1353 |
* the clone either. |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1354 |
*/ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1355 |
if (dsda->rm_origin == NULL) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1356 |
dsda->need_prep = B_TRUE; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1357 |
return (EBUSY); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1358 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1359 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1360 |
ndsda.ds = ds_prev; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1361 |
ndsda.is_origin_rm = B_TRUE; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1362 |
return (dsl_dataset_destroy_check(&ndsda, tag, tx)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1363 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1364 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1365 |
/* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1366 |
* If we're not going to remove the origin after all, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1367 |
* undo the open context setup. |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1368 |
*/ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1369 |
if (dsda->rm_origin != NULL) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1370 |
dsl_dataset_disown(dsda->rm_origin, tag); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1371 |
dsda->rm_origin = NULL; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1372 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1373 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1374 |
return (0); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1375 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1376 |
|
13055 | 1377 |
/* |
1378 |
* If you add new checks here, you may need to add |
|
1379 |
* additional checks to the "temporary" case in |
|
1380 |
* snapshot_check() in dmu_objset.c. |
|
1381 |
*/ |
|
2199 | 1382 |
/* ARGSUSED */ |
5367 | 1383 |
int |
2199 | 1384 |
dsl_dataset_destroy_check(void *arg1, void *arg2, dmu_tx_t *tx) |
1385 |
{ |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1386 |
struct dsl_ds_destroyarg *dsda = arg1; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1387 |
dsl_dataset_t *ds = dsda->ds; |
789 | 1388 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1389 |
/* 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
|
1390 |
ASSERT(!DSL_DATASET_IS_DESTROYED(ds)); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1391 |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1392 |
/* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1393 |
* Only allow deferred destroy on pools that support it. |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1394 |
* NOTE: deferred destroy is only supported on snapshots. |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1395 |
*/ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1396 |
if (dsda->defer) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1397 |
if (spa_version(ds->ds_dir->dd_pool->dp_spa) < |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1398 |
SPA_VERSION_USERREFS) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1399 |
return (ENOTSUP); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1400 |
ASSERT(dsl_dataset_is_snapshot(ds)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1401 |
return (0); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1402 |
} |
789 | 1403 |
|
1404 |
/* |
|
1405 |
* Can't delete a head dataset if there are snapshots of it. |
|
1406 |
* (Except if the only snapshots are from the branch we cloned |
|
1407 |
* from.) |
|
1408 |
*/ |
|
1409 |
if (ds->ds_prev != NULL && |
|
2199 | 1410 |
ds->ds_prev->ds_phys->ds_next_snap_obj == ds->ds_object) |
10816
731471f04028
6482588 zfs destroy -r aborts and dumps core when destroying a file system (while snapshotting is going on)
vitezslav batrla - Sun Microsystems - Prague Czech Republic <Vitezslav.Batrla@Sun.COM>
parents:
10801
diff
changeset
|
1411 |
return (EBUSY); |
789 | 1412 |
|
1413 |
/* |
|
1414 |
* If we made changes this txg, traverse_dsl_dataset won't find |
|
1415 |
* them. Try again. |
|
1416 |
*/ |
|
2199 | 1417 |
if (ds->ds_phys->ds_bp.blk_birth >= tx->tx_txg) |
789 | 1418 |
return (EAGAIN); |
2199 | 1419 |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1420 |
if (dsl_dataset_is_snapshot(ds)) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1421 |
/* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1422 |
* If this snapshot has an elevated user reference count, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1423 |
* we can't destroy it yet. |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1424 |
*/ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1425 |
if (ds->ds_userrefs > 0 && !dsda->releasing) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1426 |
return (EBUSY); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1427 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1428 |
mutex_enter(&ds->ds_lock); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1429 |
/* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1430 |
* Can't delete a branch point. However, if we're destroying |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1431 |
* a clone and removing its origin due to it having a user |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1432 |
* hold count of 0 and having been marked for deferred destroy, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1433 |
* it's OK for the origin to have a single clone. |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1434 |
*/ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1435 |
if (ds->ds_phys->ds_num_children > |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1436 |
(dsda->is_origin_rm ? 2 : 1)) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1437 |
mutex_exit(&ds->ds_lock); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1438 |
return (EEXIST); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1439 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1440 |
mutex_exit(&ds->ds_lock); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1441 |
} else if (dsl_dir_is_clone(ds->ds_dir)) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1442 |
return (dsl_dataset_origin_check(dsda, arg2, tx)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1443 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1444 |
|
2199 | 1445 |
/* XXX we should do some i/o error checking... */ |
1446 |
return (0); |
|
1447 |
} |
|
1448 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1449 |
struct refsarg { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1450 |
kmutex_t lock; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1451 |
boolean_t gone; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1452 |
kcondvar_t cv; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1453 |
}; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1454 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1455 |
/* ARGSUSED */ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1456 |
static void |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1457 |
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
|
1458 |
{ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1459 |
struct refsarg *arg = argv; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1460 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1461 |
mutex_enter(&arg->lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1462 |
arg->gone = TRUE; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1463 |
cv_signal(&arg->cv); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1464 |
mutex_exit(&arg->lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1465 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1466 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1467 |
static void |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1468 |
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
|
1469 |
{ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1470 |
struct refsarg arg; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1471 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1472 |
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
|
1473 |
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
|
1474 |
arg.gone = FALSE; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1475 |
(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
|
1476 |
dsl_dataset_refs_gone); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1477 |
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
|
1478 |
mutex_enter(&arg.lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1479 |
while (!arg.gone) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1480 |
cv_wait(&arg.cv, &arg.lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1481 |
ASSERT(arg.gone); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1482 |
mutex_exit(&arg.lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1483 |
ds->ds_dbuf = NULL; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1484 |
ds->ds_phys = NULL; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1485 |
mutex_destroy(&arg.lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1486 |
cv_destroy(&arg.cv); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1487 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1488 |
|
10801
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1489 |
static void |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1490 |
remove_from_next_clones(dsl_dataset_t *ds, uint64_t obj, dmu_tx_t *tx) |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1491 |
{ |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1492 |
objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset; |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1493 |
uint64_t count; |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1494 |
int err; |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1495 |
|
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1496 |
ASSERT(ds->ds_phys->ds_num_children >= 2); |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1497 |
err = zap_remove_int(mos, ds->ds_phys->ds_next_clones_obj, obj, tx); |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1498 |
/* |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1499 |
* The err should not be ENOENT, but a bug in a previous version |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1500 |
* of the code could cause upgrade_clones_cb() to not set |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1501 |
* ds_next_snap_obj when it should, leading to a missing entry. |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1502 |
* If we knew that the pool was created after |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1503 |
* SPA_VERSION_NEXT_CLONES, we could assert that it isn't |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1504 |
* ENOENT. However, at least we can check that we don't have |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1505 |
* too many entries in the next_clones_obj even after failing to |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1506 |
* remove this one. |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1507 |
*/ |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1508 |
if (err != ENOENT) { |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1509 |
VERIFY3U(err, ==, 0); |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1510 |
} |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1511 |
ASSERT3U(0, ==, zap_count(mos, ds->ds_phys->ds_next_clones_obj, |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1512 |
&count)); |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1513 |
ASSERT3U(count, <=, ds->ds_phys->ds_num_children - 2); |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1514 |
} |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1515 |
|
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1516 |
static void |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1517 |
dsl_dataset_remove_clones_key(dsl_dataset_t *ds, uint64_t mintxg, dmu_tx_t *tx) |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1518 |
{ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1519 |
objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1520 |
zap_cursor_t zc; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1521 |
zap_attribute_t za; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1522 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1523 |
/* |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1524 |
* If it is the old version, dd_clones doesn't exist so we can't |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1525 |
* find the clones, but deadlist_remove_key() is a no-op so it |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1526 |
* doesn't matter. |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1527 |
*/ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1528 |
if (ds->ds_dir->dd_phys->dd_clones == 0) |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1529 |
return; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1530 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1531 |
for (zap_cursor_init(&zc, mos, ds->ds_dir->dd_phys->dd_clones); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1532 |
zap_cursor_retrieve(&zc, &za) == 0; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1533 |
zap_cursor_advance(&zc)) { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1534 |
dsl_dataset_t *clone; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1535 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1536 |
VERIFY3U(0, ==, dsl_dataset_hold_obj(ds->ds_dir->dd_pool, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1537 |
za.za_first_integer, FTAG, &clone)); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1538 |
if (clone->ds_dir->dd_origin_txg > mintxg) { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1539 |
dsl_deadlist_remove_key(&clone->ds_deadlist, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1540 |
mintxg, tx); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1541 |
dsl_dataset_remove_clones_key(clone, mintxg, tx); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1542 |
} |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1543 |
dsl_dataset_rele(clone, FTAG); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1544 |
} |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1545 |
zap_cursor_fini(&zc); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1546 |
} |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1547 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1548 |
struct process_old_arg { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1549 |
dsl_dataset_t *ds; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1550 |
dsl_dataset_t *ds_prev; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1551 |
boolean_t after_branch_point; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1552 |
zio_t *pio; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1553 |
uint64_t used, comp, uncomp; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1554 |
}; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1555 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1556 |
static int |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1557 |
process_old_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx) |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1558 |
{ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1559 |
struct process_old_arg *poa = arg; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1560 |
dsl_pool_t *dp = poa->ds->ds_dir->dd_pool; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1561 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1562 |
if (bp->blk_birth <= poa->ds->ds_phys->ds_prev_snap_txg) { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1563 |
dsl_deadlist_insert(&poa->ds->ds_deadlist, bp, tx); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1564 |
if (poa->ds_prev && !poa->after_branch_point && |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1565 |
bp->blk_birth > |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1566 |
poa->ds_prev->ds_phys->ds_prev_snap_txg) { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1567 |
poa->ds_prev->ds_phys->ds_unique_bytes += |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1568 |
bp_get_dsize_sync(dp->dp_spa, bp); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1569 |
} |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1570 |
} else { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1571 |
poa->used += bp_get_dsize_sync(dp->dp_spa, bp); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1572 |
poa->comp += BP_GET_PSIZE(bp); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1573 |
poa->uncomp += BP_GET_UCSIZE(bp); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1574 |
dsl_free_sync(poa->pio, dp, tx->tx_txg, bp); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1575 |
} |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1576 |
return (0); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1577 |
} |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1578 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1579 |
static void |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1580 |
process_old_deadlist(dsl_dataset_t *ds, dsl_dataset_t *ds_prev, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1581 |
dsl_dataset_t *ds_next, boolean_t after_branch_point, dmu_tx_t *tx) |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1582 |
{ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1583 |
struct process_old_arg poa = { 0 }; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1584 |
dsl_pool_t *dp = ds->ds_dir->dd_pool; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1585 |
objset_t *mos = dp->dp_meta_objset; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1586 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1587 |
ASSERT(ds->ds_deadlist.dl_oldfmt); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1588 |
ASSERT(ds_next->ds_deadlist.dl_oldfmt); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1589 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1590 |
poa.ds = ds; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1591 |
poa.ds_prev = ds_prev; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1592 |
poa.after_branch_point = after_branch_point; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1593 |
poa.pio = zio_root(dp->dp_spa, NULL, NULL, ZIO_FLAG_MUSTSUCCEED); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1594 |
VERIFY3U(0, ==, bpobj_iterate(&ds_next->ds_deadlist.dl_bpobj, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1595 |
process_old_cb, &poa, tx)); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1596 |
VERIFY3U(zio_wait(poa.pio), ==, 0); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1597 |
ASSERT3U(poa.used, ==, ds->ds_phys->ds_unique_bytes); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1598 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1599 |
/* change snapused */ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1600 |
dsl_dir_diduse_space(ds->ds_dir, DD_USED_SNAP, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1601 |
-poa.used, -poa.comp, -poa.uncomp, tx); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1602 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1603 |
/* swap next's deadlist to our deadlist */ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1604 |
dsl_deadlist_close(&ds->ds_deadlist); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1605 |
dsl_deadlist_close(&ds_next->ds_deadlist); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1606 |
SWITCH64(ds_next->ds_phys->ds_deadlist_obj, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1607 |
ds->ds_phys->ds_deadlist_obj); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1608 |
dsl_deadlist_open(&ds->ds_deadlist, mos, ds->ds_phys->ds_deadlist_obj); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1609 |
dsl_deadlist_open(&ds_next->ds_deadlist, mos, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1610 |
ds_next->ds_phys->ds_deadlist_obj); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1611 |
} |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1612 |
|
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1613 |
static int |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1614 |
old_synchronous_dataset_destroy(dsl_dataset_t *ds, dmu_tx_t *tx) |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1615 |
{ |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1616 |
int err; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1617 |
struct killarg ka; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1618 |
|
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1619 |
/* |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1620 |
* Free everything that we point to (that's born after |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1621 |
* the previous snapshot, if we are a clone) |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1622 |
* |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1623 |
* NB: this should be very quick, because we already |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1624 |
* freed all the objects in open context. |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1625 |
*/ |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1626 |
ka.ds = ds; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1627 |
ka.tx = tx; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1628 |
err = traverse_dataset(ds, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1629 |
ds->ds_phys->ds_prev_snap_txg, TRAVERSE_POST, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1630 |
kill_blkptr, &ka); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1631 |
ASSERT3U(err, ==, 0); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1632 |
ASSERT(!DS_UNIQUE_IS_ACCURATE(ds) || ds->ds_phys->ds_unique_bytes == 0); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1633 |
|
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1634 |
return (err); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1635 |
} |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1636 |
|
5367 | 1637 |
void |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
1638 |
dsl_dataset_destroy_sync(void *arg1, void *tag, dmu_tx_t *tx) |
2199 | 1639 |
{ |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1640 |
struct dsl_ds_destroyarg *dsda = arg1; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1641 |
dsl_dataset_t *ds = dsda->ds; |
2199 | 1642 |
int err; |
1643 |
int after_branch_point = FALSE; |
|
1644 |
dsl_pool_t *dp = ds->ds_dir->dd_pool; |
|
1645 |
objset_t *mos = dp->dp_meta_objset; |
|
1646 |
dsl_dataset_t *ds_prev = NULL; |
|
13055 | 1647 |
boolean_t wont_destroy; |
2199 | 1648 |
uint64_t obj; |
1649 |
||
13055 | 1650 |
wont_destroy = (dsda->defer && |
1651 |
(ds->ds_userrefs > 0 || ds->ds_phys->ds_num_children > 1)); |
|
1652 |
||
1653 |
ASSERT(ds->ds_owner || wont_destroy); |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1654 |
ASSERT(dsda->defer || ds->ds_phys->ds_num_children <= 1); |
2199 | 1655 |
ASSERT(ds->ds_prev == NULL || |
1656 |
ds->ds_prev->ds_phys->ds_next_snap_obj != ds->ds_object); |
|
1657 |
ASSERT3U(ds->ds_phys->ds_bp.blk_birth, <=, tx->tx_txg); |
|
1658 |
||
13055 | 1659 |
if (wont_destroy) { |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1660 |
ASSERT(spa_version(dp->dp_spa) >= SPA_VERSION_USERREFS); |
13055 | 1661 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
1662 |
ds->ds_phys->ds_flags |= DS_FLAG_DEFER_DESTROY; |
|
1663 |
return; |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1664 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1665 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1666 |
/* 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
|
1667 |
mutex_enter(&ds->ds_lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1668 |
ds->ds_owner = dsl_reaper; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1669 |
cv_broadcast(&ds->ds_exclusive_cv); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1670 |
mutex_exit(&ds->ds_lock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1671 |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1672 |
/* Remove our reservation */ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1673 |
if (ds->ds_reserved != 0) { |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
1674 |
dsl_prop_setarg_t psa; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
1675 |
uint64_t value = 0; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
1676 |
|
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
1677 |
dsl_prop_setarg_init_uint64(&psa, "refreservation", |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
1678 |
(ZPROP_SRC_NONE | ZPROP_SRC_LOCAL | ZPROP_SRC_RECEIVED), |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
1679 |
&value); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
1680 |
psa.psa_effective_value = 0; /* predict default value */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
1681 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
1682 |
dsl_dataset_set_reservation_sync(ds, &psa, tx); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1683 |
ASSERT3U(ds->ds_reserved, ==, 0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1684 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1685 |
|
2199 | 1686 |
ASSERT(RW_WRITE_HELD(&dp->dp_config_rwlock)); |
1687 |
||
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
1688 |
dsl_scan_ds_destroyed(ds, tx); |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1689 |
|
2199 | 1690 |
obj = ds->ds_object; |
789 | 1691 |
|
1692 |
if (ds->ds_phys->ds_prev_snap_obj != 0) { |
|
1693 |
if (ds->ds_prev) { |
|
1694 |
ds_prev = ds->ds_prev; |
|
1695 |
} else { |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1696 |
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
|
1697 |
ds->ds_phys->ds_prev_snap_obj, FTAG, &ds_prev)); |
789 | 1698 |
} |
1699 |
after_branch_point = |
|
1700 |
(ds_prev->ds_phys->ds_next_snap_obj != obj); |
|
1701 |
||
1702 |
dmu_buf_will_dirty(ds_prev->ds_dbuf, tx); |
|
1703 |
if (after_branch_point && |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1704 |
ds_prev->ds_phys->ds_next_clones_obj != 0) { |
10801
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
1705 |
remove_from_next_clones(ds_prev, obj, tx); |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1706 |
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
|
1707 |
VERIFY(0 == zap_add_int(mos, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1708 |
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
|
1709 |
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
|
1710 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1711 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1712 |
if (after_branch_point && |
789 | 1713 |
ds->ds_phys->ds_next_snap_obj == 0) { |
1714 |
/* This clone is toast. */ |
|
1715 |
ASSERT(ds_prev->ds_phys->ds_num_children > 1); |
|
1716 |
ds_prev->ds_phys->ds_num_children--; |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1717 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1718 |
/* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1719 |
* If the clone's origin has no other clones, no |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1720 |
* user holds, and has been marked for deferred |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1721 |
* deletion, then we should have done the necessary |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1722 |
* destroy setup for it. |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1723 |
*/ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1724 |
if (ds_prev->ds_phys->ds_num_children == 1 && |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1725 |
ds_prev->ds_userrefs == 0 && |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1726 |
DS_IS_DEFER_DESTROY(ds_prev)) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1727 |
ASSERT3P(dsda->rm_origin, !=, NULL); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1728 |
} else { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1729 |
ASSERT3P(dsda->rm_origin, ==, NULL); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1730 |
} |
789 | 1731 |
} else if (!after_branch_point) { |
1732 |
ds_prev->ds_phys->ds_next_snap_obj = |
|
1733 |
ds->ds_phys->ds_next_snap_obj; |
|
1734 |
} |
|
1735 |
} |
|
1736 |
||
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
1737 |
if (dsl_dataset_is_snapshot(ds)) { |
789 | 1738 |
dsl_dataset_t *ds_next; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1739 |
uint64_t old_unique; |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1740 |
uint64_t used = 0, comp = 0, uncomp = 0; |
789 | 1741 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1742 |
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
|
1743 |
ds->ds_phys->ds_next_snap_obj, FTAG, &ds_next)); |
789 | 1744 |
ASSERT3U(ds_next->ds_phys->ds_prev_snap_obj, ==, obj); |
1745 |
||
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
1746 |
old_unique = ds_next->ds_phys->ds_unique_bytes; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1747 |
|
789 | 1748 |
dmu_buf_will_dirty(ds_next->ds_dbuf, tx); |
1749 |
ds_next->ds_phys->ds_prev_snap_obj = |
|
1750 |
ds->ds_phys->ds_prev_snap_obj; |
|
1751 |
ds_next->ds_phys->ds_prev_snap_txg = |
|
1752 |
ds->ds_phys->ds_prev_snap_txg; |
|
1753 |
ASSERT3U(ds->ds_phys->ds_prev_snap_txg, ==, |
|
1754 |
ds_prev ? ds_prev->ds_phys->ds_creation_txg : 0); |
|
1755 |
||
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1756 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1757 |
if (ds_next->ds_deadlist.dl_oldfmt) { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1758 |
process_old_deadlist(ds, ds_prev, ds_next, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1759 |
after_branch_point, tx); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1760 |
} else { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1761 |
/* Adjust prev's unique space. */ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1762 |
if (ds_prev && !after_branch_point) { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1763 |
dsl_deadlist_space_range(&ds_next->ds_deadlist, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1764 |
ds_prev->ds_phys->ds_prev_snap_txg, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1765 |
ds->ds_phys->ds_prev_snap_txg, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1766 |
&used, &comp, &uncomp); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1767 |
ds_prev->ds_phys->ds_unique_bytes += used; |
789 | 1768 |
} |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1769 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1770 |
/* Adjust snapused. */ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1771 |
dsl_deadlist_space_range(&ds_next->ds_deadlist, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1772 |
ds->ds_phys->ds_prev_snap_txg, UINT64_MAX, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1773 |
&used, &comp, &uncomp); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1774 |
dsl_dir_diduse_space(ds->ds_dir, DD_USED_SNAP, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1775 |
-used, -comp, -uncomp, tx); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1776 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1777 |
/* Move blocks to be freed to pool's free list. */ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1778 |
dsl_deadlist_move_bpobj(&ds_next->ds_deadlist, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1779 |
&dp->dp_free_bpobj, ds->ds_phys->ds_prev_snap_txg, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1780 |
tx); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1781 |
dsl_dir_diduse_space(tx->tx_pool->dp_free_dir, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1782 |
DD_USED_HEAD, used, comp, uncomp, tx); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1783 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1784 |
/* Merge our deadlist into next's and free it. */ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1785 |
dsl_deadlist_merge(&ds_next->ds_deadlist, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1786 |
ds->ds_phys->ds_deadlist_obj, tx); |
789 | 1787 |
} |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1788 |
dsl_deadlist_close(&ds->ds_deadlist); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1789 |
dsl_deadlist_free(mos, ds->ds_phys->ds_deadlist_obj, tx); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1790 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1791 |
/* Collapse range in clone heads */ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1792 |
dsl_dataset_remove_clones_key(ds, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1793 |
ds->ds_phys->ds_creation_txg, tx); |
789 | 1794 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
1795 |
if (dsl_dataset_is_snapshot(ds_next)) { |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1796 |
dsl_dataset_t *ds_nextnext; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1797 |
|
789 | 1798 |
/* |
1799 |
* Update next's unique to include blocks which |
|
1800 |
* were previously shared by only this snapshot |
|
1801 |
* and it. Those blocks will be born after the |
|
1802 |
* prev snap and before this snap, and will have |
|
1803 |
* died after the next snap and before the one |
|
1804 |
* after that (ie. be on the snap after next's |
|
1805 |
* deadlist). |
|
1806 |
*/ |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1807 |
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
|
1808 |
ds_next->ds_phys->ds_next_snap_obj, |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1809 |
FTAG, &ds_nextnext)); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1810 |
dsl_deadlist_space_range(&ds_nextnext->ds_deadlist, |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
1811 |
ds->ds_phys->ds_prev_snap_txg, |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1812 |
ds->ds_phys->ds_creation_txg, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1813 |
&used, &comp, &uncomp); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1814 |
ds_next->ds_phys->ds_unique_bytes += used; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1815 |
dsl_dataset_rele(ds_nextnext, FTAG); |
789 | 1816 |
ASSERT3P(ds_next->ds_prev, ==, NULL); |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1817 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1818 |
/* Collapse range in this head. */ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1819 |
dsl_dataset_t *hds; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1820 |
VERIFY3U(0, ==, dsl_dataset_hold_obj(dp, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1821 |
ds->ds_dir->dd_phys->dd_head_dataset_obj, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1822 |
FTAG, &hds)); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1823 |
dsl_deadlist_remove_key(&hds->ds_deadlist, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1824 |
ds->ds_phys->ds_creation_txg, tx); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1825 |
dsl_dataset_rele(hds, FTAG); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1826 |
|
789 | 1827 |
} else { |
1828 |
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
|
1829 |
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
|
1830 |
ds_next->ds_prev = NULL; |
789 | 1831 |
if (ds_prev) { |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1832 |
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
|
1833 |
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
|
1834 |
ds_next, &ds_next->ds_prev)); |
789 | 1835 |
} |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1836 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1837 |
dsl_dataset_recalc_head_uniq(ds_next); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1838 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1839 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1840 |
* Reduce the amount of our unconsmed refreservation |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1841 |
* being charged to our parent by the amount of |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1842 |
* new unique data we have gained. |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1843 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1844 |
if (old_unique < ds_next->ds_reserved) { |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1845 |
int64_t mrsdelta; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1846 |
uint64_t new_unique = |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1847 |
ds_next->ds_phys->ds_unique_bytes; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1848 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1849 |
ASSERT(old_unique <= new_unique); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1850 |
mrsdelta = MIN(new_unique - old_unique, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1851 |
ds_next->ds_reserved - old_unique); |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
1852 |
dsl_dir_diduse_space(ds->ds_dir, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
1853 |
DD_USED_REFRSRV, -mrsdelta, 0, 0, tx); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1854 |
} |
789 | 1855 |
} |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1856 |
dsl_dataset_rele(ds_next, FTAG); |
789 | 1857 |
} else { |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1858 |
zfeature_info_t *async_destroy = |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1859 |
&spa_feature_table[SPA_FEATURE_ASYNC_DESTROY]; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1860 |
|
789 | 1861 |
/* |
1862 |
* There's no next snapshot, so this is a head dataset. |
|
1863 |
* Destroy the deadlist. Unless it's a clone, the |
|
1864 |
* deadlist should be empty. (If it's a clone, it's |
|
1865 |
* safe to ignore the deadlist contents.) |
|
1866 |
*/ |
|
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1867 |
dsl_deadlist_close(&ds->ds_deadlist); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1868 |
dsl_deadlist_free(mos, ds->ds_phys->ds_deadlist_obj, tx); |
789 | 1869 |
ds->ds_phys->ds_deadlist_obj = 0; |
1870 |
||
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1871 |
if (!spa_feature_is_enabled(dp->dp_spa, async_destroy)) { |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1872 |
err = old_synchronous_dataset_destroy(ds, tx); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1873 |
} else { |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1874 |
/* |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1875 |
* Move the bptree into the pool's list of trees to |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1876 |
* clean up and update space accounting information. |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1877 |
*/ |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1878 |
uint64_t used, comp, uncomp; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1879 |
|
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1880 |
ASSERT(err == 0 || err == EBUSY); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1881 |
if (!spa_feature_is_active(dp->dp_spa, async_destroy)) { |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1882 |
spa_feature_incr(dp->dp_spa, async_destroy, tx); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1883 |
dp->dp_bptree_obj = bptree_alloc( |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1884 |
dp->dp_meta_objset, tx); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1885 |
VERIFY(zap_add(dp->dp_meta_objset, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1886 |
DMU_POOL_DIRECTORY_OBJECT, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1887 |
DMU_POOL_BPTREE_OBJ, sizeof (uint64_t), 1, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1888 |
&dp->dp_bptree_obj, tx) == 0); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1889 |
} |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1890 |
|
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1891 |
used = ds->ds_dir->dd_phys->dd_used_bytes; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1892 |
comp = ds->ds_dir->dd_phys->dd_compressed_bytes; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1893 |
uncomp = ds->ds_dir->dd_phys->dd_uncompressed_bytes; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1894 |
|
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1895 |
ASSERT(!DS_UNIQUE_IS_ACCURATE(ds) || |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1896 |
ds->ds_phys->ds_unique_bytes == used); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1897 |
|
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1898 |
bptree_add(dp->dp_meta_objset, dp->dp_bptree_obj, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1899 |
&ds->ds_phys->ds_bp, ds->ds_phys->ds_prev_snap_txg, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1900 |
used, comp, uncomp, tx); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1901 |
dsl_dir_diduse_space(ds->ds_dir, DD_USED_HEAD, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1902 |
-used, -comp, -uncomp, tx); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1903 |
dsl_dir_diduse_space(dp->dp_free_dir, DD_USED_HEAD, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1904 |
used, comp, uncomp, tx); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
1905 |
} |
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
1906 |
|
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
1907 |
if (ds->ds_prev != NULL) { |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1908 |
if (spa_version(dp->dp_spa) >= SPA_VERSION_DIR_CLONES) { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1909 |
VERIFY3U(0, ==, zap_remove_int(mos, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1910 |
ds->ds_prev->ds_dir->dd_phys->dd_clones, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1911 |
ds->ds_object, tx)); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
1912 |
} |
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
1913 |
dsl_dataset_rele(ds->ds_prev, ds); |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
1914 |
ds->ds_prev = ds_prev = NULL; |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
1915 |
} |
789 | 1916 |
} |
1917 |
||
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
1918 |
/* |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
1919 |
* This must be done after the dsl_traverse(), because it will |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
1920 |
* re-open the objset. |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
1921 |
*/ |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
1922 |
if (ds->ds_objset) { |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
1923 |
dmu_objset_evict(ds->ds_objset); |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
1924 |
ds->ds_objset = NULL; |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
1925 |
} |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
1926 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1927 |
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
|
1928 |
/* Erase the link in the dir */ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1929 |
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
|
1930 |
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
|
1931 |
ASSERT(ds->ds_phys->ds_snapnames_zapobj != 0); |
789 | 1932 |
err = zap_destroy(mos, ds->ds_phys->ds_snapnames_zapobj, tx); |
1933 |
ASSERT(err == 0); |
|
1934 |
} else { |
|
1935 |
/* remove from snapshot namespace */ |
|
1936 |
dsl_dataset_t *ds_head; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1937 |
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
|
1938 |
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
|
1939 |
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
|
1940 |
VERIFY(0 == dsl_dataset_get_snapname(ds)); |
789 | 1941 |
#ifdef ZFS_DEBUG |
1942 |
{ |
|
1943 |
uint64_t val; |
|
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6047
diff
changeset
|
1944 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1945 |
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
|
1946 |
ds->ds_snapname, &val); |
789 | 1947 |
ASSERT3U(err, ==, 0); |
1948 |
ASSERT3U(val, ==, obj); |
|
1949 |
} |
|
1950 |
#endif |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1951 |
err = dsl_dataset_snap_remove(ds_head, ds->ds_snapname, tx); |
789 | 1952 |
ASSERT(err == 0); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1953 |
dsl_dataset_rele(ds_head, FTAG); |
789 | 1954 |
} |
1955 |
||
1956 |
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
|
1957 |
dsl_dataset_rele(ds_prev, FTAG); |
789 | 1958 |
|
5094 | 1959 |
spa_prop_clear_bootfs(dp->dp_spa, ds->ds_object, tx); |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
1960 |
spa_history_log_internal(LOG_DS_DESTROY, dp->dp_spa, tx, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
1961 |
"dataset = %llu", ds->ds_object); |
4543 | 1962 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1963 |
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
|
1964 |
uint64_t count; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1965 |
ASSERT(0 == zap_count(mos, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1966 |
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
|
1967 |
VERIFY(0 == dmu_object_free(mos, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1968 |
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
|
1969 |
} |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
1970 |
if (ds->ds_phys->ds_props_obj != 0) |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
1971 |
VERIFY(0 == zap_destroy(mos, ds->ds_phys->ds_props_obj, tx)); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1972 |
if (ds->ds_phys->ds_userrefs_obj != 0) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1973 |
VERIFY(0 == zap_destroy(mos, ds->ds_phys->ds_userrefs_obj, tx)); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1974 |
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
|
1975 |
ds->ds_dir = NULL; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1976 |
dsl_dataset_drain_refs(ds, tag); |
2199 | 1977 |
VERIFY(0 == dmu_object_free(mos, obj, tx)); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1978 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1979 |
if (dsda->rm_origin) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1980 |
/* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1981 |
* Remove the origin of the clone we just destroyed. |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1982 |
*/ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1983 |
struct dsl_ds_destroyarg ndsda = {0}; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1984 |
|
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
1985 |
ndsda.ds = dsda->rm_origin; |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
1986 |
dsl_dataset_destroy_sync(&ndsda, tag, tx); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1987 |
} |
2199 | 1988 |
} |
1989 |
||
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1990 |
static int |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1991 |
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
|
1992 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1993 |
uint64_t asize; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1994 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1995 |
if (!dmu_tx_is_syncing(tx)) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1996 |
return (0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1997 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1998 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
1999 |
* 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
|
2000 |
* 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
|
2001 |
* outside of the reservation. |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2002 |
*/ |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2003 |
ASSERT(ds->ds_reserved == 0 || DS_UNIQUE_IS_ACCURATE(ds)); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2004 |
asize = MIN(ds->ds_phys->ds_unique_bytes, ds->ds_reserved); |
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
2005 |
if (asize > 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
|
2006 |
return (ENOSPC); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2007 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2008 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2009 |
* Propogate any reserved space for this snapshot to other |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2010 |
* snapshot checks in this sync group. |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2011 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2012 |
if (asize > 0) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2013 |
dsl_dir_willuse_space(ds->ds_dir, asize, tx); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2014 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2015 |
return (0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2016 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2017 |
|
2199 | 2018 |
int |
2019 |
dsl_dataset_snapshot_check(void *arg1, void *arg2, dmu_tx_t *tx) |
|
2020 |
{ |
|
5367 | 2021 |
dsl_dataset_t *ds = arg1; |
2199 | 2022 |
const char *snapname = arg2; |
2023 |
int err; |
|
2024 |
uint64_t value; |
|
789 | 2025 |
|
2026 |
/* |
|
2199 | 2027 |
* We don't allow multiple snapshots of the same txg. If there |
2028 |
* is already one, try again. |
|
2029 |
*/ |
|
2030 |
if (ds->ds_phys->ds_prev_snap_txg >= tx->tx_txg) |
|
2031 |
return (EAGAIN); |
|
2032 |
||
2033 |
/* |
|
2034 |
* Check for conflicting name snapshot name. |
|
789 | 2035 |
*/ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2036 |
err = dsl_dataset_snap_lookup(ds, snapname, &value); |
2199 | 2037 |
if (err == 0) |
2038 |
return (EEXIST); |
|
2039 |
if (err != ENOENT) |
|
2040 |
return (err); |
|
789 | 2041 |
|
3978
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
2042 |
/* |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
2043 |
* 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
|
2044 |
* 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
|
2045 |
*/ |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
2046 |
if (dsl_dataset_namelen(ds) + 1 + strlen(snapname) >= MAXNAMELEN) |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
2047 |
return (ENAMETOOLONG); |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3912
diff
changeset
|
2048 |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2049 |
err = dsl_dataset_snapshot_reserve_space(ds, tx); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2050 |
if (err) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2051 |
return (err); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2052 |
|
2199 | 2053 |
ds->ds_trysnap_txg = tx->tx_txg; |
789 | 2054 |
return (0); |
2055 |
} |
|
2056 |
||
2199 | 2057 |
void |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2058 |
dsl_dataset_snapshot_sync(void *arg1, void *arg2, dmu_tx_t *tx) |
789 | 2059 |
{ |
5367 | 2060 |
dsl_dataset_t *ds = arg1; |
2199 | 2061 |
const char *snapname = arg2; |
2062 |
dsl_pool_t *dp = ds->ds_dir->dd_pool; |
|
789 | 2063 |
dmu_buf_t *dbuf; |
2064 |
dsl_dataset_phys_t *dsphys; |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2065 |
uint64_t dsobj, crtxg; |
789 | 2066 |
objset_t *mos = dp->dp_meta_objset; |
2067 |
int err; |
|
2068 |
||
2199 | 2069 |
ASSERT(RW_WRITE_HELD(&dp->dp_config_rwlock)); |
789 | 2070 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2071 |
/* |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2072 |
* 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
|
2073 |
*/ |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2074 |
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
|
2075 |
crtxg = 1; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2076 |
else |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2077 |
crtxg = tx->tx_txg; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2078 |
|
928
36d72fe4da29
6349314 dmu_object_type names incorrect for DSL Directories and DSL Datasets
tabriz
parents:
885
diff
changeset
|
2079 |
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
|
2080 |
DMU_OT_DSL_DATASET, sizeof (dsl_dataset_phys_t), tx); |
1544 | 2081 |
VERIFY(0 == dmu_bonus_hold(mos, dsobj, FTAG, &dbuf)); |
789 | 2082 |
dmu_buf_will_dirty(dbuf, tx); |
2083 |
dsphys = dbuf->db_data; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2084 |
bzero(dsphys, sizeof (dsl_dataset_phys_t)); |
2199 | 2085 |
dsphys->ds_dir_obj = ds->ds_dir->dd_object; |
789 | 2086 |
dsphys->ds_fsid_guid = unique_create(); |
2087 |
(void) random_get_pseudo_bytes((void*)&dsphys->ds_guid, |
|
2088 |
sizeof (dsphys->ds_guid)); |
|
2089 |
dsphys->ds_prev_snap_obj = ds->ds_phys->ds_prev_snap_obj; |
|
2090 |
dsphys->ds_prev_snap_txg = ds->ds_phys->ds_prev_snap_txg; |
|
2091 |
dsphys->ds_next_snap_obj = ds->ds_object; |
|
2092 |
dsphys->ds_num_children = 1; |
|
2093 |
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
|
2094 |
dsphys->ds_creation_txg = crtxg; |
789 | 2095 |
dsphys->ds_deadlist_obj = ds->ds_phys->ds_deadlist_obj; |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2096 |
dsphys->ds_referenced_bytes = ds->ds_phys->ds_referenced_bytes; |
789 | 2097 |
dsphys->ds_compressed_bytes = ds->ds_phys->ds_compressed_bytes; |
2098 |
dsphys->ds_uncompressed_bytes = ds->ds_phys->ds_uncompressed_bytes; |
|
2082 | 2099 |
dsphys->ds_flags = ds->ds_phys->ds_flags; |
789 | 2100 |
dsphys->ds_bp = ds->ds_phys->ds_bp; |
1544 | 2101 |
dmu_buf_rele(dbuf, FTAG); |
789 | 2102 |
|
2199 | 2103 |
ASSERT3U(ds->ds_prev != 0, ==, ds->ds_phys->ds_prev_snap_obj != 0); |
2104 |
if (ds->ds_prev) { |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2105 |
uint64_t next_clones_obj = |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2106 |
ds->ds_prev->ds_phys->ds_next_clones_obj; |
2199 | 2107 |
ASSERT(ds->ds_prev->ds_phys->ds_next_snap_obj == |
789 | 2108 |
ds->ds_object || |
2199 | 2109 |
ds->ds_prev->ds_phys->ds_num_children > 1); |
2110 |
if (ds->ds_prev->ds_phys->ds_next_snap_obj == ds->ds_object) { |
|
2111 |
dmu_buf_will_dirty(ds->ds_prev->ds_dbuf, tx); |
|
789 | 2112 |
ASSERT3U(ds->ds_phys->ds_prev_snap_txg, ==, |
2199 | 2113 |
ds->ds_prev->ds_phys->ds_creation_txg); |
2114 |
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
|
2115 |
} else if (next_clones_obj != 0) { |
10801
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
2116 |
remove_from_next_clones(ds->ds_prev, |
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
2117 |
dsphys->ds_next_snap_obj, tx); |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2118 |
VERIFY3U(0, ==, zap_add_int(mos, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2119 |
next_clones_obj, dsobj, tx)); |
789 | 2120 |
} |
2121 |
} |
|
2122 |
||
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2123 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2124 |
* 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
|
2125 |
* need to increase the amount of refreservation being charged |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2126 |
* since our unique space is going to zero. |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2127 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2128 |
if (ds->ds_reserved) { |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2129 |
int64_t delta; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2130 |
ASSERT(DS_UNIQUE_IS_ACCURATE(ds)); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2131 |
delta = MIN(ds->ds_phys->ds_unique_bytes, ds->ds_reserved); |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2132 |
dsl_dir_diduse_space(ds->ds_dir, DD_USED_REFRSRV, |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2133 |
delta, 0, 0, tx); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2134 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2135 |
|
789 | 2136 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2137 |
zfs_dbgmsg("taking snapshot %s@%s/%llu; newkey=%llu", |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2138 |
ds->ds_dir->dd_myname, snapname, dsobj, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2139 |
ds->ds_phys->ds_prev_snap_txg); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2140 |
ds->ds_phys->ds_deadlist_obj = dsl_deadlist_clone(&ds->ds_deadlist, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2141 |
UINT64_MAX, ds->ds_phys->ds_prev_snap_obj, tx); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2142 |
dsl_deadlist_close(&ds->ds_deadlist); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2143 |
dsl_deadlist_open(&ds->ds_deadlist, mos, ds->ds_phys->ds_deadlist_obj); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2144 |
dsl_deadlist_add_key(&ds->ds_deadlist, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2145 |
ds->ds_phys->ds_prev_snap_txg, tx); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2146 |
|
5712
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5569
diff
changeset
|
2147 |
ASSERT3U(ds->ds_phys->ds_prev_snap_txg, <, tx->tx_txg); |
789 | 2148 |
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
|
2149 |
ds->ds_phys->ds_prev_snap_txg = crtxg; |
789 | 2150 |
ds->ds_phys->ds_unique_bytes = 0; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2151 |
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
|
2152 |
ds->ds_phys->ds_flags |= DS_FLAG_UNIQUE_ACCURATE; |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2153 |
|
789 | 2154 |
err = zap_add(mos, ds->ds_phys->ds_snapnames_zapobj, |
2155 |
snapname, 8, 1, &dsobj, tx); |
|
2156 |
ASSERT(err == 0); |
|
2157 |
||
2158 |
if (ds->ds_prev) |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2159 |
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
|
2160 |
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
|
2161 |
ds->ds_phys->ds_prev_snap_obj, ds, &ds->ds_prev)); |
4543 | 2162 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2163 |
dsl_scan_ds_snapshotted(ds, tx); |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2164 |
|
10373
bcf97ee54990
6395956 snapshot dir needs real c/mtime
Chris Kirby <chris.kirby@sun.com>
parents:
10342
diff
changeset
|
2165 |
dsl_dir_snap_cmtime_update(ds->ds_dir); |
bcf97ee54990
6395956 snapshot dir needs real c/mtime
Chris Kirby <chris.kirby@sun.com>
parents:
10342
diff
changeset
|
2166 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2167 |
spa_history_log_internal(LOG_DS_SNAPSHOT, dp->dp_spa, tx, |
4603
c7840c367d00
6494569 zfs recv -d pool/<doesn't exist> core dumps for top-level filesystem backups
ahrens
parents:
4577
diff
changeset
|
2168 |
"dataset = %llu", dsobj); |
789 | 2169 |
} |
2170 |
||
2171 |
void |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
2172 |
dsl_dataset_sync(dsl_dataset_t *ds, zio_t *zio, dmu_tx_t *tx) |
789 | 2173 |
{ |
2174 |
ASSERT(dmu_tx_is_syncing(tx)); |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2175 |
ASSERT(ds->ds_objset != NULL); |
789 | 2176 |
ASSERT(ds->ds_phys->ds_next_snap_obj == 0); |
2177 |
||
4787 | 2178 |
/* |
2179 |
* in case we had to change ds_fsid_guid when we opened it, |
|
2180 |
* sync it out now. |
|
2181 |
*/ |
|
2182 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
|
2183 |
ds->ds_phys->ds_fsid_guid = ds->ds_fsid_guid; |
|
2184 |
||
789 | 2185 |
dsl_dir_dirty(ds->ds_dir, tx); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2186 |
dmu_objset_sync(ds->ds_objset, zio, tx); |
789 | 2187 |
} |
2188 |
||
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2189 |
static void |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2190 |
get_clones_stat(dsl_dataset_t *ds, nvlist_t *nv) |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2191 |
{ |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2192 |
uint64_t count = 0; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2193 |
objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2194 |
zap_cursor_t zc; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2195 |
zap_attribute_t za; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2196 |
nvlist_t *propval; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2197 |
nvlist_t *val; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2198 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2199 |
rw_enter(&ds->ds_dir->dd_pool->dp_config_rwlock, RW_READER); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2200 |
VERIFY(nvlist_alloc(&propval, NV_UNIQUE_NAME, KM_SLEEP) == 0); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2201 |
VERIFY(nvlist_alloc(&val, NV_UNIQUE_NAME, KM_SLEEP) == 0); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2202 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2203 |
/* |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2204 |
* There may me missing entries in ds_next_clones_obj |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2205 |
* due to a bug in a previous version of the code. |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2206 |
* Only trust it if it has the right number of entries. |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2207 |
*/ |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2208 |
if (ds->ds_phys->ds_next_clones_obj != 0) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2209 |
ASSERT3U(0, ==, zap_count(mos, ds->ds_phys->ds_next_clones_obj, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2210 |
&count)); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2211 |
} |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2212 |
if (count != ds->ds_phys->ds_num_children - 1) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2213 |
goto fail; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2214 |
} |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2215 |
for (zap_cursor_init(&zc, mos, ds->ds_phys->ds_next_clones_obj); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2216 |
zap_cursor_retrieve(&zc, &za) == 0; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2217 |
zap_cursor_advance(&zc)) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2218 |
dsl_dataset_t *clone; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2219 |
char buf[ZFS_MAXNAMELEN]; |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2220 |
/* |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2221 |
* Even though we hold the dp_config_rwlock, the dataset |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2222 |
* may fail to open, returning ENOENT. If there is a |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2223 |
* thread concurrently attempting to destroy this |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2224 |
* dataset, it will have the ds_rwlock held for |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2225 |
* RW_WRITER. Our call to dsl_dataset_hold_obj() -> |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2226 |
* dsl_dataset_hold_ref() will fail its |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2227 |
* rw_tryenter(&ds->ds_rwlock, RW_READER), drop the |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2228 |
* dp_config_rwlock, and wait for the destroy progress |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2229 |
* and signal ds_exclusive_cv. If the destroy was |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2230 |
* successful, we will see that |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2231 |
* DSL_DATASET_IS_DESTROYED(), and return ENOENT. |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2232 |
*/ |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2233 |
if (dsl_dataset_hold_obj(ds->ds_dir->dd_pool, |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2234 |
za.za_first_integer, FTAG, &clone) != 0) |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2235 |
continue; |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2236 |
dsl_dir_name(clone->ds_dir, buf); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2237 |
VERIFY(nvlist_add_boolean(val, buf) == 0); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2238 |
dsl_dataset_rele(clone, FTAG); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2239 |
} |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2240 |
zap_cursor_fini(&zc); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2241 |
VERIFY(nvlist_add_nvlist(propval, ZPROP_VALUE, val) == 0); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2242 |
VERIFY(nvlist_add_nvlist(nv, zfs_prop_to_name(ZFS_PROP_CLONES), |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2243 |
propval) == 0); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2244 |
fail: |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2245 |
nvlist_free(val); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2246 |
nvlist_free(propval); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2247 |
rw_exit(&ds->ds_dir->dd_pool->dp_config_rwlock); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2248 |
} |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2249 |
|
789 | 2250 |
void |
2885 | 2251 |
dsl_dataset_stats(dsl_dataset_t *ds, nvlist_t *nv) |
789 | 2252 |
{ |
13387
7dd5626b8b49
1092 zfs refratio property
Matt Ahrens <Matt.Ahrens@delphix.com>
parents:
13055
diff
changeset
|
2253 |
uint64_t refd, avail, uobjs, aobjs, ratio; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2254 |
|
2885 | 2255 |
dsl_dir_stats(ds->ds_dir, nv); |
789 | 2256 |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2257 |
dsl_dataset_space(ds, &refd, &avail, &uobjs, &aobjs); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2258 |
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
|
2259 |
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
|
2260 |
|
2885 | 2261 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_CREATION, |
2262 |
ds->ds_phys->ds_creation_time); |
|
2263 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_CREATETXG, |
|
2264 |
ds->ds_phys->ds_creation_txg); |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2265 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_REFQUOTA, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2266 |
ds->ds_quota); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2267 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_REFRESERVATION, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2268 |
ds->ds_reserved); |
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6502
diff
changeset
|
2269 |
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
|
2270 |
ds->ds_phys->ds_guid); |
10575
2a8816c5173b
6882196 resource.* events shouldn't be posted during spa_tryimport()
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10385
diff
changeset
|
2271 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_UNIQUE, |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2272 |
ds->ds_phys->ds_unique_bytes); |
10575
2a8816c5173b
6882196 resource.* events shouldn't be posted during spa_tryimport()
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10385
diff
changeset
|
2273 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_OBJSETID, |
2a8816c5173b
6882196 resource.* events shouldn't be posted during spa_tryimport()
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
10385
diff
changeset
|
2274 |
ds->ds_object); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
2275 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USERREFS, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
2276 |
ds->ds_userrefs); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
2277 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_DEFER_DESTROY, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
2278 |
DS_IS_DEFER_DESTROY(ds) ? 1 : 0); |
789 | 2279 |
|
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2280 |
if (ds->ds_phys->ds_prev_snap_obj != 0) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2281 |
uint64_t written, comp, uncomp; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2282 |
dsl_pool_t *dp = ds->ds_dir->dd_pool; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2283 |
dsl_dataset_t *prev; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2284 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2285 |
rw_enter(&dp->dp_config_rwlock, RW_READER); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2286 |
int err = dsl_dataset_hold_obj(dp, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2287 |
ds->ds_phys->ds_prev_snap_obj, FTAG, &prev); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2288 |
rw_exit(&dp->dp_config_rwlock); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2289 |
if (err == 0) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2290 |
err = dsl_dataset_space_written(prev, ds, &written, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2291 |
&comp, &uncomp); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2292 |
dsl_dataset_rele(prev, FTAG); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2293 |
if (err == 0) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2294 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_WRITTEN, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2295 |
written); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2296 |
} |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2297 |
} |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2298 |
} |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2299 |
|
13387
7dd5626b8b49
1092 zfs refratio property
Matt Ahrens <Matt.Ahrens@delphix.com>
parents:
13055
diff
changeset
|
2300 |
ratio = ds->ds_phys->ds_compressed_bytes == 0 ? 100 : |
7dd5626b8b49
1092 zfs refratio property
Matt Ahrens <Matt.Ahrens@delphix.com>
parents:
13055
diff
changeset
|
2301 |
(ds->ds_phys->ds_uncompressed_bytes * 100 / |
7dd5626b8b49
1092 zfs refratio property
Matt Ahrens <Matt.Ahrens@delphix.com>
parents:
13055
diff
changeset
|
2302 |
ds->ds_phys->ds_compressed_bytes); |
7dd5626b8b49
1092 zfs refratio property
Matt Ahrens <Matt.Ahrens@delphix.com>
parents:
13055
diff
changeset
|
2303 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_REFRATIO, ratio); |
7dd5626b8b49
1092 zfs refratio property
Matt Ahrens <Matt.Ahrens@delphix.com>
parents:
13055
diff
changeset
|
2304 |
|
789 | 2305 |
if (ds->ds_phys->ds_next_snap_obj) { |
2306 |
/* |
|
2307 |
* This is a snapshot; override the dd's space used with |
|
2885 | 2308 |
* our unique space and compression ratio. |
789 | 2309 |
*/ |
2885 | 2310 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USED, |
2311 |
ds->ds_phys->ds_unique_bytes); |
|
13387
7dd5626b8b49
1092 zfs refratio property
Matt Ahrens <Matt.Ahrens@delphix.com>
parents:
13055
diff
changeset
|
2312 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_COMPRESSRATIO, ratio); |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2313 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
2314 |
get_clones_stat(ds, nv); |
789 | 2315 |
} |
2316 |
} |
|
2317 |
||
2885 | 2318 |
void |
2319 |
dsl_dataset_fast_stat(dsl_dataset_t *ds, dmu_objset_stats_t *stat) |
|
789 | 2320 |
{ |
2885 | 2321 |
stat->dds_creation_txg = ds->ds_phys->ds_creation_txg; |
2322 |
stat->dds_inconsistent = ds->ds_phys->ds_flags & DS_FLAG_INCONSISTENT; |
|
5367 | 2323 |
stat->dds_guid = ds->ds_phys->ds_guid; |
2885 | 2324 |
if (ds->ds_phys->ds_next_snap_obj) { |
2325 |
stat->dds_is_snapshot = B_TRUE; |
|
2326 |
stat->dds_num_clones = ds->ds_phys->ds_num_children - 1; |
|
8228
51e9ca9ee3a5
6572357 libzfs should do more to avoid mnttab lookups
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7837
diff
changeset
|
2327 |
} else { |
51e9ca9ee3a5
6572357 libzfs should do more to avoid mnttab lookups
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7837
diff
changeset
|
2328 |
stat->dds_is_snapshot = B_FALSE; |
51e9ca9ee3a5
6572357 libzfs should do more to avoid mnttab lookups
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7837
diff
changeset
|
2329 |
stat->dds_num_clones = 0; |
2885 | 2330 |
} |
2331 |
||
2332 |
/* clone origin is really a dsl_dir thing... */ |
|
5446 | 2333 |
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
|
2334 |
if (dsl_dir_is_clone(ds->ds_dir)) { |
2885 | 2335 |
dsl_dataset_t *ods; |
2336 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2337 |
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
|
2338 |
ds->ds_dir->dd_phys->dd_origin_obj, FTAG, &ods)); |
5367 | 2339 |
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
|
2340 |
dsl_dataset_drop_ref(ods, FTAG); |
8228
51e9ca9ee3a5
6572357 libzfs should do more to avoid mnttab lookups
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7837
diff
changeset
|
2341 |
} else { |
51e9ca9ee3a5
6572357 libzfs should do more to avoid mnttab lookups
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7837
diff
changeset
|
2342 |
stat->dds_origin[0] = '\0'; |
2885 | 2343 |
} |
5446 | 2344 |
rw_exit(&ds->ds_dir->dd_pool->dp_config_rwlock); |
2885 | 2345 |
} |
2346 |
||
2347 |
uint64_t |
|
2348 |
dsl_dataset_fsid_guid(dsl_dataset_t *ds) |
|
2349 |
{ |
|
4787 | 2350 |
return (ds->ds_fsid_guid); |
2885 | 2351 |
} |
2352 |
||
2353 |
void |
|
2354 |
dsl_dataset_space(dsl_dataset_t *ds, |
|
2355 |
uint64_t *refdbytesp, uint64_t *availbytesp, |
|
2356 |
uint64_t *usedobjsp, uint64_t *availobjsp) |
|
2357 |
{ |
|
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2358 |
*refdbytesp = ds->ds_phys->ds_referenced_bytes; |
2885 | 2359 |
*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
|
2360 |
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
|
2361 |
*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
|
2362 |
if (ds->ds_quota != 0) { |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2363 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2364 |
* Adjust available bytes according to refquota |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2365 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2366 |
if (*refdbytesp < ds->ds_quota) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2367 |
*availbytesp = MIN(*availbytesp, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2368 |
ds->ds_quota - *refdbytesp); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2369 |
else |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2370 |
*availbytesp = 0; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
2371 |
} |
2885 | 2372 |
*usedobjsp = ds->ds_phys->ds_bp.blk_fill; |
2373 |
*availobjsp = DN_MAX_OBJECT - *usedobjsp; |
|
789 | 2374 |
} |
2375 |
||
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2376 |
boolean_t |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2377 |
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
|
2378 |
{ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2379 |
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
|
2380 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2381 |
ASSERT(RW_LOCK_HELD(&dp->dp_config_rwlock) || |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2382 |
dsl_pool_sync_context(dp)); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2383 |
if (ds->ds_prev == NULL) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2384 |
return (B_FALSE); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2385 |
if (ds->ds_phys->ds_bp.blk_birth > |
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
2386 |
ds->ds_prev->ds_phys->ds_creation_txg) { |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
2387 |
objset_t *os, *os_prev; |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
2388 |
/* |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
2389 |
* It may be that only the ZIL differs, because it was |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
2390 |
* reset in the head. Don't count that as being |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
2391 |
* modified. |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
2392 |
*/ |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
2393 |
if (dmu_objset_from_ds(ds, &os) != 0) |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
2394 |
return (B_TRUE); |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
2395 |
if (dmu_objset_from_ds(ds->ds_prev, &os_prev) != 0) |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
2396 |
return (B_TRUE); |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
2397 |
return (bcmp(&os->os_phys->os_meta_dnode, |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
2398 |
&os_prev->os_phys->os_meta_dnode, |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
2399 |
sizeof (os->os_phys->os_meta_dnode)) != 0); |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12798
diff
changeset
|
2400 |
} |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2401 |
return (B_FALSE); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2402 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2403 |
|
2199 | 2404 |
/* ARGSUSED */ |
789 | 2405 |
static int |
2199 | 2406 |
dsl_dataset_snapshot_rename_check(void *arg1, void *arg2, dmu_tx_t *tx) |
789 | 2407 |
{ |
2199 | 2408 |
dsl_dataset_t *ds = arg1; |
2409 |
char *newsnapname = arg2; |
|
2410 |
dsl_dir_t *dd = ds->ds_dir; |
|
2411 |
dsl_dataset_t *hds; |
|
2412 |
uint64_t val; |
|
789 | 2413 |
int err; |
2414 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2415 |
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
|
2416 |
dd->dd_phys->dd_head_dataset_obj, FTAG, &hds); |
789 | 2417 |
if (err) |
2418 |
return (err); |
|
2419 |
||
2199 | 2420 |
/* 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
|
2421 |
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
|
2422 |
dsl_dataset_rele(hds, FTAG); |
789 | 2423 |
|
2199 | 2424 |
if (err == 0) |
2425 |
err = EEXIST; |
|
2426 |
else if (err == ENOENT) |
|
2427 |
err = 0; |
|
4007 | 2428 |
|
2429 |
/* dataset name + 1 for the "@" + the new snapshot name must fit */ |
|
2430 |
if (dsl_dir_namelen(ds->ds_dir) + 1 + strlen(newsnapname) >= MAXNAMELEN) |
|
2431 |
err = ENAMETOOLONG; |
|
2432 |
||
2199 | 2433 |
return (err); |
2434 |
} |
|
789 | 2435 |
|
2199 | 2436 |
static void |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2437 |
dsl_dataset_snapshot_rename_sync(void *arg1, void *arg2, dmu_tx_t *tx) |
2199 | 2438 |
{ |
2439 |
dsl_dataset_t *ds = arg1; |
|
4543 | 2440 |
const char *newsnapname = arg2; |
2199 | 2441 |
dsl_dir_t *dd = ds->ds_dir; |
2442 |
objset_t *mos = dd->dd_pool->dp_meta_objset; |
|
2443 |
dsl_dataset_t *hds; |
|
2444 |
int err; |
|
789 | 2445 |
|
2199 | 2446 |
ASSERT(ds->ds_phys->ds_next_snap_obj != 0); |
789 | 2447 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2448 |
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
|
2449 |
dd->dd_phys->dd_head_dataset_obj, FTAG, &hds)); |
789 | 2450 |
|
2199 | 2451 |
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
|
2452 |
err = dsl_dataset_snap_remove(hds, ds->ds_snapname, tx); |
789 | 2453 |
ASSERT3U(err, ==, 0); |
2199 | 2454 |
mutex_enter(&ds->ds_lock); |
2455 |
(void) strcpy(ds->ds_snapname, newsnapname); |
|
2456 |
mutex_exit(&ds->ds_lock); |
|
2457 |
err = zap_add(mos, hds->ds_phys->ds_snapnames_zapobj, |
|
2458 |
ds->ds_snapname, 8, 1, &ds->ds_object, tx); |
|
789 | 2459 |
ASSERT3U(err, ==, 0); |
2460 |
||
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2461 |
spa_history_log_internal(LOG_DS_RENAME, dd->dd_pool->dp_spa, tx, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2462 |
"dataset = %llu", ds->ds_object); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2463 |
dsl_dataset_rele(hds, FTAG); |
789 | 2464 |
} |
2465 |
||
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2466 |
struct renamesnaparg { |
4007 | 2467 |
dsl_sync_task_group_t *dstg; |
2468 |
char failed[MAXPATHLEN]; |
|
2469 |
char *oldsnap; |
|
2470 |
char *newsnap; |
|
2471 |
}; |
|
2472 |
||
2473 |
static int |
|
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2474 |
dsl_snapshot_rename_one(const char *name, void *arg) |
4007 | 2475 |
{ |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2476 |
struct renamesnaparg *ra = arg; |
4007 | 2477 |
dsl_dataset_t *ds = NULL; |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2478 |
char *snapname; |
4007 | 2479 |
int err; |
2480 |
||
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2481 |
snapname = kmem_asprintf("%s@%s", name, ra->oldsnap); |
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2482 |
(void) strlcpy(ra->failed, snapname, sizeof (ra->failed)); |
4543 | 2483 |
|
2484 |
/* |
|
2485 |
* For recursive snapshot renames the parent won't be changing |
|
2486 |
* so we just pass name for both the to/from argument. |
|
2487 |
*/ |
|
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2488 |
err = zfs_secpolicy_rename_perms(snapname, snapname, CRED()); |
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2489 |
if (err != 0) { |
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2490 |
strfree(snapname); |
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2491 |
return (err == ENOENT ? 0 : err); |
4543 | 2492 |
} |
2493 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2494 |
#ifdef _KERNEL |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2495 |
/* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2496 |
* 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
|
2497 |
*/ |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2498 |
(void) zfs_unmount_snap(snapname, NULL); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2499 |
#endif |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2500 |
err = dsl_dataset_hold(snapname, ra->dstg, &ds); |
11609
3b5da7ebb54d
6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11546
diff
changeset
|
2501 |
strfree(snapname); |
3b5da7ebb54d
6920880 assertion failure in dbuf_write_ready()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11546
diff
changeset
|
2502 |
if (err != 0) |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2503 |
return (err == ENOENT ? 0 : err); |
4007 | 2504 |
|
2505 |
dsl_sync_task_create(ra->dstg, dsl_dataset_snapshot_rename_check, |
|
2506 |
dsl_dataset_snapshot_rename_sync, ds, ra->newsnap, 0); |
|
2507 |
||
2508 |
return (0); |
|
2509 |
} |
|
2510 |
||
2511 |
static int |
|
2512 |
dsl_recursive_rename(char *oldname, const char *newname) |
|
2513 |
{ |
|
2514 |
int err; |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2515 |
struct renamesnaparg *ra; |
4007 | 2516 |
dsl_sync_task_t *dst; |
2517 |
spa_t *spa; |
|
2518 |
char *cp, *fsname = spa_strdup(oldname); |
|
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2519 |
int len = strlen(oldname) + 1; |
4007 | 2520 |
|
2521 |
/* truncate the snapshot name to get the fsname */ |
|
2522 |
cp = strchr(fsname, '@'); |
|
2523 |
*cp = '\0'; |
|
2524 |
||
4603
c7840c367d00
6494569 zfs recv -d pool/<doesn't exist> core dumps for top-level filesystem backups
ahrens
parents:
4577
diff
changeset
|
2525 |
err = spa_open(fsname, &spa, FTAG); |
4007 | 2526 |
if (err) { |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2527 |
kmem_free(fsname, len); |
4007 | 2528 |
return (err); |
2529 |
} |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2530 |
ra = kmem_alloc(sizeof (struct renamesnaparg), KM_SLEEP); |
4007 | 2531 |
ra->dstg = dsl_sync_task_group_create(spa_get_dsl(spa)); |
2532 |
||
2533 |
ra->oldsnap = strchr(oldname, '@') + 1; |
|
2534 |
ra->newsnap = strchr(newname, '@') + 1; |
|
2535 |
*ra->failed = '\0'; |
|
2536 |
||
2537 |
err = dmu_objset_find(fsname, dsl_snapshot_rename_one, ra, |
|
2538 |
DS_FIND_CHILDREN); |
|
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2539 |
kmem_free(fsname, len); |
4007 | 2540 |
|
2541 |
if (err == 0) { |
|
2542 |
err = dsl_sync_task_group_wait(ra->dstg); |
|
2543 |
} |
|
2544 |
||
2545 |
for (dst = list_head(&ra->dstg->dstg_tasks); dst; |
|
2546 |
dst = list_next(&ra->dstg->dstg_tasks, dst)) { |
|
2547 |
dsl_dataset_t *ds = dst->dst_arg1; |
|
2548 |
if (dst->dst_err) { |
|
2549 |
dsl_dir_name(ds->ds_dir, ra->failed); |
|
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2550 |
(void) strlcat(ra->failed, "@", sizeof (ra->failed)); |
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2551 |
(void) strlcat(ra->failed, ra->newsnap, |
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2552 |
sizeof (ra->failed)); |
4007 | 2553 |
} |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2554 |
dsl_dataset_rele(ds, ra->dstg); |
4007 | 2555 |
} |
2556 |
||
4543 | 2557 |
if (err) |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2558 |
(void) strlcpy(oldname, ra->failed, sizeof (ra->failed)); |
4007 | 2559 |
|
2560 |
dsl_sync_task_group_destroy(ra->dstg); |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
2561 |
kmem_free(ra, sizeof (struct renamesnaparg)); |
4007 | 2562 |
spa_close(spa, FTAG); |
2563 |
return (err); |
|
2564 |
} |
|
2565 |
||
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
|
2566 |
static int |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
2567 |
dsl_valid_rename(const char *oldname, void *arg) |
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
|
2568 |
{ |
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2569 |
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
|
2570 |
|
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2571 |
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
|
2572 |
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
|
2573 |
|
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2574 |
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
|
2575 |
} |
e80d40447f27
6355623 zfs rename to a valid dataset name, but its snapshot name becomes too long, panics the system
mmusante
parents:
4543
diff
changeset
|
2576 |
|
789 | 2577 |
#pragma weak dmu_objset_rename = dsl_dataset_rename |
2578 |
int |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2579 |
dsl_dataset_rename(char *oldname, const char *newname, boolean_t recursive) |
789 | 2580 |
{ |
2581 |
dsl_dir_t *dd; |
|
2199 | 2582 |
dsl_dataset_t *ds; |
789 | 2583 |
const char *tail; |
2584 |
int err; |
|
2585 |
||
2199 | 2586 |
err = dsl_dir_open(oldname, FTAG, &dd, &tail); |
1544 | 2587 |
if (err) |
2588 |
return (err); |
|
11701
6f890435df16
6915532 snapshot related activity causes akd to hang
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
11609
diff
changeset
|
2589 |
|
789 | 2590 |
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
|
2591 |
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
|
2592 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2593 |
/* 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
|
2594 |
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
|
2595 |
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
|
2596 |
&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
|
2597 |
|
11823
c756cd80d532
6930022 zfs rename of non-shapshot is slower than necessary
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11701
diff
changeset
|
2598 |
if (err == 0) |
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
|
2599 |
err = dsl_dir_rename(dd, newname); |
789 | 2600 |
dsl_dir_close(dd, FTAG); |
2601 |
return (err); |
|
2602 |
} |
|
11701
6f890435df16
6915532 snapshot related activity causes akd to hang
Sanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
parents:
11609
diff
changeset
|
2603 |
|
789 | 2604 |
if (tail[0] != '@') { |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10575
diff
changeset
|
2605 |
/* the name ended in a nonexistent component */ |
789 | 2606 |
dsl_dir_close(dd, FTAG); |
2607 |
return (ENOENT); |
|
2608 |
} |
|
2609 |
||
2199 | 2610 |
dsl_dir_close(dd, FTAG); |
2611 |
||
2612 |
/* new name must be snapshot in same filesystem */ |
|
2613 |
tail = strchr(newname, '@'); |
|
2614 |
if (tail == NULL) |
|
2615 |
return (EINVAL); |
|
2616 |
tail++; |
|
2617 |
if (strncmp(oldname, newname, tail - newname) != 0) |
|
2618 |
return (EXDEV); |
|
789 | 2619 |
|
4007 | 2620 |
if (recursive) { |
2621 |
err = dsl_recursive_rename(oldname, newname); |
|
2622 |
} else { |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2623 |
err = dsl_dataset_hold(oldname, FTAG, &ds); |
4007 | 2624 |
if (err) |
2625 |
return (err); |
|
2199 | 2626 |
|
4007 | 2627 |
err = dsl_sync_task_do(ds->ds_dir->dd_pool, |
2628 |
dsl_dataset_snapshot_rename_check, |
|
2629 |
dsl_dataset_snapshot_rename_sync, ds, (char *)tail, 1); |
|
2199 | 2630 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2631 |
dsl_dataset_rele(ds, FTAG); |
4007 | 2632 |
} |
2199 | 2633 |
|
789 | 2634 |
return (err); |
2635 |
} |
|
2082 | 2636 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2637 |
struct promotenode { |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2638 |
list_node_t link; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2639 |
dsl_dataset_t *ds; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2640 |
}; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2641 |
|
2199 | 2642 |
struct promotearg { |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2643 |
list_t shared_snaps, origin_snaps, clone_snaps; |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2644 |
dsl_dataset_t *origin_origin; |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2645 |
uint64_t used, comp, uncomp, unique, cloneusedsnap, originusedsnap; |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10575
diff
changeset
|
2646 |
char *err_ds; |
2199 | 2647 |
}; |
2648 |
||
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2649 |
static int snaplist_space(list_t *l, uint64_t mintxg, uint64_t *spacep); |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2650 |
static boolean_t snaplist_unstable(list_t *l); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2651 |
|
2082 | 2652 |
static int |
2199 | 2653 |
dsl_dataset_promote_check(void *arg1, void *arg2, dmu_tx_t *tx) |
2082 | 2654 |
{ |
2199 | 2655 |
dsl_dataset_t *hds = arg1; |
2656 |
struct promotearg *pa = arg2; |
|
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2657 |
struct promotenode *snap = list_head(&pa->shared_snaps); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2658 |
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
|
2659 |
int err; |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2660 |
uint64_t unused; |
2199 | 2661 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2662 |
/* 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
|
2663 |
if (!dsl_dir_is_clone(hds->ds_dir)) |
2082 | 2664 |
return (EINVAL); |
2665 |
||
2199 | 2666 |
/* Since this is so expensive, don't do the preliminary check */ |
2667 |
if (!dmu_tx_is_syncing(tx)) |
|
2668 |
return (0); |
|
2669 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2670 |
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
|
2671 |
return (EXDEV); |
2082 | 2672 |
|
5367 | 2673 |
/* compute origin's new unique space */ |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2674 |
snap = list_tail(&pa->clone_snaps); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2675 |
ASSERT3U(snap->ds->ds_phys->ds_prev_snap_obj, ==, origin_ds->ds_object); |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2676 |
dsl_deadlist_space_range(&snap->ds->ds_deadlist, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2677 |
origin_ds->ds_phys->ds_prev_snap_txg, UINT64_MAX, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2678 |
&pa->unique, &unused, &unused); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2679 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2680 |
/* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2681 |
* 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
|
2682 |
* |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2683 |
* Compute space to transfer. Consider the incremental changes |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2684 |
* to used for each snapshot: |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2685 |
* (my used) = (prev's used) + (blocks born) - (blocks killed) |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2686 |
* So each snapshot gave birth to: |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2687 |
* (blocks born) = (my used) - (prev's used) + (blocks killed) |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2688 |
* So a sequence would look like: |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2689 |
* (uN - u(N-1) + kN) + ... + (u1 - u0 + k1) + (u0 - 0 + k0) |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2690 |
* Which simplifies to: |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2691 |
* uN + kN + kN-1 + ... + k1 + k0 |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2692 |
* Note however, if we stop before we reach the ORIGIN we get: |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2693 |
* uN + kN + kN-1 + ... + kM - uM-1 |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2694 |
*/ |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2695 |
pa->used = origin_ds->ds_phys->ds_referenced_bytes; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2696 |
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
|
2697 |
pa->uncomp = origin_ds->ds_phys->ds_uncompressed_bytes; |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2698 |
for (snap = list_head(&pa->shared_snaps); snap; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2699 |
snap = list_next(&pa->shared_snaps, snap)) { |
2082 | 2700 |
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
|
2701 |
dsl_dataset_t *ds = snap->ds; |
2082 | 2702 |
|
2703 |
/* Check that the snapshot name does not conflict */ |
|
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2704 |
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
|
2705 |
err = dsl_dataset_snap_lookup(hds, ds->ds_snapname, &val); |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10575
diff
changeset
|
2706 |
if (err == 0) { |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10575
diff
changeset
|
2707 |
err = EEXIST; |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10575
diff
changeset
|
2708 |
goto out; |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10575
diff
changeset
|
2709 |
} |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2710 |
if (err != ENOENT) |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10575
diff
changeset
|
2711 |
goto out; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2712 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2713 |
/* The very first snapshot does not have a deadlist */ |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2714 |
if (ds->ds_phys->ds_prev_snap_obj == 0) |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2715 |
continue; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2716 |
|
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2717 |
dsl_deadlist_space(&ds->ds_deadlist, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2718 |
&dlused, &dlcomp, &dluncomp); |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2719 |
pa->used += dlused; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2720 |
pa->comp += dlcomp; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2721 |
pa->uncomp += dluncomp; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2722 |
} |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2723 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2724 |
/* |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2725 |
* 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
|
2726 |
* 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
|
2727 |
*/ |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2728 |
if (pa->origin_origin) { |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
2729 |
pa->used -= pa->origin_origin->ds_phys->ds_referenced_bytes; |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2730 |
pa->comp -= pa->origin_origin->ds_phys->ds_compressed_bytes; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2731 |
pa->uncomp -= pa->origin_origin->ds_phys->ds_uncompressed_bytes; |
2082 | 2732 |
} |
2733 |
||
2734 |
/* Check that there is enough space here */ |
|
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2735 |
err = dsl_dir_transfer_possible(origin_ds->ds_dir, hds->ds_dir, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2736 |
pa->used); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2737 |
if (err) |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2738 |
return (err); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2739 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2740 |
/* |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2741 |
* Compute the amounts of space that will be used by snapshots |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2742 |
* after the promotion (for both origin and clone). For each, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2743 |
* it is the amount of space that will be on all of their |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2744 |
* deadlists (that was not born before their new origin). |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2745 |
*/ |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2746 |
if (hds->ds_dir->dd_phys->dd_flags & DD_FLAG_USED_BREAKDOWN) { |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2747 |
uint64_t space; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2748 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2749 |
/* |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2750 |
* Note, typically this will not be a clone of a clone, |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2751 |
* so dd_origin_txg will be < TXG_INITIAL, so |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2752 |
* these snaplist_space() -> dsl_deadlist_space_range() |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2753 |
* calls will be fast because they do not have to |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2754 |
* iterate over all bps. |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2755 |
*/ |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2756 |
snap = list_head(&pa->origin_snaps); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2757 |
err = snaplist_space(&pa->shared_snaps, |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2758 |
snap->ds->ds_dir->dd_origin_txg, &pa->cloneusedsnap); |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2759 |
if (err) |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2760 |
return (err); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2761 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2762 |
err = snaplist_space(&pa->clone_snaps, |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2763 |
snap->ds->ds_dir->dd_origin_txg, &space); |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2764 |
if (err) |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2765 |
return (err); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2766 |
pa->cloneusedsnap += space; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2767 |
} |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2768 |
if (origin_ds->ds_dir->dd_phys->dd_flags & DD_FLAG_USED_BREAKDOWN) { |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2769 |
err = snaplist_space(&pa->origin_snaps, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2770 |
origin_ds->ds_phys->ds_creation_txg, &pa->originusedsnap); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2771 |
if (err) |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2772 |
return (err); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2773 |
} |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2774 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2775 |
return (0); |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10575
diff
changeset
|
2776 |
out: |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10575
diff
changeset
|
2777 |
pa->err_ds = snap->ds->ds_snapname; |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10575
diff
changeset
|
2778 |
return (err); |
2199 | 2779 |
} |
2082 | 2780 |
|
2199 | 2781 |
static void |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2782 |
dsl_dataset_promote_sync(void *arg1, void *arg2, dmu_tx_t *tx) |
2199 | 2783 |
{ |
2784 |
dsl_dataset_t *hds = arg1; |
|
2785 |
struct promotearg *pa = arg2; |
|
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2786 |
struct promotenode *snap = list_head(&pa->shared_snaps); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2787 |
dsl_dataset_t *origin_ds = snap->ds; |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2788 |
dsl_dataset_t *origin_head; |
2199 | 2789 |
dsl_dir_t *dd = hds->ds_dir; |
2790 |
dsl_pool_t *dp = hds->ds_dir->dd_pool; |
|
5367 | 2791 |
dsl_dir_t *odd = NULL; |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2792 |
uint64_t oldnext_obj; |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2793 |
int64_t delta; |
2199 | 2794 |
|
2795 |
ASSERT(0 == (hds->ds_phys->ds_flags & DS_FLAG_NOPROMOTE)); |
|
2796 |
||
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2797 |
snap = list_head(&pa->origin_snaps); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2798 |
origin_head = snap->ds; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2799 |
|
2417 | 2800 |
/* |
5367 | 2801 |
* We need to explicitly open odd, since origin_ds's dd will be |
2417 | 2802 |
* changing. |
2803 |
*/ |
|
5367 | 2804 |
VERIFY(0 == dsl_dir_open_obj(dp, origin_ds->ds_dir->dd_object, |
2805 |
NULL, FTAG, &odd)); |
|
2082 | 2806 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2807 |
/* change origin's next snap */ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2808 |
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
|
2809 |
oldnext_obj = origin_ds->ds_phys->ds_next_snap_obj; |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2810 |
snap = list_tail(&pa->clone_snaps); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2811 |
ASSERT3U(snap->ds->ds_phys->ds_prev_snap_obj, ==, origin_ds->ds_object); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2812 |
origin_ds->ds_phys->ds_next_snap_obj = snap->ds->ds_object; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2813 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2814 |
/* change the origin's next clone */ |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2815 |
if (origin_ds->ds_phys->ds_next_clones_obj) { |
10801
e0bf032e8673
6822816 assertion failed: zap_remove_int(ds_next_clones_obj) returns ENOENT
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10799
diff
changeset
|
2816 |
remove_from_next_clones(origin_ds, snap->ds->ds_object, tx); |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2817 |
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
|
2818 |
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
|
2819 |
oldnext_obj, tx)); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2820 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
2821 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2822 |
/* change origin */ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2823 |
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
|
2824 |
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
|
2825 |
dd->dd_phys->dd_origin_obj = odd->dd_phys->dd_origin_obj; |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2826 |
dd->dd_origin_txg = origin_head->ds_dir->dd_origin_txg; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2827 |
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
|
2828 |
odd->dd_phys->dd_origin_obj = origin_ds->ds_object; |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2829 |
origin_head->ds_dir->dd_origin_txg = |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2830 |
origin_ds->ds_phys->ds_creation_txg; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2831 |
|
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2832 |
/* change dd_clone entries */ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2833 |
if (spa_version(dp->dp_spa) >= SPA_VERSION_DIR_CLONES) { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2834 |
VERIFY3U(0, ==, zap_remove_int(dp->dp_meta_objset, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2835 |
odd->dd_phys->dd_clones, hds->ds_object, tx)); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2836 |
VERIFY3U(0, ==, zap_add_int(dp->dp_meta_objset, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2837 |
pa->origin_origin->ds_dir->dd_phys->dd_clones, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2838 |
hds->ds_object, tx)); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2839 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2840 |
VERIFY3U(0, ==, zap_remove_int(dp->dp_meta_objset, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2841 |
pa->origin_origin->ds_dir->dd_phys->dd_clones, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2842 |
origin_head->ds_object, tx)); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2843 |
if (dd->dd_phys->dd_clones == 0) { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2844 |
dd->dd_phys->dd_clones = zap_create(dp->dp_meta_objset, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2845 |
DMU_OT_DSL_CLONES, DMU_OT_NONE, 0, tx); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2846 |
} |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2847 |
VERIFY3U(0, ==, zap_add_int(dp->dp_meta_objset, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2848 |
dd->dd_phys->dd_clones, origin_head->ds_object, tx)); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2849 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2850 |
} |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2851 |
|
2082 | 2852 |
/* move snapshots to this dir */ |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2853 |
for (snap = list_head(&pa->shared_snaps); snap; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2854 |
snap = list_next(&pa->shared_snaps, snap)) { |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2855 |
dsl_dataset_t *ds = snap->ds; |
2082 | 2856 |
|
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7077
diff
changeset
|
2857 |
/* unregister props as dsl_dir is changing */ |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2858 |
if (ds->ds_objset) { |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2859 |
dmu_objset_evict(ds->ds_objset); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
2860 |
ds->ds_objset = NULL; |
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7077
diff
changeset
|
2861 |
} |
2082 | 2862 |
/* move snap name entry */ |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2863 |
VERIFY(0 == dsl_dataset_get_snapname(ds)); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2864 |
VERIFY(0 == dsl_dataset_snap_remove(origin_head, |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2865 |
ds->ds_snapname, tx)); |
2199 | 2866 |
VERIFY(0 == zap_add(dp->dp_meta_objset, |
2082 | 2867 |
hds->ds_phys->ds_snapnames_zapobj, ds->ds_snapname, |
2868 |
8, 1, &ds->ds_object, tx)); |
|
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2869 |
|
2082 | 2870 |
/* change containing dsl_dir */ |
2871 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
|
5367 | 2872 |
ASSERT3U(ds->ds_phys->ds_dir_obj, ==, odd->dd_object); |
2082 | 2873 |
ds->ds_phys->ds_dir_obj = dd->dd_object; |
5367 | 2874 |
ASSERT3P(ds->ds_dir, ==, odd); |
2082 | 2875 |
dsl_dir_close(ds->ds_dir, ds); |
2199 | 2876 |
VERIFY(0 == dsl_dir_open_obj(dp, dd->dd_object, |
2082 | 2877 |
NULL, ds, &ds->ds_dir)); |
2878 |
||
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2879 |
/* move any clone references */ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2880 |
if (ds->ds_phys->ds_next_clones_obj && |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2881 |
spa_version(dp->dp_spa) >= SPA_VERSION_DIR_CLONES) { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2882 |
zap_cursor_t zc; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2883 |
zap_attribute_t za; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2884 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2885 |
for (zap_cursor_init(&zc, dp->dp_meta_objset, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2886 |
ds->ds_phys->ds_next_clones_obj); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2887 |
zap_cursor_retrieve(&zc, &za) == 0; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2888 |
zap_cursor_advance(&zc)) { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2889 |
dsl_dataset_t *cnds; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2890 |
uint64_t o; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2891 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2892 |
if (za.za_first_integer == oldnext_obj) { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2893 |
/* |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2894 |
* We've already moved the |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2895 |
* origin's reference. |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2896 |
*/ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2897 |
continue; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2898 |
} |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2899 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2900 |
VERIFY3U(0, ==, dsl_dataset_hold_obj(dp, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2901 |
za.za_first_integer, FTAG, &cnds)); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2902 |
o = cnds->ds_dir->dd_phys->dd_head_dataset_obj; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2903 |
|
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2904 |
VERIFY3U(zap_remove_int(dp->dp_meta_objset, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2905 |
odd->dd_phys->dd_clones, o, tx), ==, 0); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2906 |
VERIFY3U(zap_add_int(dp->dp_meta_objset, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2907 |
dd->dd_phys->dd_clones, o, tx), ==, 0); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2908 |
dsl_dataset_rele(cnds, FTAG); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2909 |
} |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2910 |
zap_cursor_fini(&zc); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2911 |
} |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
2912 |
|
2082 | 2913 |
ASSERT3U(dsl_prop_numcb(ds), ==, 0); |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2914 |
} |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2915 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2916 |
/* |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2917 |
* Change space accounting. |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2918 |
* Note, pa->*usedsnap and dd_used_breakdown[SNAP] will either |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2919 |
* both be valid, or both be 0 (resulting in delta == 0). This |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2920 |
* is true for each of {clone,origin} independently. |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2921 |
*/ |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2922 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2923 |
delta = pa->cloneusedsnap - |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2924 |
dd->dd_phys->dd_used_breakdown[DD_USED_SNAP]; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2925 |
ASSERT3S(delta, >=, 0); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2926 |
ASSERT3U(pa->used, >=, delta); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2927 |
dsl_dir_diduse_space(dd, DD_USED_SNAP, delta, 0, 0, tx); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2928 |
dsl_dir_diduse_space(dd, DD_USED_HEAD, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2929 |
pa->used - delta, pa->comp, pa->uncomp, tx); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2930 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2931 |
delta = pa->originusedsnap - |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2932 |
odd->dd_phys->dd_used_breakdown[DD_USED_SNAP]; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2933 |
ASSERT3S(delta, <=, 0); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2934 |
ASSERT3U(pa->used, >=, -delta); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2935 |
dsl_dir_diduse_space(odd, DD_USED_SNAP, delta, 0, 0, tx); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2936 |
dsl_dir_diduse_space(odd, DD_USED_HEAD, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2937 |
-pa->used - delta, -pa->comp, -pa->uncomp, tx); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2938 |
|
5367 | 2939 |
origin_ds->ds_phys->ds_unique_bytes = pa->unique; |
2082 | 2940 |
|
4543 | 2941 |
/* log history record */ |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2942 |
spa_history_log_internal(LOG_DS_PROMOTE, dd->dd_pool->dp_spa, tx, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
2943 |
"dataset = %llu", hds->ds_object); |
4543 | 2944 |
|
5367 | 2945 |
dsl_dir_close(odd, FTAG); |
2082 | 2946 |
} |
2947 |
||
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2948 |
static char *snaplist_tag = "snaplist"; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2949 |
/* |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2950 |
* Make a list of dsl_dataset_t's for the snapshots between first_obj |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2951 |
* (exclusive) and last_obj (inclusive). The list will be in reverse |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2952 |
* order (last_obj will be the list_head()). If first_obj == 0, do all |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2953 |
* snapshots back to this dataset's origin. |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2954 |
*/ |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2955 |
static int |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2956 |
snaplist_make(dsl_pool_t *dp, boolean_t own, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2957 |
uint64_t first_obj, uint64_t last_obj, list_t *l) |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2958 |
{ |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2959 |
uint64_t obj = last_obj; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2960 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2961 |
ASSERT(RW_LOCK_HELD(&dp->dp_config_rwlock)); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2962 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2963 |
list_create(l, sizeof (struct promotenode), |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2964 |
offsetof(struct promotenode, link)); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2965 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2966 |
while (obj != first_obj) { |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2967 |
dsl_dataset_t *ds; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2968 |
struct promotenode *snap; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2969 |
int err; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2970 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2971 |
if (own) { |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2972 |
err = dsl_dataset_own_obj(dp, obj, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2973 |
0, snaplist_tag, &ds); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2974 |
if (err == 0) |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2975 |
dsl_dataset_make_exclusive(ds, snaplist_tag); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2976 |
} else { |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2977 |
err = dsl_dataset_hold_obj(dp, obj, snaplist_tag, &ds); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2978 |
} |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2979 |
if (err == ENOENT) { |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2980 |
/* lost race with snapshot destroy */ |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2981 |
struct promotenode *last = list_tail(l); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2982 |
ASSERT(obj != last->ds->ds_phys->ds_prev_snap_obj); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2983 |
obj = last->ds->ds_phys->ds_prev_snap_obj; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2984 |
continue; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2985 |
} else if (err) { |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2986 |
return (err); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2987 |
} |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2988 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2989 |
if (first_obj == 0) |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2990 |
first_obj = ds->ds_dir->dd_phys->dd_origin_obj; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2991 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2992 |
snap = kmem_alloc(sizeof (struct promotenode), KM_SLEEP); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2993 |
snap->ds = ds; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2994 |
list_insert_tail(l, snap); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2995 |
obj = ds->ds_phys->ds_prev_snap_obj; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2996 |
} |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2997 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2998 |
return (0); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
2999 |
} |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3000 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3001 |
static int |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3002 |
snaplist_space(list_t *l, uint64_t mintxg, uint64_t *spacep) |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3003 |
{ |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3004 |
struct promotenode *snap; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3005 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3006 |
*spacep = 0; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3007 |
for (snap = list_head(l); snap; snap = list_next(l, snap)) { |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3008 |
uint64_t used, comp, uncomp; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3009 |
dsl_deadlist_space_range(&snap->ds->ds_deadlist, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3010 |
mintxg, UINT64_MAX, &used, &comp, &uncomp); |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3011 |
*spacep += used; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3012 |
} |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3013 |
return (0); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3014 |
} |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3015 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3016 |
static void |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3017 |
snaplist_destroy(list_t *l, boolean_t own) |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3018 |
{ |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3019 |
struct promotenode *snap; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3020 |
|
8779
f164e0e90508
6784924 panic while ludelete (zfs destroy)
Mark J Musante <Mark.Musante@Sun.COM>
parents:
8746
diff
changeset
|
3021 |
if (!l || !list_link_active(&l->list_head)) |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3022 |
return; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3023 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3024 |
while ((snap = list_tail(l)) != NULL) { |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3025 |
list_remove(l, snap); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3026 |
if (own) |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3027 |
dsl_dataset_disown(snap->ds, snaplist_tag); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3028 |
else |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3029 |
dsl_dataset_rele(snap->ds, snaplist_tag); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3030 |
kmem_free(snap, sizeof (struct promotenode)); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3031 |
} |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3032 |
list_destroy(l); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3033 |
} |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3034 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3035 |
/* |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3036 |
* Promote a clone. Nomenclature note: |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3037 |
* "clone" or "cds": the original clone which is being promoted |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3038 |
* "origin" or "ods": the snapshot which is originally clone's origin |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3039 |
* "origin head" or "ohds": the dataset which is the head |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3040 |
* (filesystem/volume) for the origin |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3041 |
* "origin origin": the origin of the origin's filesystem (typically |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3042 |
* NULL, indicating that the clone is not a clone of a clone). |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3043 |
*/ |
2082 | 3044 |
int |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10575
diff
changeset
|
3045 |
dsl_dataset_promote(const char *name, char *conflsnap) |
2082 | 3046 |
{ |
3047 |
dsl_dataset_t *ds; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3048 |
dsl_dir_t *dd; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3049 |
dsl_pool_t *dp; |
2082 | 3050 |
dmu_object_info_t doi; |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3051 |
struct promotearg pa = { 0 }; |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
3052 |
struct promotenode *snap; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3053 |
int err; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3054 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3055 |
err = dsl_dataset_hold(name, FTAG, &ds); |
2082 | 3056 |
if (err) |
3057 |
return (err); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3058 |
dd = ds->ds_dir; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3059 |
dp = dd->dd_pool; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3060 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3061 |
err = dmu_object_info(dp->dp_meta_objset, |
2082 | 3062 |
ds->ds_phys->ds_snapnames_zapobj, &doi); |
3063 |
if (err) { |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3064 |
dsl_dataset_rele(ds, FTAG); |
2082 | 3065 |
return (err); |
3066 |
} |
|
3067 |
||
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3068 |
if (dsl_dataset_is_snapshot(ds) || dd->dd_phys->dd_origin_obj == 0) { |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3069 |
dsl_dataset_rele(ds, FTAG); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3070 |
return (EINVAL); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3071 |
} |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3072 |
|
2082 | 3073 |
/* |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3074 |
* 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
|
3075 |
* 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
|
3076 |
* 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
|
3077 |
* namespace. |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3078 |
*/ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3079 |
rw_enter(&dp->dp_config_rwlock, RW_READER); |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3080 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3081 |
err = snaplist_make(dp, B_TRUE, 0, dd->dd_phys->dd_origin_obj, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3082 |
&pa.shared_snaps); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3083 |
if (err != 0) |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3084 |
goto out; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3085 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3086 |
err = snaplist_make(dp, B_FALSE, 0, ds->ds_object, &pa.clone_snaps); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3087 |
if (err != 0) |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3088 |
goto out; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3089 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3090 |
snap = list_head(&pa.shared_snaps); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3091 |
ASSERT3U(snap->ds->ds_object, ==, dd->dd_phys->dd_origin_obj); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3092 |
err = snaplist_make(dp, B_FALSE, dd->dd_phys->dd_origin_obj, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3093 |
snap->ds->ds_dir->dd_phys->dd_head_dataset_obj, &pa.origin_snaps); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3094 |
if (err != 0) |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3095 |
goto out; |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3096 |
|
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3097 |
if (snap->ds->ds_dir->dd_phys->dd_origin_obj != 0) { |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3098 |
err = dsl_dataset_hold_obj(dp, |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3099 |
snap->ds->ds_dir->dd_phys->dd_origin_obj, |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3100 |
FTAG, &pa.origin_origin); |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3101 |
if (err != 0) |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3102 |
goto out; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3103 |
} |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3104 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3105 |
out: |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3106 |
rw_exit(&dp->dp_config_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3107 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3108 |
/* |
2082 | 3109 |
* Add in 128x the snapnames zapobj size, since we will be moving |
3110 |
* a bunch of snapnames to the promoted ds, and dirtying their |
|
3111 |
* bonus buffers. |
|
3112 |
*/ |
|
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3113 |
if (err == 0) { |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3114 |
err = dsl_sync_task_do(dp, dsl_dataset_promote_check, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3115 |
dsl_dataset_promote_sync, ds, &pa, |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10816
diff
changeset
|
3116 |
2 + 2 * doi.doi_physical_blocks_512); |
10588
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10575
diff
changeset
|
3117 |
if (err && pa.err_ds && conflsnap) |
dc03f981ea18
6438937 if 'zfs destroy' fails, it can leave a zvol device link missing
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
10575
diff
changeset
|
3118 |
(void) strncpy(conflsnap, pa.err_ds, MAXNAMELEN); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3119 |
} |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3120 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3121 |
snaplist_destroy(&pa.shared_snaps, B_TRUE); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3122 |
snaplist_destroy(&pa.clone_snaps, B_FALSE); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3123 |
snaplist_destroy(&pa.origin_snaps, B_FALSE); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3124 |
if (pa.origin_origin) |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3125 |
dsl_dataset_rele(pa.origin_origin, FTAG); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3126 |
dsl_dataset_rele(ds, FTAG); |
2082 | 3127 |
return (err); |
3128 |
} |
|
3912 | 3129 |
|
5367 | 3130 |
struct cloneswaparg { |
3131 |
dsl_dataset_t *cds; /* clone dataset */ |
|
3132 |
dsl_dataset_t *ohds; /* origin's head dataset */ |
|
3133 |
boolean_t force; |
|
5481
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3134 |
int64_t unused_refres_delta; /* change in unconsumed refreservation */ |
5367 | 3135 |
}; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3136 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3137 |
/* ARGSUSED */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3138 |
static int |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3139 |
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
|
3140 |
{ |
5367 | 3141 |
struct cloneswaparg *csa = arg1; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3142 |
|
5367 | 3143 |
/* they should both be heads */ |
3144 |
if (dsl_dataset_is_snapshot(csa->cds) || |
|
3145 |
dsl_dataset_is_snapshot(csa->ohds)) |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3146 |
return (EINVAL); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3147 |
|
5367 | 3148 |
/* the branch point should be just before them */ |
3149 |
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
|
3150 |
return (EINVAL); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3151 |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3152 |
/* cds should be the clone (unless they are unrelated) */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3153 |
if (csa->cds->ds_prev != NULL && |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3154 |
csa->cds->ds_prev != csa->cds->ds_dir->dd_pool->dp_origin_snap && |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3155 |
csa->ohds->ds_object != |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3156 |
csa->cds->ds_prev->ds_phys->ds_next_snap_obj) |
5367 | 3157 |
return (EINVAL); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3158 |
|
5367 | 3159 |
/* the clone should be a child of the origin */ |
3160 |
if (csa->cds->ds_dir->dd_parent != csa->ohds->ds_dir) |
|
3161 |
return (EINVAL); |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3162 |
|
5367 | 3163 |
/* ohds shouldn't be modified unless 'force' */ |
3164 |
if (!csa->force && dsl_dataset_modified_since_lastsnap(csa->ohds)) |
|
3165 |
return (ETXTBSY); |
|
5481
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3166 |
|
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3167 |
/* adjust amount of any unconsumed refreservation */ |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3168 |
csa->unused_refres_delta = |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3169 |
(int64_t)MIN(csa->ohds->ds_reserved, |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3170 |
csa->ohds->ds_phys->ds_unique_bytes) - |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3171 |
(int64_t)MIN(csa->ohds->ds_reserved, |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3172 |
csa->cds->ds_phys->ds_unique_bytes); |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3173 |
|
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3174 |
if (csa->unused_refres_delta > 0 && |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3175 |
csa->unused_refres_delta > |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3176 |
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
|
3177 |
return (ENOSPC); |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3178 |
|
10799
395576ddfea9
6881321 zfs test rsend_012_pos panics when running daily.0807 archives
Chris Kirby <Chris.Kirby@sun.com>
parents:
10588
diff
changeset
|
3179 |
if (csa->ohds->ds_quota != 0 && |
395576ddfea9
6881321 zfs test rsend_012_pos panics when running daily.0807 archives
Chris Kirby <Chris.Kirby@sun.com>
parents:
10588
diff
changeset
|
3180 |
csa->cds->ds_phys->ds_unique_bytes > csa->ohds->ds_quota) |
395576ddfea9
6881321 zfs test rsend_012_pos panics when running daily.0807 archives
Chris Kirby <Chris.Kirby@sun.com>
parents:
10588
diff
changeset
|
3181 |
return (EDQUOT); |
395576ddfea9
6881321 zfs test rsend_012_pos panics when running daily.0807 archives
Chris Kirby <Chris.Kirby@sun.com>
parents:
10588
diff
changeset
|
3182 |
|
5367 | 3183 |
return (0); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3184 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3185 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3186 |
/* ARGSUSED */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3187 |
static void |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3188 |
dsl_dataset_clone_swap_sync(void *arg1, void *arg2, dmu_tx_t *tx) |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3189 |
{ |
5367 | 3190 |
struct cloneswaparg *csa = arg1; |
3191 |
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
|
3192 |
|
5481
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3193 |
ASSERT(csa->cds->ds_reserved == 0); |
10799
395576ddfea9
6881321 zfs test rsend_012_pos panics when running daily.0807 archives
Chris Kirby <Chris.Kirby@sun.com>
parents:
10588
diff
changeset
|
3194 |
ASSERT(csa->ohds->ds_quota == 0 || |
395576ddfea9
6881321 zfs test rsend_012_pos panics when running daily.0807 archives
Chris Kirby <Chris.Kirby@sun.com>
parents:
10588
diff
changeset
|
3195 |
csa->cds->ds_phys->ds_unique_bytes <= csa->ohds->ds_quota); |
5481
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3196 |
|
5367 | 3197 |
dmu_buf_will_dirty(csa->cds->ds_dbuf, tx); |
3198 |
dmu_buf_will_dirty(csa->ohds->ds_dbuf, tx); |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3199 |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3200 |
if (csa->cds->ds_objset != NULL) { |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3201 |
dmu_objset_evict(csa->cds->ds_objset); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3202 |
csa->cds->ds_objset = NULL; |
5367 | 3203 |
} |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3204 |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3205 |
if (csa->ohds->ds_objset != NULL) { |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3206 |
dmu_objset_evict(csa->ohds->ds_objset); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3207 |
csa->ohds->ds_objset = NULL; |
5367 | 3208 |
} |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3209 |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3210 |
/* |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3211 |
* Reset origin's unique bytes, if it exists. |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3212 |
*/ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3213 |
if (csa->cds->ds_prev) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3214 |
dsl_dataset_t *origin = csa->cds->ds_prev; |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3215 |
uint64_t comp, uncomp; |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3216 |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3217 |
dmu_buf_will_dirty(origin->ds_dbuf, tx); |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3218 |
dsl_deadlist_space_range(&csa->cds->ds_deadlist, |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3219 |
origin->ds_phys->ds_prev_snap_txg, UINT64_MAX, |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3220 |
&origin->ds_phys->ds_unique_bytes, &comp, &uncomp); |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3221 |
} |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3222 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3223 |
/* swap blkptrs */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3224 |
{ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3225 |
blkptr_t tmp; |
5367 | 3226 |
tmp = csa->ohds->ds_phys->ds_bp; |
3227 |
csa->ohds->ds_phys->ds_bp = csa->cds->ds_phys->ds_bp; |
|
3228 |
csa->cds->ds_phys->ds_bp = tmp; |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3229 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3230 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3231 |
/* set dd_*_bytes */ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3232 |
{ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3233 |
int64_t dused, dcomp, duncomp; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3234 |
uint64_t cdl_used, cdl_comp, cdl_uncomp; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3235 |
uint64_t odl_used, odl_comp, odl_uncomp; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3236 |
|
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3237 |
ASSERT3U(csa->cds->ds_dir->dd_phys-> |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3238 |
dd_used_breakdown[DD_USED_SNAP], ==, 0); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3239 |
|
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3240 |
dsl_deadlist_space(&csa->cds->ds_deadlist, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3241 |
&cdl_used, &cdl_comp, &cdl_uncomp); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3242 |
dsl_deadlist_space(&csa->ohds->ds_deadlist, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3243 |
&odl_used, &odl_comp, &odl_uncomp); |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3244 |
|
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
3245 |
dused = csa->cds->ds_phys->ds_referenced_bytes + cdl_used - |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
3246 |
(csa->ohds->ds_phys->ds_referenced_bytes + odl_used); |
5367 | 3247 |
dcomp = csa->cds->ds_phys->ds_compressed_bytes + cdl_comp - |
3248 |
(csa->ohds->ds_phys->ds_compressed_bytes + odl_comp); |
|
3249 |
duncomp = csa->cds->ds_phys->ds_uncompressed_bytes + |
|
3250 |
cdl_uncomp - |
|
3251 |
(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
|
3252 |
|
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3253 |
dsl_dir_diduse_space(csa->ohds->ds_dir, DD_USED_HEAD, |
5367 | 3254 |
dused, dcomp, duncomp, tx); |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3255 |
dsl_dir_diduse_space(csa->cds->ds_dir, DD_USED_HEAD, |
5367 | 3256 |
-dused, -dcomp, -duncomp, tx); |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3257 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3258 |
/* |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3259 |
* The difference in the space used by snapshots is the |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3260 |
* difference in snapshot space due to the head's |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3261 |
* deadlist (since that's the only thing that's |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3262 |
* changing that affects the snapused). |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3263 |
*/ |
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3264 |
dsl_deadlist_space_range(&csa->cds->ds_deadlist, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3265 |
csa->ohds->ds_dir->dd_origin_txg, UINT64_MAX, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3266 |
&cdl_used, &cdl_comp, &cdl_uncomp); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3267 |
dsl_deadlist_space_range(&csa->ohds->ds_deadlist, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3268 |
csa->ohds->ds_dir->dd_origin_txg, UINT64_MAX, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3269 |
&odl_used, &odl_comp, &odl_uncomp); |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3270 |
dsl_dir_transfer_space(csa->ohds->ds_dir, cdl_used - odl_used, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3271 |
DD_USED_HEAD, DD_USED_SNAP, tx); |
5367 | 3272 |
} |
3273 |
||
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3274 |
/* swap ds_*_bytes */ |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
3275 |
SWITCH64(csa->ohds->ds_phys->ds_referenced_bytes, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
3276 |
csa->cds->ds_phys->ds_referenced_bytes); |
5367 | 3277 |
SWITCH64(csa->ohds->ds_phys->ds_compressed_bytes, |
3278 |
csa->cds->ds_phys->ds_compressed_bytes); |
|
3279 |
SWITCH64(csa->ohds->ds_phys->ds_uncompressed_bytes, |
|
3280 |
csa->cds->ds_phys->ds_uncompressed_bytes); |
|
5481
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3281 |
SWITCH64(csa->ohds->ds_phys->ds_unique_bytes, |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3282 |
csa->cds->ds_phys->ds_unique_bytes); |
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3283 |
|
1364fb7de75d
6619182 new non-sparse zvols should get refreservations
ck153898
parents:
5475
diff
changeset
|
3284 |
/* apply any parent delta for change in unconsumed refreservation */ |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3285 |
dsl_dir_diduse_space(csa->ohds->ds_dir, DD_USED_REFRSRV, |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7385
diff
changeset
|
3286 |
csa->unused_refres_delta, 0, 0, tx); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3287 |
|
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3288 |
/* |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3289 |
* Swap deadlists. |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3290 |
*/ |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3291 |
dsl_deadlist_close(&csa->cds->ds_deadlist); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3292 |
dsl_deadlist_close(&csa->ohds->ds_deadlist); |
5367 | 3293 |
SWITCH64(csa->ohds->ds_phys->ds_deadlist_obj, |
3294 |
csa->cds->ds_phys->ds_deadlist_obj); |
|
12470
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3295 |
dsl_deadlist_open(&csa->cds->ds_deadlist, dp->dp_meta_objset, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3296 |
csa->cds->ds_phys->ds_deadlist_obj); |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3297 |
dsl_deadlist_open(&csa->ohds->ds_deadlist, dp->dp_meta_objset, |
54258108784b
6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12450
diff
changeset
|
3298 |
csa->ohds->ds_phys->ds_deadlist_obj); |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
3299 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3300 |
dsl_scan_ds_clone_swapped(csa->ohds, csa->cds, tx); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3301 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3302 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3303 |
/* |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3304 |
* Swap 'clone' with its origin head datasets. Used at the end of "zfs |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3305 |
* recv" into an existing fs to swizzle the file system to the new |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3306 |
* version, and by "zfs rollback". Can also be used to swap two |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3307 |
* independent head datasets if neither has any snapshots. |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3308 |
*/ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3309 |
int |
5367 | 3310 |
dsl_dataset_clone_swap(dsl_dataset_t *clone, dsl_dataset_t *origin_head, |
3311 |
boolean_t force) |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3312 |
{ |
5367 | 3313 |
struct cloneswaparg csa; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3314 |
int error; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3315 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3316 |
ASSERT(clone->ds_owner); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3317 |
ASSERT(origin_head->ds_owner); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3318 |
retry: |
12711
7ba0ca9a0395
6952867 recursive rw_enter in dsl_dataset_clone_swap
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12687
diff
changeset
|
3319 |
/* |
7ba0ca9a0395
6952867 recursive rw_enter in dsl_dataset_clone_swap
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12687
diff
changeset
|
3320 |
* Need exclusive access for the swap. If we're swapping these |
7ba0ca9a0395
6952867 recursive rw_enter in dsl_dataset_clone_swap
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12687
diff
changeset
|
3321 |
* datasets back after an error, we already hold the locks. |
7ba0ca9a0395
6952867 recursive rw_enter in dsl_dataset_clone_swap
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12687
diff
changeset
|
3322 |
*/ |
7ba0ca9a0395
6952867 recursive rw_enter in dsl_dataset_clone_swap
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12687
diff
changeset
|
3323 |
if (!RW_WRITE_HELD(&clone->ds_rwlock)) |
7ba0ca9a0395
6952867 recursive rw_enter in dsl_dataset_clone_swap
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12687
diff
changeset
|
3324 |
rw_enter(&clone->ds_rwlock, RW_WRITER); |
7ba0ca9a0395
6952867 recursive rw_enter in dsl_dataset_clone_swap
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12687
diff
changeset
|
3325 |
if (!RW_WRITE_HELD(&origin_head->ds_rwlock) && |
7ba0ca9a0395
6952867 recursive rw_enter in dsl_dataset_clone_swap
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12687
diff
changeset
|
3326 |
!rw_tryenter(&origin_head->ds_rwlock, RW_WRITER)) { |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3327 |
rw_exit(&clone->ds_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3328 |
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
|
3329 |
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
|
3330 |
rw_exit(&origin_head->ds_rwlock); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3331 |
goto retry; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3332 |
} |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3333 |
} |
5367 | 3334 |
csa.cds = clone; |
3335 |
csa.ohds = origin_head; |
|
3336 |
csa.force = force; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3337 |
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
|
3338 |
dsl_dataset_clone_swap_check, |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3339 |
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
|
3340 |
return (error); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3341 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5094
diff
changeset
|
3342 |
|
3912 | 3343 |
/* |
3344 |
* Given a pool name and a dataset object number in that pool, |
|
3345 |
* return the name of that dataset. |
|
3346 |
*/ |
|
3347 |
int |
|
3348 |
dsl_dsobj_to_dsname(char *pname, uint64_t obj, char *buf) |
|
3349 |
{ |
|
3350 |
spa_t *spa; |
|
3351 |
dsl_pool_t *dp; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3352 |
dsl_dataset_t *ds; |
3912 | 3353 |
int error; |
3354 |
||
3355 |
if ((error = spa_open(pname, &spa, FTAG)) != 0) |
|
3356 |
return (error); |
|
3357 |
dp = spa_get_dsl(spa); |
|
3358 |
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
|
3359 |
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
|
3360 |
dsl_dataset_name(ds, buf); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3361 |
dsl_dataset_rele(ds, FTAG); |
3912 | 3362 |
} |
3363 |
rw_exit(&dp->dp_config_rwlock); |
|
3364 |
spa_close(spa, FTAG); |
|
3365 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3366 |
return (error); |
3912 | 3367 |
} |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3368 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3369 |
int |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3370 |
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
|
3371 |
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
|
3372 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3373 |
int error = 0; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3374 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3375 |
ASSERT3S(asize, >, 0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3376 |
|
5831
48655d6b290b
6630761 In sub-filesystem, available space is less than refreservation space
ck153898
parents:
5712
diff
changeset
|
3377 |
/* |
48655d6b290b
6630761 In sub-filesystem, available space is less than refreservation space
ck153898
parents:
5712
diff
changeset
|
3378 |
* *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
|
3379 |
* unconsumed refreservation space. |
48655d6b290b
6630761 In sub-filesystem, available space is less than refreservation space
ck153898
parents:
5712
diff
changeset
|
3380 |
*/ |
48655d6b290b
6630761 In sub-filesystem, available space is less than refreservation space
ck153898
parents:
5712
diff
changeset
|
3381 |
*ref_rsrv = 0; |
48655d6b290b
6630761 In sub-filesystem, available space is less than refreservation space
ck153898
parents:
5712
diff
changeset
|
3382 |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3383 |
mutex_enter(&ds->ds_lock); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3384 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3385 |
* Make a space adjustment for reserved bytes. |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3386 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3387 |
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
|
3388 |
ASSERT3U(*used, >=, |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3389 |
ds->ds_reserved - ds->ds_phys->ds_unique_bytes); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3390 |
*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
|
3391 |
*ref_rsrv = |
48655d6b290b
6630761 In sub-filesystem, available space is less than refreservation space
ck153898
parents:
5712
diff
changeset
|
3392 |
asize - MIN(asize, parent_delta(ds, asize + inflight)); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3393 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3394 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3395 |
if (!check_quota || ds->ds_quota == 0) { |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3396 |
mutex_exit(&ds->ds_lock); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3397 |
return (0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3398 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3399 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3400 |
* 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
|
3401 |
* 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
|
3402 |
* 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
|
3403 |
* may free up space for us). |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3404 |
*/ |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
3405 |
if (ds->ds_phys->ds_referenced_bytes + inflight >= ds->ds_quota) { |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
3406 |
if (inflight > 0 || |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
3407 |
ds->ds_phys->ds_referenced_bytes < ds->ds_quota) |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3408 |
error = ERESTART; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3409 |
else |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3410 |
error = EDQUOT; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3411 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3412 |
mutex_exit(&ds->ds_lock); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3413 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3414 |
return (error); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3415 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3416 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3417 |
/* ARGSUSED */ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3418 |
static int |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3419 |
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
|
3420 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3421 |
dsl_dataset_t *ds = arg1; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3422 |
dsl_prop_setarg_t *psa = arg2; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3423 |
int err; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3424 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3425 |
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
|
3426 |
return (ENOTSUP); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3427 |
|
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3428 |
if ((err = dsl_prop_predict_sync(ds->ds_dir, psa)) != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3429 |
return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3430 |
|
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3431 |
if (psa->psa_effective_value == 0) |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3432 |
return (0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3433 |
|
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
3434 |
if (psa->psa_effective_value < ds->ds_phys->ds_referenced_bytes || |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3435 |
psa->psa_effective_value < ds->ds_reserved) |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3436 |
return (ENOSPC); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3437 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3438 |
return (0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3439 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3440 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3441 |
extern void dsl_prop_set_sync(void *, void *, dmu_tx_t *); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3442 |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3443 |
void |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3444 |
dsl_dataset_set_quota_sync(void *arg1, void *arg2, dmu_tx_t *tx) |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3445 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3446 |
dsl_dataset_t *ds = arg1; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3447 |
dsl_prop_setarg_t *psa = arg2; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3448 |
uint64_t effective_value = psa->psa_effective_value; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3449 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3450 |
dsl_prop_set_sync(ds, psa, tx); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3451 |
DSL_PROP_CHECK_PREDICTION(ds->ds_dir, psa); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3452 |
|
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3453 |
if (ds->ds_quota != effective_value) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3454 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3455 |
ds->ds_quota = effective_value; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3456 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3457 |
spa_history_log_internal(LOG_DS_REFQUOTA, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3458 |
ds->ds_dir->dd_pool->dp_spa, tx, "%lld dataset = %llu ", |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3459 |
(longlong_t)ds->ds_quota, ds->ds_object); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3460 |
} |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3461 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3462 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3463 |
int |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3464 |
dsl_dataset_set_quota(const char *dsname, zprop_source_t source, uint64_t quota) |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3465 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3466 |
dsl_dataset_t *ds; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3467 |
dsl_prop_setarg_t psa; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3468 |
int err; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3469 |
|
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3470 |
dsl_prop_setarg_init_uint64(&psa, "refquota", source, "a); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3471 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3472 |
err = dsl_dataset_hold(dsname, FTAG, &ds); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3473 |
if (err) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3474 |
return (err); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3475 |
|
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3476 |
/* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3477 |
* If someone removes a file, then tries to set the quota, we |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3478 |
* want to make sure the file freeing takes effect. |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3479 |
*/ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3480 |
txg_wait_open(ds->ds_dir->dd_pool, 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3481 |
|
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3482 |
err = dsl_sync_task_do(ds->ds_dir->dd_pool, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3483 |
dsl_dataset_set_quota_check, dsl_dataset_set_quota_sync, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3484 |
ds, &psa, 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3485 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3486 |
dsl_dataset_rele(ds, FTAG); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3487 |
return (err); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3488 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3489 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3490 |
static int |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3491 |
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
|
3492 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3493 |
dsl_dataset_t *ds = arg1; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3494 |
dsl_prop_setarg_t *psa = arg2; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3495 |
uint64_t effective_value; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3496 |
uint64_t unique; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3497 |
int err; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3498 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3499 |
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
|
3500 |
SPA_VERSION_REFRESERVATION) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3501 |
return (ENOTSUP); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3502 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3503 |
if (dsl_dataset_is_snapshot(ds)) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3504 |
return (EINVAL); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3505 |
|
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3506 |
if ((err = dsl_prop_predict_sync(ds->ds_dir, psa)) != 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3507 |
return (err); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3508 |
|
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3509 |
effective_value = psa->psa_effective_value; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3510 |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3511 |
/* |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3512 |
* 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
|
3513 |
* space estimates may be inaccurate. |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3514 |
*/ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3515 |
if (!dmu_tx_is_syncing(tx)) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3516 |
return (0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3517 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3518 |
mutex_enter(&ds->ds_lock); |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3519 |
if (!DS_UNIQUE_IS_ACCURATE(ds)) |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3520 |
dsl_dataset_recalc_head_uniq(ds); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3521 |
unique = ds->ds_phys->ds_unique_bytes; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3522 |
mutex_exit(&ds->ds_lock); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3523 |
|
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3524 |
if (MAX(unique, effective_value) > MAX(unique, ds->ds_reserved)) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3525 |
uint64_t delta = MAX(unique, effective_value) - |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8517
diff
changeset
|
3526 |
MAX(unique, ds->ds_reserved); |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8517
diff
changeset
|
3527 |
|
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8517
diff
changeset
|
3528 |
if (delta > dsl_dir_space_available(ds->ds_dir, NULL, 0, TRUE)) |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8517
diff
changeset
|
3529 |
return (ENOSPC); |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8517
diff
changeset
|
3530 |
if (ds->ds_quota > 0 && |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3531 |
effective_value > ds->ds_quota) |
8525
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8517
diff
changeset
|
3532 |
return (ENOSPC); |
e0e0e525d0f8
6788830 set large value to reservation cause core dump
Eric Schrock <Eric.Schrock@Sun.COM>
parents:
8517
diff
changeset
|
3533 |
} |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3534 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3535 |
return (0); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3536 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3537 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3538 |
static void |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3539 |
dsl_dataset_set_reservation_sync(void *arg1, void *arg2, dmu_tx_t *tx) |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3540 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3541 |
dsl_dataset_t *ds = arg1; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3542 |
dsl_prop_setarg_t *psa = arg2; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3543 |
uint64_t effective_value = psa->psa_effective_value; |
7595
2ff5700c7efc
6747355 finish closing race condition when setting refreservation
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7525
diff
changeset
|
3544 |
uint64_t unique; |
2ff5700c7efc
6747355 finish closing race condition when setting refreservation
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7525
diff
changeset
|
3545 |
int64_t delta; |
2ff5700c7efc
6747355 finish closing race condition when setting refreservation
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7525
diff
changeset
|
3546 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3547 |
dsl_prop_set_sync(ds, psa, tx); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3548 |
DSL_PROP_CHECK_PREDICTION(ds->ds_dir, psa); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3549 |
|
7595
2ff5700c7efc
6747355 finish closing race condition when setting refreservation
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7525
diff
changeset
|
3550 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
2ff5700c7efc
6747355 finish closing race condition when setting refreservation
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7525
diff
changeset
|
3551 |
|
2ff5700c7efc
6747355 finish closing race condition when setting refreservation
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7525
diff
changeset
|
3552 |
mutex_enter(&ds->ds_dir->dd_lock); |
2ff5700c7efc
6747355 finish closing race condition when setting refreservation
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7525
diff
changeset
|
3553 |
mutex_enter(&ds->ds_lock); |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3554 |
ASSERT(DS_UNIQUE_IS_ACCURATE(ds)); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3555 |
unique = ds->ds_phys->ds_unique_bytes; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3556 |
delta = MAX(0, (int64_t)(effective_value - unique)) - |
7595
2ff5700c7efc
6747355 finish closing race condition when setting refreservation
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7525
diff
changeset
|
3557 |
MAX(0, (int64_t)(ds->ds_reserved - unique)); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3558 |
ds->ds_reserved = effective_value; |
7595
2ff5700c7efc
6747355 finish closing race condition when setting refreservation
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7525
diff
changeset
|
3559 |
mutex_exit(&ds->ds_lock); |
2ff5700c7efc
6747355 finish closing race condition when setting refreservation
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7525
diff
changeset
|
3560 |
|
2ff5700c7efc
6747355 finish closing race condition when setting refreservation
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7525
diff
changeset
|
3561 |
dsl_dir_diduse_space(ds->ds_dir, DD_USED_REFRSRV, delta, 0, 0, tx); |
2ff5700c7efc
6747355 finish closing race condition when setting refreservation
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7525
diff
changeset
|
3562 |
mutex_exit(&ds->ds_dir->dd_lock); |
2ff5700c7efc
6747355 finish closing race condition when setting refreservation
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7525
diff
changeset
|
3563 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3564 |
spa_history_log_internal(LOG_DS_REFRESERV, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3565 |
ds->ds_dir->dd_pool->dp_spa, tx, "%lld dataset = %llu", |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3566 |
(longlong_t)effective_value, ds->ds_object); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3567 |
} |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3568 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3569 |
int |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3570 |
dsl_dataset_set_reservation(const char *dsname, zprop_source_t source, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3571 |
uint64_t reservation) |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3572 |
{ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3573 |
dsl_dataset_t *ds; |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3574 |
dsl_prop_setarg_t psa; |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3575 |
int err; |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3576 |
|
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3577 |
dsl_prop_setarg_init_uint64(&psa, "refreservation", source, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3578 |
&reservation); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3579 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3580 |
err = dsl_dataset_hold(dsname, FTAG, &ds); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3581 |
if (err) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3582 |
return (err); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3583 |
|
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3584 |
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
|
3585 |
dsl_dataset_set_reservation_check, |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3586 |
dsl_dataset_set_reservation_sync, ds, &psa, 0); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
10951
diff
changeset
|
3587 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
3588 |
dsl_dataset_rele(ds, FTAG); |
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3589 |
return (err); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
3590 |
} |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3591 |
|
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12470
diff
changeset
|
3592 |
typedef struct zfs_hold_cleanup_arg { |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3593 |
dsl_pool_t *dp; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3594 |
uint64_t dsobj; |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12470
diff
changeset
|
3595 |
char htag[MAXNAMELEN]; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12470
diff
changeset
|
3596 |
} zfs_hold_cleanup_arg_t; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12470
diff
changeset
|
3597 |
|
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12470
diff
changeset
|
3598 |
static void |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12470
diff
changeset
|
3599 |
dsl_dataset_user_release_onexit(void *arg) |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12470
diff
changeset
|
3600 |
{ |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12470
diff
changeset
|
3601 |
zfs_hold_cleanup_arg_t *ca = arg; |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12470
diff
changeset
|
3602 |
|
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3603 |
(void) dsl_dataset_user_release_tmp(ca->dp, ca->dsobj, ca->htag, |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3604 |
B_TRUE); |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12470
diff
changeset
|
3605 |
kmem_free(ca, sizeof (zfs_hold_cleanup_arg_t)); |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12470
diff
changeset
|
3606 |
} |
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12470
diff
changeset
|
3607 |
|
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3608 |
void |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3609 |
dsl_register_onexit_hold_cleanup(dsl_dataset_t *ds, const char *htag, |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3610 |
minor_t minor) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3611 |
{ |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3612 |
zfs_hold_cleanup_arg_t *ca; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3613 |
|
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3614 |
ca = kmem_alloc(sizeof (zfs_hold_cleanup_arg_t), KM_SLEEP); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3615 |
ca->dp = ds->ds_dir->dd_pool; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3616 |
ca->dsobj = ds->ds_object; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3617 |
(void) strlcpy(ca->htag, htag, sizeof (ca->htag)); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3618 |
VERIFY3U(0, ==, zfs_onexit_add_cb(minor, |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3619 |
dsl_dataset_user_release_onexit, ca, NULL)); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3620 |
} |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3621 |
|
10951
56fd5475e8fe
6896756 assertion failed: 0 == dsl_pool_user_hold(dp, ds->ds_object, htag, &now, tx)
Chris Kirby <Chris.Kirby@sun.com>
parents:
10922
diff
changeset
|
3622 |
/* |
13055 | 3623 |
* If you add new checks here, you may need to add |
3624 |
* additional checks to the "temporary" case in |
|
3625 |
* snapshot_check() in dmu_objset.c. |
|
10951
56fd5475e8fe
6896756 assertion failed: 0 == dsl_pool_user_hold(dp, ds->ds_object, htag, &now, tx)
Chris Kirby <Chris.Kirby@sun.com>
parents:
10922
diff
changeset
|
3626 |
*/ |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3627 |
static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3628 |
dsl_dataset_user_hold_check(void *arg1, void *arg2, dmu_tx_t *tx) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3629 |
{ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3630 |
dsl_dataset_t *ds = arg1; |
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3631 |
struct dsl_ds_holdarg *ha = arg2; |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3632 |
char *htag = ha->htag; |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3633 |
objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3634 |
int error = 0; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3635 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3636 |
if (spa_version(ds->ds_dir->dd_pool->dp_spa) < SPA_VERSION_USERREFS) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3637 |
return (ENOTSUP); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3638 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3639 |
if (!dsl_dataset_is_snapshot(ds)) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3640 |
return (EINVAL); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3641 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3642 |
/* tags must be unique */ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3643 |
mutex_enter(&ds->ds_lock); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3644 |
if (ds->ds_phys->ds_userrefs_obj) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3645 |
error = zap_lookup(mos, ds->ds_phys->ds_userrefs_obj, htag, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3646 |
8, 1, tx); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3647 |
if (error == 0) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3648 |
error = EEXIST; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3649 |
else if (error == ENOENT) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3650 |
error = 0; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3651 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3652 |
mutex_exit(&ds->ds_lock); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3653 |
|
10951
56fd5475e8fe
6896756 assertion failed: 0 == dsl_pool_user_hold(dp, ds->ds_object, htag, &now, tx)
Chris Kirby <Chris.Kirby@sun.com>
parents:
10922
diff
changeset
|
3654 |
if (error == 0 && ha->temphold && |
56fd5475e8fe
6896756 assertion failed: 0 == dsl_pool_user_hold(dp, ds->ds_object, htag, &now, tx)
Chris Kirby <Chris.Kirby@sun.com>
parents:
10922
diff
changeset
|
3655 |
strlen(htag) + MAX_TAG_PREFIX_LEN >= MAXNAMELEN) |
56fd5475e8fe
6896756 assertion failed: 0 == dsl_pool_user_hold(dp, ds->ds_object, htag, &now, tx)
Chris Kirby <Chris.Kirby@sun.com>
parents:
10922
diff
changeset
|
3656 |
error = E2BIG; |
56fd5475e8fe
6896756 assertion failed: 0 == dsl_pool_user_hold(dp, ds->ds_object, htag, &now, tx)
Chris Kirby <Chris.Kirby@sun.com>
parents:
10922
diff
changeset
|
3657 |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3658 |
return (error); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3659 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3660 |
|
13055 | 3661 |
void |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3662 |
dsl_dataset_user_hold_sync(void *arg1, void *arg2, dmu_tx_t *tx) |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3663 |
{ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3664 |
dsl_dataset_t *ds = arg1; |
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3665 |
struct dsl_ds_holdarg *ha = arg2; |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3666 |
char *htag = ha->htag; |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3667 |
dsl_pool_t *dp = ds->ds_dir->dd_pool; |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3668 |
objset_t *mos = dp->dp_meta_objset; |
10951
56fd5475e8fe
6896756 assertion failed: 0 == dsl_pool_user_hold(dp, ds->ds_object, htag, &now, tx)
Chris Kirby <Chris.Kirby@sun.com>
parents:
10922
diff
changeset
|
3669 |
uint64_t now = gethrestime_sec(); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3670 |
uint64_t zapobj; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3671 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3672 |
mutex_enter(&ds->ds_lock); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3673 |
if (ds->ds_phys->ds_userrefs_obj == 0) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3674 |
/* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3675 |
* This is the first user hold for this dataset. Create |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3676 |
* the userrefs zap object. |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3677 |
*/ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3678 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3679 |
zapobj = ds->ds_phys->ds_userrefs_obj = |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3680 |
zap_create(mos, DMU_OT_USERREFS, DMU_OT_NONE, 0, tx); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3681 |
} else { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3682 |
zapobj = ds->ds_phys->ds_userrefs_obj; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3683 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3684 |
ds->ds_userrefs++; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3685 |
mutex_exit(&ds->ds_lock); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3686 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3687 |
VERIFY(0 == zap_add(mos, zapobj, htag, 8, 1, &now, tx)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3688 |
|
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3689 |
if (ha->temphold) { |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3690 |
VERIFY(0 == dsl_pool_user_hold(dp, ds->ds_object, |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3691 |
htag, &now, tx)); |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3692 |
} |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3693 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3694 |
spa_history_log_internal(LOG_DS_USER_HOLD, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3695 |
dp->dp_spa, tx, "<%s> temp = %d dataset = %llu", htag, |
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3696 |
(int)ha->temphold, ds->ds_object); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3697 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3698 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3699 |
static int |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
3700 |
dsl_dataset_user_hold_one(const char *dsname, void *arg) |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3701 |
{ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3702 |
struct dsl_ds_holdarg *ha = arg; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3703 |
dsl_dataset_t *ds; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3704 |
int error; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3705 |
char *name; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3706 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3707 |
/* alloc a buffer to hold dsname@snapname plus terminating NULL */ |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3708 |
name = kmem_asprintf("%s@%s", dsname, ha->snapname); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3709 |
error = dsl_dataset_hold(name, ha->dstg, &ds); |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3710 |
strfree(name); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3711 |
if (error == 0) { |
10268
cb380b2e9410
6868130 ZFS hold/release "zfs hold -r tag snapshot" failed to check the existence of snapshot
Chris Kirby <chris.kirby@sun.com>
parents:
10242
diff
changeset
|
3712 |
ha->gotone = B_TRUE; |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3713 |
dsl_sync_task_create(ha->dstg, dsl_dataset_user_hold_check, |
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3714 |
dsl_dataset_user_hold_sync, ds, ha, 0); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3715 |
} else if (error == ENOENT && ha->recursive) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3716 |
error = 0; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3717 |
} else { |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
3718 |
(void) strlcpy(ha->failed, dsname, sizeof (ha->failed)); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3719 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3720 |
return (error); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3721 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3722 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3723 |
int |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3724 |
dsl_dataset_user_hold_for_send(dsl_dataset_t *ds, char *htag, |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3725 |
boolean_t temphold) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3726 |
{ |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3727 |
struct dsl_ds_holdarg *ha; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3728 |
int error; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3729 |
|
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3730 |
ha = kmem_zalloc(sizeof (struct dsl_ds_holdarg), KM_SLEEP); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3731 |
ha->htag = htag; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3732 |
ha->temphold = temphold; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3733 |
error = dsl_sync_task_do(ds->ds_dir->dd_pool, |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3734 |
dsl_dataset_user_hold_check, dsl_dataset_user_hold_sync, |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3735 |
ds, ha, 0); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3736 |
kmem_free(ha, sizeof (struct dsl_ds_holdarg)); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3737 |
|
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3738 |
return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3739 |
} |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3740 |
|
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3741 |
int |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3742 |
dsl_dataset_user_hold(char *dsname, char *snapname, char *htag, |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12470
diff
changeset
|
3743 |
boolean_t recursive, boolean_t temphold, int cleanup_fd) |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3744 |
{ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3745 |
struct dsl_ds_holdarg *ha; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3746 |
dsl_sync_task_t *dst; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3747 |
spa_t *spa; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3748 |
int error; |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3749 |
minor_t minor = 0; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3750 |
|
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3751 |
if (cleanup_fd != -1) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3752 |
/* Currently we only support cleanup-on-exit of tempholds. */ |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3753 |
if (!temphold) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3754 |
return (EINVAL); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3755 |
error = zfs_onexit_fd_hold(cleanup_fd, &minor); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3756 |
if (error) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3757 |
return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3758 |
} |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3759 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3760 |
ha = kmem_zalloc(sizeof (struct dsl_ds_holdarg), KM_SLEEP); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3761 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3762 |
(void) strlcpy(ha->failed, dsname, sizeof (ha->failed)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3763 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3764 |
error = spa_open(dsname, &spa, FTAG); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3765 |
if (error) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3766 |
kmem_free(ha, sizeof (struct dsl_ds_holdarg)); |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3767 |
if (cleanup_fd != -1) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3768 |
zfs_onexit_fd_rele(cleanup_fd); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3769 |
return (error); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3770 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3771 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3772 |
ha->dstg = dsl_sync_task_group_create(spa_get_dsl(spa)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3773 |
ha->htag = htag; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3774 |
ha->snapname = snapname; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3775 |
ha->recursive = recursive; |
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3776 |
ha->temphold = temphold; |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12470
diff
changeset
|
3777 |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3778 |
if (recursive) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3779 |
error = dmu_objset_find(dsname, dsl_dataset_user_hold_one, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3780 |
ha, DS_FIND_CHILDREN); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3781 |
} else { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3782 |
error = dsl_dataset_user_hold_one(dsname, ha); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3783 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3784 |
if (error == 0) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3785 |
error = dsl_sync_task_group_wait(ha->dstg); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3786 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3787 |
for (dst = list_head(&ha->dstg->dstg_tasks); dst; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3788 |
dst = list_next(&ha->dstg->dstg_tasks, dst)) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3789 |
dsl_dataset_t *ds = dst->dst_arg1; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3790 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3791 |
if (dst->dst_err) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3792 |
dsl_dataset_name(ds, ha->failed); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3793 |
*strchr(ha->failed, '@') = '\0'; |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3794 |
} else if (error == 0 && minor != 0 && temphold) { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3795 |
/* |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3796 |
* If this hold is to be released upon process exit, |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3797 |
* register that action now. |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3798 |
*/ |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3799 |
dsl_register_onexit_hold_cleanup(ds, htag, minor); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3800 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3801 |
dsl_dataset_rele(ds, ha->dstg); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3802 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3803 |
|
10268
cb380b2e9410
6868130 ZFS hold/release "zfs hold -r tag snapshot" failed to check the existence of snapshot
Chris Kirby <chris.kirby@sun.com>
parents:
10242
diff
changeset
|
3804 |
if (error == 0 && recursive && !ha->gotone) |
cb380b2e9410
6868130 ZFS hold/release "zfs hold -r tag snapshot" failed to check the existence of snapshot
Chris Kirby <chris.kirby@sun.com>
parents:
10242
diff
changeset
|
3805 |
error = ENOENT; |
cb380b2e9410
6868130 ZFS hold/release "zfs hold -r tag snapshot" failed to check the existence of snapshot
Chris Kirby <chris.kirby@sun.com>
parents:
10242
diff
changeset
|
3806 |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3807 |
if (error) |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
3808 |
(void) strlcpy(dsname, ha->failed, sizeof (ha->failed)); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3809 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3810 |
dsl_sync_task_group_destroy(ha->dstg); |
12527
693dd2cad55f
6884007 zfs_send() can leave temporary holds around
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12470
diff
changeset
|
3811 |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3812 |
kmem_free(ha, sizeof (struct dsl_ds_holdarg)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3813 |
spa_close(spa, FTAG); |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3814 |
if (cleanup_fd != -1) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
3815 |
zfs_onexit_fd_rele(cleanup_fd); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3816 |
return (error); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3817 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3818 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3819 |
struct dsl_ds_releasearg { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3820 |
dsl_dataset_t *ds; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3821 |
const char *htag; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3822 |
boolean_t own; /* do we own or just hold ds? */ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3823 |
}; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3824 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3825 |
static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3826 |
dsl_dataset_release_might_destroy(dsl_dataset_t *ds, const char *htag, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3827 |
boolean_t *might_destroy) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3828 |
{ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3829 |
objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3830 |
uint64_t zapobj; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3831 |
uint64_t tmp; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3832 |
int error; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3833 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3834 |
*might_destroy = B_FALSE; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3835 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3836 |
mutex_enter(&ds->ds_lock); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3837 |
zapobj = ds->ds_phys->ds_userrefs_obj; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3838 |
if (zapobj == 0) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3839 |
/* The tag can't possibly exist */ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3840 |
mutex_exit(&ds->ds_lock); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3841 |
return (ESRCH); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3842 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3843 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3844 |
/* Make sure the tag exists */ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3845 |
error = zap_lookup(mos, zapobj, htag, 8, 1, &tmp); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3846 |
if (error) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3847 |
mutex_exit(&ds->ds_lock); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3848 |
if (error == ENOENT) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3849 |
error = ESRCH; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3850 |
return (error); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3851 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3852 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3853 |
if (ds->ds_userrefs == 1 && ds->ds_phys->ds_num_children == 1 && |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3854 |
DS_IS_DEFER_DESTROY(ds)) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3855 |
*might_destroy = B_TRUE; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3856 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3857 |
mutex_exit(&ds->ds_lock); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3858 |
return (0); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3859 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3860 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3861 |
static int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3862 |
dsl_dataset_user_release_check(void *arg1, void *tag, dmu_tx_t *tx) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3863 |
{ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3864 |
struct dsl_ds_releasearg *ra = arg1; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3865 |
dsl_dataset_t *ds = ra->ds; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3866 |
boolean_t might_destroy; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3867 |
int error; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3868 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3869 |
if (spa_version(ds->ds_dir->dd_pool->dp_spa) < SPA_VERSION_USERREFS) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3870 |
return (ENOTSUP); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3871 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3872 |
error = dsl_dataset_release_might_destroy(ds, ra->htag, &might_destroy); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3873 |
if (error) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3874 |
return (error); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3875 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3876 |
if (might_destroy) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3877 |
struct dsl_ds_destroyarg dsda = {0}; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3878 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3879 |
if (dmu_tx_is_syncing(tx)) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3880 |
/* |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3881 |
* If we're not prepared to remove the snapshot, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3882 |
* we can't allow the release to happen right now. |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3883 |
*/ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3884 |
if (!ra->own) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3885 |
return (EBUSY); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3886 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3887 |
dsda.ds = ds; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3888 |
dsda.releasing = B_TRUE; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3889 |
return (dsl_dataset_destroy_check(&dsda, tag, tx)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3890 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3891 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3892 |
return (0); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3893 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3894 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3895 |
static void |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3896 |
dsl_dataset_user_release_sync(void *arg1, void *tag, dmu_tx_t *tx) |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3897 |
{ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3898 |
struct dsl_ds_releasearg *ra = arg1; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3899 |
dsl_dataset_t *ds = ra->ds; |
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3900 |
dsl_pool_t *dp = ds->ds_dir->dd_pool; |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3901 |
objset_t *mos = dp->dp_meta_objset; |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3902 |
uint64_t zapobj; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3903 |
uint64_t dsobj = ds->ds_object; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3904 |
uint64_t refs; |
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3905 |
int error; |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3906 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3907 |
mutex_enter(&ds->ds_lock); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3908 |
ds->ds_userrefs--; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3909 |
refs = ds->ds_userrefs; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3910 |
mutex_exit(&ds->ds_lock); |
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3911 |
error = dsl_pool_user_release(dp, ds->ds_object, ra->htag, tx); |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
3912 |
VERIFY(error == 0 || error == ENOENT); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3913 |
zapobj = ds->ds_phys->ds_userrefs_obj; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3914 |
VERIFY(0 == zap_remove(mos, zapobj, ra->htag, tx)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3915 |
if (ds->ds_userrefs == 0 && ds->ds_phys->ds_num_children == 1 && |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3916 |
DS_IS_DEFER_DESTROY(ds)) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3917 |
struct dsl_ds_destroyarg dsda = {0}; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3918 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3919 |
ASSERT(ra->own); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3920 |
dsda.ds = ds; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3921 |
dsda.releasing = B_TRUE; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3922 |
/* We already did the destroy_check */ |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3923 |
dsl_dataset_destroy_sync(&dsda, tag, tx); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3924 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3925 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3926 |
spa_history_log_internal(LOG_DS_USER_RELEASE, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
12295
diff
changeset
|
3927 |
dp->dp_spa, tx, "<%s> %lld dataset = %llu", |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3928 |
ra->htag, (longlong_t)refs, dsobj); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3929 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3930 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3931 |
static int |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
3932 |
dsl_dataset_user_release_one(const char *dsname, void *arg) |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3933 |
{ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3934 |
struct dsl_ds_holdarg *ha = arg; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3935 |
struct dsl_ds_releasearg *ra; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3936 |
dsl_dataset_t *ds; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3937 |
int error; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3938 |
void *dtag = ha->dstg; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3939 |
char *name; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3940 |
boolean_t own = B_FALSE; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3941 |
boolean_t might_destroy; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3942 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3943 |
/* alloc a buffer to hold dsname@snapname, plus the terminating NULL */ |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3944 |
name = kmem_asprintf("%s@%s", dsname, ha->snapname); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3945 |
error = dsl_dataset_hold(name, dtag, &ds); |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10268
diff
changeset
|
3946 |
strfree(name); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3947 |
if (error == ENOENT && ha->recursive) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3948 |
return (0); |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
3949 |
(void) strlcpy(ha->failed, dsname, sizeof (ha->failed)); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3950 |
if (error) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3951 |
return (error); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3952 |
|
10268
cb380b2e9410
6868130 ZFS hold/release "zfs hold -r tag snapshot" failed to check the existence of snapshot
Chris Kirby <chris.kirby@sun.com>
parents:
10242
diff
changeset
|
3953 |
ha->gotone = B_TRUE; |
cb380b2e9410
6868130 ZFS hold/release "zfs hold -r tag snapshot" failed to check the existence of snapshot
Chris Kirby <chris.kirby@sun.com>
parents:
10242
diff
changeset
|
3954 |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3955 |
ASSERT(dsl_dataset_is_snapshot(ds)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3956 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3957 |
error = dsl_dataset_release_might_destroy(ds, ha->htag, &might_destroy); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3958 |
if (error) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3959 |
dsl_dataset_rele(ds, dtag); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3960 |
return (error); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3961 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3962 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3963 |
if (might_destroy) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3964 |
#ifdef _KERNEL |
12115
3655f38d3bea
6942295 use-after-free panic in dsl_dataset_user_release_one
Chris Kirby <Chris.Kirby@oracle.com>
parents:
11823
diff
changeset
|
3965 |
name = kmem_asprintf("%s@%s", dsname, ha->snapname); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3966 |
error = zfs_unmount_snap(name, NULL); |
12115
3655f38d3bea
6942295 use-after-free panic in dsl_dataset_user_release_one
Chris Kirby <Chris.Kirby@oracle.com>
parents:
11823
diff
changeset
|
3967 |
strfree(name); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3968 |
if (error) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3969 |
dsl_dataset_rele(ds, dtag); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3970 |
return (error); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3971 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3972 |
#endif |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
3973 |
if (!dsl_dataset_tryown(ds, B_TRUE, dtag)) { |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3974 |
dsl_dataset_rele(ds, dtag); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3975 |
return (EBUSY); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3976 |
} else { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3977 |
own = B_TRUE; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3978 |
dsl_dataset_make_exclusive(ds, dtag); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3979 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3980 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3981 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3982 |
ra = kmem_alloc(sizeof (struct dsl_ds_releasearg), KM_SLEEP); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3983 |
ra->ds = ds; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3984 |
ra->htag = ha->htag; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3985 |
ra->own = own; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3986 |
dsl_sync_task_create(ha->dstg, dsl_dataset_user_release_check, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3987 |
dsl_dataset_user_release_sync, ra, dtag, 0); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3988 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3989 |
return (0); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3990 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3991 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3992 |
int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3993 |
dsl_dataset_user_release(char *dsname, char *snapname, char *htag, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3994 |
boolean_t recursive) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3995 |
{ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3996 |
struct dsl_ds_holdarg *ha; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3997 |
dsl_sync_task_t *dst; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3998 |
spa_t *spa; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
3999 |
int error; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4000 |
|
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
4001 |
top: |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4002 |
ha = kmem_zalloc(sizeof (struct dsl_ds_holdarg), KM_SLEEP); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4003 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4004 |
(void) strlcpy(ha->failed, dsname, sizeof (ha->failed)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4005 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4006 |
error = spa_open(dsname, &spa, FTAG); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4007 |
if (error) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4008 |
kmem_free(ha, sizeof (struct dsl_ds_holdarg)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4009 |
return (error); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4010 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4011 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4012 |
ha->dstg = dsl_sync_task_group_create(spa_get_dsl(spa)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4013 |
ha->htag = htag; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4014 |
ha->snapname = snapname; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4015 |
ha->recursive = recursive; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4016 |
if (recursive) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4017 |
error = dmu_objset_find(dsname, dsl_dataset_user_release_one, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4018 |
ha, DS_FIND_CHILDREN); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4019 |
} else { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4020 |
error = dsl_dataset_user_release_one(dsname, ha); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4021 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4022 |
if (error == 0) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4023 |
error = dsl_sync_task_group_wait(ha->dstg); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4024 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4025 |
for (dst = list_head(&ha->dstg->dstg_tasks); dst; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4026 |
dst = list_next(&ha->dstg->dstg_tasks, dst)) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4027 |
struct dsl_ds_releasearg *ra = dst->dst_arg1; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4028 |
dsl_dataset_t *ds = ra->ds; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4029 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4030 |
if (dst->dst_err) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4031 |
dsl_dataset_name(ds, ha->failed); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4032 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4033 |
if (ra->own) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4034 |
dsl_dataset_disown(ds, ha->dstg); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4035 |
else |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4036 |
dsl_dataset_rele(ds, ha->dstg); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4037 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4038 |
kmem_free(ra, sizeof (struct dsl_ds_releasearg)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4039 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4040 |
|
10268
cb380b2e9410
6868130 ZFS hold/release "zfs hold -r tag snapshot" failed to check the existence of snapshot
Chris Kirby <chris.kirby@sun.com>
parents:
10242
diff
changeset
|
4041 |
if (error == 0 && recursive && !ha->gotone) |
cb380b2e9410
6868130 ZFS hold/release "zfs hold -r tag snapshot" failed to check the existence of snapshot
Chris Kirby <chris.kirby@sun.com>
parents:
10242
diff
changeset
|
4042 |
error = ENOENT; |
cb380b2e9410
6868130 ZFS hold/release "zfs hold -r tag snapshot" failed to check the existence of snapshot
Chris Kirby <chris.kirby@sun.com>
parents:
10242
diff
changeset
|
4043 |
|
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
4044 |
if (error && error != EBUSY) |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
4045 |
(void) strlcpy(dsname, ha->failed, sizeof (ha->failed)); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4046 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4047 |
dsl_sync_task_group_destroy(ha->dstg); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4048 |
kmem_free(ha, sizeof (struct dsl_ds_holdarg)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4049 |
spa_close(spa, FTAG); |
11546
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
4050 |
|
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
4051 |
/* |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
4052 |
* We can get EBUSY if we were racing with deferred destroy and |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
4053 |
* dsl_dataset_user_release_check() hadn't done the necessary |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
4054 |
* open context setup. We can also get EBUSY if we're racing |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
4055 |
* with destroy and that thread is the ds_owner. Either way |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
4056 |
* the busy condition should be transient, and we should retry |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
4057 |
* the release operation. |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
4058 |
*/ |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
4059 |
if (error == EBUSY) |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
4060 |
goto top; |
42ea6be8961b
6915111 zfs_iter_snapshots() can miss snapshots
Chris Kirby <Chris.Kirby@sun.com>
parents:
11209
diff
changeset
|
4061 |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4062 |
return (error); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4063 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4064 |
|
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
4065 |
/* |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4066 |
* Called at spa_load time (with retry == B_FALSE) to release a stale |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4067 |
* temporary user hold. Also called by the onexit code (with retry == B_TRUE). |
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
4068 |
*/ |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
4069 |
int |
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4070 |
dsl_dataset_user_release_tmp(dsl_pool_t *dp, uint64_t dsobj, char *htag, |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4071 |
boolean_t retry) |
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
4072 |
{ |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
4073 |
dsl_dataset_t *ds; |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
4074 |
char *snap; |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
4075 |
char *name; |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
4076 |
int namelen; |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
4077 |
int error; |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
4078 |
|
12798
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4079 |
do { |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4080 |
rw_enter(&dp->dp_config_rwlock, RW_READER); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4081 |
error = dsl_dataset_hold_obj(dp, dsobj, FTAG, &ds); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4082 |
rw_exit(&dp->dp_config_rwlock); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4083 |
if (error) |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4084 |
return (error); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4085 |
namelen = dsl_dataset_namelen(ds)+1; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4086 |
name = kmem_alloc(namelen, KM_SLEEP); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4087 |
dsl_dataset_name(ds, name); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4088 |
dsl_dataset_rele(ds, FTAG); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4089 |
|
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4090 |
snap = strchr(name, '@'); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4091 |
*snap = '\0'; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4092 |
++snap; |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4093 |
error = dsl_dataset_user_release(name, snap, htag, B_FALSE); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4094 |
kmem_free(name, namelen); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4095 |
|
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4096 |
/* |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4097 |
* The object can't have been destroyed because we have a hold, |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4098 |
* but it might have been renamed, resulting in ENOENT. Retry |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4099 |
* if we've been requested to do so. |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4100 |
* |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4101 |
* It would be nice if we could use the dsobj all the way |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4102 |
* through and avoid ENOENT entirely. But we might need to |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4103 |
* unmount the snapshot, and there's currently no way to lookup |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4104 |
* a vfsp using a ZFS object id. |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4105 |
*/ |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4106 |
} while ((error == ENOENT) && retry); |
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4107 |
|
f6c8601080b4
6938335 zfs send -R can still miss renamed snapshots
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12711
diff
changeset
|
4108 |
return (error); |
10342
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
4109 |
} |
108f0058f837
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Chris Kirby <chris.kirby@sun.com>
parents:
10298
diff
changeset
|
4110 |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4111 |
int |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4112 |
dsl_dataset_get_holds(const char *dsname, nvlist_t **nvp) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4113 |
{ |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4114 |
dsl_dataset_t *ds; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4115 |
int err; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4116 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4117 |
err = dsl_dataset_hold(dsname, FTAG, &ds); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4118 |
if (err) |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4119 |
return (err); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4120 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4121 |
VERIFY(0 == nvlist_alloc(nvp, NV_UNIQUE_NAME, KM_SLEEP)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4122 |
if (ds->ds_phys->ds_userrefs_obj != 0) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4123 |
zap_attribute_t *za; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4124 |
zap_cursor_t zc; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4125 |
|
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4126 |
za = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4127 |
for (zap_cursor_init(&zc, ds->ds_dir->dd_pool->dp_meta_objset, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4128 |
ds->ds_phys->ds_userrefs_obj); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4129 |
zap_cursor_retrieve(&zc, za) == 0; |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4130 |
zap_cursor_advance(&zc)) { |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4131 |
VERIFY(0 == nvlist_add_uint64(*nvp, za->za_name, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4132 |
za->za_first_integer)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4133 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4134 |
zap_cursor_fini(&zc); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4135 |
kmem_free(za, sizeof (zap_attribute_t)); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4136 |
} |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4137 |
dsl_dataset_rele(ds, FTAG); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4138 |
return (0); |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
4139 |
} |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4140 |
|
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4141 |
/* |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4142 |
* Note, this function is used as the callback for dmu_objset_find(). We |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4143 |
* always return 0 so that we will continue to find and process |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4144 |
* inconsistent datasets, even if we encounter an error trying to |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4145 |
* process one of them. |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4146 |
*/ |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4147 |
/* ARGSUSED */ |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4148 |
int |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
4149 |
dsl_destroy_inconsistent(const char *dsname, void *arg) |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4150 |
{ |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4151 |
dsl_dataset_t *ds; |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4152 |
|
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4153 |
if (dsl_dataset_own(dsname, B_TRUE, FTAG, &ds) == 0) { |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4154 |
if (DS_IS_INCONSISTENT(ds)) |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4155 |
(void) dsl_dataset_destroy(ds, FTAG, B_FALSE); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4156 |
else |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4157 |
dsl_dataset_disown(ds, FTAG); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4158 |
} |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4159 |
return (0); |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
4160 |
} |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4161 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4162 |
/* |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4163 |
* Return (in *usedp) the amount of space written in new that is not |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4164 |
* present in oldsnap. New may be a snapshot or the head. Old must be |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4165 |
* a snapshot before new, in new's filesystem (or its origin). If not then |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4166 |
* fail and return EINVAL. |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4167 |
* |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4168 |
* The written space is calculated by considering two components: First, we |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4169 |
* ignore any freed space, and calculate the written as new's used space |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4170 |
* minus old's used space. Next, we add in the amount of space that was freed |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4171 |
* between the two snapshots, thus reducing new's used space relative to old's. |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4172 |
* Specifically, this is the space that was born before old->ds_creation_txg, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4173 |
* and freed before new (ie. on new's deadlist or a previous deadlist). |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4174 |
* |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4175 |
* space freed [---------------------] |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4176 |
* snapshots ---O-------O--------O-------O------ |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4177 |
* oldsnap new |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4178 |
*/ |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4179 |
int |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4180 |
dsl_dataset_space_written(dsl_dataset_t *oldsnap, dsl_dataset_t *new, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4181 |
uint64_t *usedp, uint64_t *compp, uint64_t *uncompp) |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4182 |
{ |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4183 |
int err = 0; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4184 |
uint64_t snapobj; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4185 |
dsl_pool_t *dp = new->ds_dir->dd_pool; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4186 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4187 |
*usedp = 0; |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
4188 |
*usedp += new->ds_phys->ds_referenced_bytes; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
4189 |
*usedp -= oldsnap->ds_phys->ds_referenced_bytes; |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4190 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4191 |
*compp = 0; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4192 |
*compp += new->ds_phys->ds_compressed_bytes; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4193 |
*compp -= oldsnap->ds_phys->ds_compressed_bytes; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4194 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4195 |
*uncompp = 0; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4196 |
*uncompp += new->ds_phys->ds_uncompressed_bytes; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4197 |
*uncompp -= oldsnap->ds_phys->ds_uncompressed_bytes; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4198 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4199 |
rw_enter(&dp->dp_config_rwlock, RW_READER); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4200 |
snapobj = new->ds_object; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4201 |
while (snapobj != oldsnap->ds_object) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4202 |
dsl_dataset_t *snap; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4203 |
uint64_t used, comp, uncomp; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4204 |
|
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
4205 |
if (snapobj == new->ds_object) { |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
4206 |
snap = new; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
4207 |
} else { |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
4208 |
err = dsl_dataset_hold_obj(dp, snapobj, FTAG, &snap); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
4209 |
if (err != 0) |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
4210 |
break; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
4211 |
} |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4212 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4213 |
if (snap->ds_phys->ds_prev_snap_txg == |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4214 |
oldsnap->ds_phys->ds_creation_txg) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4215 |
/* |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4216 |
* The blocks in the deadlist can not be born after |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4217 |
* ds_prev_snap_txg, so get the whole deadlist space, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4218 |
* which is more efficient (especially for old-format |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4219 |
* deadlists). Unfortunately the deadlist code |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4220 |
* doesn't have enough information to make this |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4221 |
* optimization itself. |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4222 |
*/ |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4223 |
dsl_deadlist_space(&snap->ds_deadlist, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4224 |
&used, &comp, &uncomp); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4225 |
} else { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4226 |
dsl_deadlist_space_range(&snap->ds_deadlist, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4227 |
0, oldsnap->ds_phys->ds_creation_txg, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4228 |
&used, &comp, &uncomp); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4229 |
} |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4230 |
*usedp += used; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4231 |
*compp += comp; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4232 |
*uncompp += uncomp; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4233 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4234 |
/* |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4235 |
* If we get to the beginning of the chain of snapshots |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4236 |
* (ds_prev_snap_obj == 0) before oldsnap, then oldsnap |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4237 |
* was not a snapshot of/before new. |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4238 |
*/ |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4239 |
snapobj = snap->ds_phys->ds_prev_snap_obj; |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
4240 |
if (snap != new) |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13686
diff
changeset
|
4241 |
dsl_dataset_rele(snap, FTAG); |
13524
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4242 |
if (snapobj == 0) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4243 |
err = EINVAL; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4244 |
break; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4245 |
} |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4246 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4247 |
} |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4248 |
rw_exit(&dp->dp_config_rwlock); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4249 |
return (err); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4250 |
} |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4251 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4252 |
/* |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4253 |
* Return (in *usedp) the amount of space that will be reclaimed if firstsnap, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4254 |
* lastsnap, and all snapshots in between are deleted. |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4255 |
* |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4256 |
* blocks that would be freed [---------------------------] |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4257 |
* snapshots ---O-------O--------O-------O--------O |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4258 |
* firstsnap lastsnap |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4259 |
* |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4260 |
* This is the set of blocks that were born after the snap before firstsnap, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4261 |
* (birth > firstsnap->prev_snap_txg) and died before the snap after the |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4262 |
* last snap (ie, is on lastsnap->ds_next->ds_deadlist or an earlier deadlist). |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4263 |
* We calculate this by iterating over the relevant deadlists (from the snap |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4264 |
* after lastsnap, backward to the snap after firstsnap), summing up the |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4265 |
* space on the deadlist that was born after the snap before firstsnap. |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4266 |
*/ |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4267 |
int |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4268 |
dsl_dataset_space_wouldfree(dsl_dataset_t *firstsnap, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4269 |
dsl_dataset_t *lastsnap, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4270 |
uint64_t *usedp, uint64_t *compp, uint64_t *uncompp) |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4271 |
{ |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4272 |
int err = 0; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4273 |
uint64_t snapobj; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4274 |
dsl_pool_t *dp = firstsnap->ds_dir->dd_pool; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4275 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4276 |
ASSERT(dsl_dataset_is_snapshot(firstsnap)); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4277 |
ASSERT(dsl_dataset_is_snapshot(lastsnap)); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4278 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4279 |
/* |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4280 |
* Check that the snapshots are in the same dsl_dir, and firstsnap |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4281 |
* is before lastsnap. |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4282 |
*/ |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4283 |
if (firstsnap->ds_dir != lastsnap->ds_dir || |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4284 |
firstsnap->ds_phys->ds_creation_txg > |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4285 |
lastsnap->ds_phys->ds_creation_txg) |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4286 |
return (EINVAL); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4287 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4288 |
*usedp = *compp = *uncompp = 0; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4289 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4290 |
rw_enter(&dp->dp_config_rwlock, RW_READER); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4291 |
snapobj = lastsnap->ds_phys->ds_next_snap_obj; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4292 |
while (snapobj != firstsnap->ds_object) { |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4293 |
dsl_dataset_t *ds; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4294 |
uint64_t used, comp, uncomp; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4295 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4296 |
err = dsl_dataset_hold_obj(dp, snapobj, FTAG, &ds); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4297 |
if (err != 0) |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4298 |
break; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4299 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4300 |
dsl_deadlist_space_range(&ds->ds_deadlist, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4301 |
firstsnap->ds_phys->ds_prev_snap_txg, UINT64_MAX, |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4302 |
&used, &comp, &uncomp); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4303 |
*usedp += used; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4304 |
*compp += comp; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4305 |
*uncompp += uncomp; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4306 |
|
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4307 |
snapobj = ds->ds_phys->ds_prev_snap_obj; |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4308 |
ASSERT3U(snapobj, !=, 0); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4309 |
dsl_dataset_rele(ds, FTAG); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4310 |
} |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4311 |
rw_exit(&dp->dp_config_rwlock); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4312 |
return (err); |
f0e12b33f77c
1644 add ZFS "clones" property
Matthew Ahrens <matt@delphix.com>
parents:
13512
diff
changeset
|
4313 |
} |