author | Jeff Bonwick <Jeff.Bonwick@Sun.COM> |
Sun, 01 Nov 2009 14:14:46 -0800 | |
changeset 10922 | e2081f502306 |
parent 10819 | d41e0e73a69e |
child 11007 | 216d8396182e |
permissions | -rw-r--r-- |
2743 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
5 |
* Common Development and Distribution License (the "License"). |
|
6 |
* You may not use this file except in compliance with the License. |
|
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 |
/* |
|
8644
10534c530688
6793373 assertion failed in dnode_reallocate: dn_nblkptr >= old_nblkptr
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
7994
diff
changeset
|
22 |
* Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
2743 | 23 |
* Use is subject to license terms. |
24 |
*/ |
|
25 |
||
26 |
#include <sys/dmu.h> |
|
27 |
#include <sys/dmu_impl.h> |
|
28 |
#include <sys/dmu_tx.h> |
|
29 |
#include <sys/dbuf.h> |
|
30 |
#include <sys/dnode.h> |
|
31 |
#include <sys/zfs_context.h> |
|
32 |
#include <sys/dmu_objset.h> |
|
33 |
#include <sys/dmu_traverse.h> |
|
34 |
#include <sys/dsl_dataset.h> |
|
35 |
#include <sys/dsl_dir.h> |
|
36 |
#include <sys/dsl_pool.h> |
|
37 |
#include <sys/dsl_synctask.h> |
|
38 |
#include <sys/zfs_ioctl.h> |
|
39 |
#include <sys/zap.h> |
|
40 |
#include <sys/zio_checksum.h> |
|
41 |
||
5367 | 42 |
static char *dmu_recv_tag = "dmu_recv_tag"; |
43 |
||
2743 | 44 |
struct backuparg { |
45 |
dmu_replay_record_t *drr; |
|
46 |
vnode_t *vp; |
|
5367 | 47 |
offset_t *off; |
2743 | 48 |
objset_t *os; |
49 |
zio_cksum_t zc; |
|
50 |
int err; |
|
51 |
}; |
|
52 |
||
53 |
static int |
|
54 |
dump_bytes(struct backuparg *ba, void *buf, int len) |
|
55 |
{ |
|
56 |
ssize_t resid; /* have to get resid to get detailed errno */ |
|
57 |
ASSERT3U(len % 8, ==, 0); |
|
58 |
||
59 |
fletcher_4_incremental_native(buf, len, &ba->zc); |
|
60 |
ba->err = vn_rdwr(UIO_WRITE, ba->vp, |
|
61 |
(caddr_t)buf, len, |
|
62 |
0, UIO_SYSSPACE, FAPPEND, RLIM64_INFINITY, CRED(), &resid); |
|
5367 | 63 |
*ba->off += len; |
2743 | 64 |
return (ba->err); |
65 |
} |
|
66 |
||
67 |
static int |
|
68 |
dump_free(struct backuparg *ba, uint64_t object, uint64_t offset, |
|
69 |
uint64_t length) |
|
70 |
{ |
|
71 |
/* write a FREE record */ |
|
72 |
bzero(ba->drr, sizeof (dmu_replay_record_t)); |
|
73 |
ba->drr->drr_type = DRR_FREE; |
|
74 |
ba->drr->drr_u.drr_free.drr_object = object; |
|
75 |
ba->drr->drr_u.drr_free.drr_offset = offset; |
|
76 |
ba->drr->drr_u.drr_free.drr_length = length; |
|
77 |
||
78 |
if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t))) |
|
79 |
return (EINTR); |
|
80 |
return (0); |
|
81 |
} |
|
82 |
||
83 |
static int |
|
84 |
dump_data(struct backuparg *ba, dmu_object_type_t type, |
|
85 |
uint64_t object, uint64_t offset, int blksz, void *data) |
|
86 |
{ |
|
87 |
/* write a DATA record */ |
|
88 |
bzero(ba->drr, sizeof (dmu_replay_record_t)); |
|
89 |
ba->drr->drr_type = DRR_WRITE; |
|
90 |
ba->drr->drr_u.drr_write.drr_object = object; |
|
91 |
ba->drr->drr_u.drr_write.drr_type = type; |
|
92 |
ba->drr->drr_u.drr_write.drr_offset = offset; |
|
93 |
ba->drr->drr_u.drr_write.drr_length = blksz; |
|
94 |
||
95 |
if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t))) |
|
96 |
return (EINTR); |
|
97 |
if (dump_bytes(ba, data, blksz)) |
|
98 |
return (EINTR); |
|
99 |
return (0); |
|
100 |
} |
|
101 |
||
102 |
static int |
|
103 |
dump_freeobjects(struct backuparg *ba, uint64_t firstobj, uint64_t numobjs) |
|
104 |
{ |
|
105 |
/* write a FREEOBJECTS record */ |
|
106 |
bzero(ba->drr, sizeof (dmu_replay_record_t)); |
|
107 |
ba->drr->drr_type = DRR_FREEOBJECTS; |
|
108 |
ba->drr->drr_u.drr_freeobjects.drr_firstobj = firstobj; |
|
109 |
ba->drr->drr_u.drr_freeobjects.drr_numobjs = numobjs; |
|
110 |
||
111 |
if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t))) |
|
112 |
return (EINTR); |
|
113 |
return (0); |
|
114 |
} |
|
115 |
||
116 |
static int |
|
117 |
dump_dnode(struct backuparg *ba, uint64_t object, dnode_phys_t *dnp) |
|
118 |
{ |
|
119 |
if (dnp == NULL || dnp->dn_type == DMU_OT_NONE) |
|
120 |
return (dump_freeobjects(ba, object, 1)); |
|
121 |
||
122 |
/* write an OBJECT record */ |
|
123 |
bzero(ba->drr, sizeof (dmu_replay_record_t)); |
|
124 |
ba->drr->drr_type = DRR_OBJECT; |
|
125 |
ba->drr->drr_u.drr_object.drr_object = object; |
|
126 |
ba->drr->drr_u.drr_object.drr_type = dnp->dn_type; |
|
127 |
ba->drr->drr_u.drr_object.drr_bonustype = dnp->dn_bonustype; |
|
128 |
ba->drr->drr_u.drr_object.drr_blksz = |
|
129 |
dnp->dn_datablkszsec << SPA_MINBLOCKSHIFT; |
|
130 |
ba->drr->drr_u.drr_object.drr_bonuslen = dnp->dn_bonuslen; |
|
131 |
ba->drr->drr_u.drr_object.drr_checksum = dnp->dn_checksum; |
|
132 |
ba->drr->drr_u.drr_object.drr_compress = dnp->dn_compress; |
|
133 |
||
134 |
if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t))) |
|
135 |
return (EINTR); |
|
136 |
||
137 |
if (dump_bytes(ba, DN_BONUS(dnp), P2ROUNDUP(dnp->dn_bonuslen, 8))) |
|
138 |
return (EINTR); |
|
139 |
||
140 |
/* free anything past the end of the file */ |
|
141 |
if (dump_free(ba, object, (dnp->dn_maxblkid + 1) * |
|
142 |
(dnp->dn_datablkszsec << SPA_MINBLOCKSHIFT), -1ULL)) |
|
143 |
return (EINTR); |
|
144 |
if (ba->err) |
|
145 |
return (EINTR); |
|
146 |
return (0); |
|
147 |
} |
|
148 |
||
149 |
#define BP_SPAN(dnp, level) \ |
|
150 |
(((uint64_t)dnp->dn_datablkszsec) << (SPA_MINBLOCKSHIFT + \ |
|
151 |
(level) * (dnp->dn_indblkshift - SPA_BLKPTRSHIFT))) |
|
152 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10819
diff
changeset
|
153 |
/* ARGSUSED */ |
2743 | 154 |
static int |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10819
diff
changeset
|
155 |
backup_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10819
diff
changeset
|
156 |
const zbookmark_t *zb, const dnode_phys_t *dnp, void *arg) |
2743 | 157 |
{ |
158 |
struct backuparg *ba = arg; |
|
159 |
dmu_object_type_t type = bp ? BP_GET_TYPE(bp) : DMU_OT_NONE; |
|
160 |
int err = 0; |
|
161 |
||
162 |
if (issig(JUSTLOOKING) && issig(FORREAL)) |
|
163 |
return (EINTR); |
|
164 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10819
diff
changeset
|
165 |
if (zb->zb_object != DMU_META_DNODE_OBJECT && |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10819
diff
changeset
|
166 |
DMU_OBJECT_IS_SPECIAL(zb->zb_object)) { |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8986
diff
changeset
|
167 |
return (0); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10819
diff
changeset
|
168 |
} else if (bp == NULL && zb->zb_object == DMU_META_DNODE_OBJECT) { |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
169 |
uint64_t span = BP_SPAN(dnp, zb->zb_level); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
170 |
uint64_t dnobj = (zb->zb_blkid * span) >> DNODE_SHIFT; |
2743 | 171 |
err = dump_freeobjects(ba, dnobj, span >> DNODE_SHIFT); |
172 |
} else if (bp == NULL) { |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
173 |
uint64_t span = BP_SPAN(dnp, zb->zb_level); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
174 |
err = dump_free(ba, zb->zb_object, zb->zb_blkid * span, span); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
175 |
} else if (zb->zb_level > 0 || type == DMU_OT_OBJSET) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
176 |
return (0); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
177 |
} else if (type == DMU_OT_DNODE) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
178 |
dnode_phys_t *blk; |
2743 | 179 |
int i; |
180 |
int blksz = BP_GET_LSIZE(bp); |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
181 |
uint32_t aflags = ARC_WAIT; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
182 |
arc_buf_t *abuf; |
2743 | 183 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
184 |
if (arc_read_nolock(NULL, spa, bp, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
185 |
arc_getbuf_func, &abuf, ZIO_PRIORITY_ASYNC_READ, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
186 |
ZIO_FLAG_CANFAIL, &aflags, zb) != 0) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
187 |
return (EIO); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
188 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
189 |
blk = abuf->b_data; |
2743 | 190 |
for (i = 0; i < blksz >> DNODE_SHIFT; i++) { |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
191 |
uint64_t dnobj = (zb->zb_blkid << |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
192 |
(DNODE_BLOCK_SHIFT - DNODE_SHIFT)) + i; |
2743 | 193 |
err = dump_dnode(ba, dnobj, blk+i); |
194 |
if (err) |
|
195 |
break; |
|
196 |
} |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
197 |
(void) arc_buf_remove_ref(abuf, &abuf); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
198 |
} else { /* it's a level-0 block of a regular object */ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
199 |
uint32_t aflags = ARC_WAIT; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
200 |
arc_buf_t *abuf; |
2743 | 201 |
int blksz = BP_GET_LSIZE(bp); |
202 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
203 |
if (arc_read_nolock(NULL, spa, bp, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
204 |
arc_getbuf_func, &abuf, ZIO_PRIORITY_ASYNC_READ, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
205 |
ZIO_FLAG_CANFAIL, &aflags, zb) != 0) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
206 |
return (EIO); |
2743 | 207 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
208 |
err = dump_data(ba, type, zb->zb_object, zb->zb_blkid * blksz, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
209 |
blksz, abuf->b_data); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
210 |
(void) arc_buf_remove_ref(abuf, &abuf); |
2743 | 211 |
} |
212 |
||
213 |
ASSERT(err == 0 || err == EINTR); |
|
214 |
return (err); |
|
215 |
} |
|
216 |
||
217 |
int |
|
5367 | 218 |
dmu_sendbackup(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin, |
219 |
vnode_t *vp, offset_t *off) |
|
2743 | 220 |
{ |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
221 |
dsl_dataset_t *ds = tosnap->os_dsl_dataset; |
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
222 |
dsl_dataset_t *fromds = fromsnap ? fromsnap->os_dsl_dataset : NULL; |
2743 | 223 |
dmu_replay_record_t *drr; |
224 |
struct backuparg ba; |
|
225 |
int err; |
|
5367 | 226 |
uint64_t fromtxg = 0; |
2743 | 227 |
|
228 |
/* tosnap must be a snapshot */ |
|
229 |
if (ds->ds_phys->ds_next_snap_obj == 0) |
|
230 |
return (EINVAL); |
|
231 |
||
232 |
/* fromsnap must be an earlier snapshot from the same fs as tosnap */ |
|
233 |
if (fromds && (ds->ds_dir != fromds->ds_dir || |
|
5367 | 234 |
fromds->ds_phys->ds_creation_txg >= ds->ds_phys->ds_creation_txg)) |
2743 | 235 |
return (EXDEV); |
236 |
||
5367 | 237 |
if (fromorigin) { |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
238 |
dsl_pool_t *dp = ds->ds_dir->dd_pool; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
239 |
|
5367 | 240 |
if (fromsnap) |
241 |
return (EINVAL); |
|
242 |
||
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
243 |
if (dsl_dir_is_clone(ds->ds_dir)) { |
5367 | 244 |
rw_enter(&dp->dp_config_rwlock, RW_READER); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
245 |
err = dsl_dataset_hold_obj(dp, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
246 |
ds->ds_dir->dd_phys->dd_origin_obj, FTAG, &fromds); |
5367 | 247 |
rw_exit(&dp->dp_config_rwlock); |
248 |
if (err) |
|
249 |
return (err); |
|
250 |
} else { |
|
251 |
fromorigin = B_FALSE; |
|
252 |
} |
|
253 |
} |
|
254 |
||
255 |
||
2743 | 256 |
drr = kmem_zalloc(sizeof (dmu_replay_record_t), KM_SLEEP); |
257 |
drr->drr_type = DRR_BEGIN; |
|
258 |
drr->drr_u.drr_begin.drr_magic = DMU_BACKUP_MAGIC; |
|
5367 | 259 |
drr->drr_u.drr_begin.drr_version = DMU_BACKUP_STREAM_VERSION; |
2743 | 260 |
drr->drr_u.drr_begin.drr_creation_time = |
261 |
ds->ds_phys->ds_creation_time; |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
262 |
drr->drr_u.drr_begin.drr_type = tosnap->os_phys->os_type; |
5367 | 263 |
if (fromorigin) |
264 |
drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_CLONE; |
|
2743 | 265 |
drr->drr_u.drr_begin.drr_toguid = ds->ds_phys->ds_guid; |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6479
diff
changeset
|
266 |
if (ds->ds_phys->ds_flags & DS_FLAG_CI_DATASET) |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6479
diff
changeset
|
267 |
drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_CI_DATA; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6479
diff
changeset
|
268 |
|
2743 | 269 |
if (fromds) |
270 |
drr->drr_u.drr_begin.drr_fromguid = fromds->ds_phys->ds_guid; |
|
271 |
dsl_dataset_name(ds, drr->drr_u.drr_begin.drr_toname); |
|
272 |
||
5367 | 273 |
if (fromds) |
274 |
fromtxg = fromds->ds_phys->ds_creation_txg; |
|
275 |
if (fromorigin) |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
276 |
dsl_dataset_rele(fromds, FTAG); |
5367 | 277 |
|
2743 | 278 |
ba.drr = drr; |
279 |
ba.vp = vp; |
|
280 |
ba.os = tosnap; |
|
5367 | 281 |
ba.off = off; |
2743 | 282 |
ZIO_SET_CHECKSUM(&ba.zc, 0, 0, 0, 0); |
283 |
||
284 |
if (dump_bytes(&ba, drr, sizeof (dmu_replay_record_t))) { |
|
285 |
kmem_free(drr, sizeof (dmu_replay_record_t)); |
|
286 |
return (ba.err); |
|
287 |
} |
|
288 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
289 |
err = traverse_dataset(ds, fromtxg, TRAVERSE_PRE | TRAVERSE_PREFETCH, |
2743 | 290 |
backup_cb, &ba); |
291 |
||
292 |
if (err) { |
|
293 |
if (err == EINTR && ba.err) |
|
294 |
err = ba.err; |
|
3655 | 295 |
kmem_free(drr, sizeof (dmu_replay_record_t)); |
2743 | 296 |
return (err); |
297 |
} |
|
298 |
||
299 |
bzero(drr, sizeof (dmu_replay_record_t)); |
|
300 |
drr->drr_type = DRR_END; |
|
301 |
drr->drr_u.drr_end.drr_checksum = ba.zc; |
|
302 |
||
3655 | 303 |
if (dump_bytes(&ba, drr, sizeof (dmu_replay_record_t))) { |
304 |
kmem_free(drr, sizeof (dmu_replay_record_t)); |
|
2743 | 305 |
return (ba.err); |
3655 | 306 |
} |
2743 | 307 |
|
308 |
kmem_free(drr, sizeof (dmu_replay_record_t)); |
|
309 |
||
310 |
return (0); |
|
311 |
} |
|
312 |
||
5367 | 313 |
struct recvbeginsyncarg { |
314 |
const char *tofs; |
|
315 |
const char *tosnap; |
|
316 |
dsl_dataset_t *origin; |
|
317 |
uint64_t fromguid; |
|
318 |
dmu_objset_type_t type; |
|
319 |
void *tag; |
|
320 |
boolean_t force; |
|
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6479
diff
changeset
|
321 |
uint64_t dsflags; |
5367 | 322 |
char clonelastname[MAXNAMELEN]; |
323 |
dsl_dataset_t *ds; /* the ds to recv into; returned from the syncfunc */ |
|
2743 | 324 |
}; |
325 |
||
5367 | 326 |
/* ARGSUSED */ |
2743 | 327 |
static int |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
328 |
recv_new_check(void *arg1, void *arg2, dmu_tx_t *tx) |
5367 | 329 |
{ |
330 |
dsl_dir_t *dd = arg1; |
|
331 |
struct recvbeginsyncarg *rbsa = arg2; |
|
332 |
objset_t *mos = dd->dd_pool->dp_meta_objset; |
|
333 |
uint64_t val; |
|
334 |
int err; |
|
335 |
||
336 |
err = zap_lookup(mos, dd->dd_phys->dd_child_dir_zapobj, |
|
337 |
strrchr(rbsa->tofs, '/') + 1, sizeof (uint64_t), 1, &val); |
|
338 |
||
339 |
if (err != ENOENT) |
|
340 |
return (err ? err : EEXIST); |
|
341 |
||
342 |
if (rbsa->origin) { |
|
343 |
/* make sure it's a snap in the same pool */ |
|
344 |
if (rbsa->origin->ds_dir->dd_pool != dd->dd_pool) |
|
345 |
return (EXDEV); |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
346 |
if (!dsl_dataset_is_snapshot(rbsa->origin)) |
5367 | 347 |
return (EINVAL); |
348 |
if (rbsa->origin->ds_phys->ds_guid != rbsa->fromguid) |
|
349 |
return (ENODEV); |
|
350 |
} |
|
351 |
||
352 |
return (0); |
|
353 |
} |
|
354 |
||
355 |
static void |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
356 |
recv_new_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) |
5367 | 357 |
{ |
358 |
dsl_dir_t *dd = arg1; |
|
359 |
struct recvbeginsyncarg *rbsa = arg2; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
360 |
uint64_t flags = DS_FLAG_INCONSISTENT | rbsa->dsflags; |
5367 | 361 |
uint64_t dsobj; |
362 |
||
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
363 |
/* Create and open new dataset. */ |
5367 | 364 |
dsobj = dsl_dataset_create_sync(dd, strrchr(rbsa->tofs, '/') + 1, |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6479
diff
changeset
|
365 |
rbsa->origin, flags, cr, tx); |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
366 |
VERIFY(0 == dsl_dataset_own_obj(dd->dd_pool, dsobj, |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
367 |
B_TRUE, dmu_recv_tag, &rbsa->ds)); |
5367 | 368 |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
369 |
if (rbsa->origin == NULL) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
370 |
(void) dmu_objset_create_impl(dd->dd_pool->dp_spa, |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
371 |
rbsa->ds, &rbsa->ds->ds_phys->ds_bp, rbsa->type, tx); |
5367 | 372 |
} |
373 |
||
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
374 |
spa_history_internal_log(LOG_DS_REPLAY_FULL_SYNC, |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
375 |
dd->dd_pool->dp_spa, tx, cr, "dataset = %lld", dsobj); |
5367 | 376 |
} |
377 |
||
378 |
/* ARGSUSED */ |
|
379 |
static int |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
380 |
recv_existing_check(void *arg1, void *arg2, dmu_tx_t *tx) |
5367 | 381 |
{ |
382 |
dsl_dataset_t *ds = arg1; |
|
383 |
struct recvbeginsyncarg *rbsa = arg2; |
|
2743 | 384 |
int err; |
385 |
uint64_t val; |
|
386 |
||
5367 | 387 |
/* must not have any changes since most recent snapshot */ |
388 |
if (!rbsa->force && dsl_dataset_modified_since_lastsnap(ds)) |
|
389 |
return (ETXTBSY); |
|
390 |
||
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
391 |
if (rbsa->fromguid) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
392 |
/* if incremental, most recent snapshot must match fromguid */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
393 |
if (ds->ds_prev == NULL) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
394 |
return (ENODEV); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
395 |
if (ds->ds_prev->ds_phys->ds_guid != rbsa->fromguid) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
396 |
return (ENODEV); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
397 |
} else { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
398 |
/* if full, most recent snapshot must be $ORIGIN */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
399 |
if (ds->ds_phys->ds_prev_snap_txg >= TXG_INITIAL) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
400 |
return (ENODEV); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
401 |
} |
2743 | 402 |
|
6083
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5378
diff
changeset
|
403 |
/* temporary clone name must not exist */ |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5378
diff
changeset
|
404 |
err = zap_lookup(ds->ds_dir->dd_pool->dp_meta_objset, |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5378
diff
changeset
|
405 |
ds->ds_dir->dd_phys->dd_child_dir_zapobj, |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5378
diff
changeset
|
406 |
rbsa->clonelastname, 8, 1, &val); |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5378
diff
changeset
|
407 |
if (err == 0) |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5378
diff
changeset
|
408 |
return (EEXIST); |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5378
diff
changeset
|
409 |
if (err != ENOENT) |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5378
diff
changeset
|
410 |
return (err); |
23e77aa611b1
6655963 Panic: 0 == zap_add(mos, pds->dd_phys->dd_child_dir_zapobj, name, sizeof (uint64_t), 1, &ddobj, tx)
ek110237
parents:
5378
diff
changeset
|
411 |
|
2743 | 412 |
/* new snapshot name must not exist */ |
5367 | 413 |
err = zap_lookup(ds->ds_dir->dd_pool->dp_meta_objset, |
414 |
ds->ds_phys->ds_snapnames_zapobj, rbsa->tosnap, 8, 1, &val); |
|
415 |
if (err == 0) |
|
2743 | 416 |
return (EEXIST); |
417 |
if (err != ENOENT) |
|
5367 | 418 |
return (err); |
2743 | 419 |
return (0); |
420 |
} |
|
421 |
||
422 |
/* ARGSUSED */ |
|
5367 | 423 |
static void |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
424 |
recv_existing_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
425 |
{ |
5367 | 426 |
dsl_dataset_t *ohds = arg1; |
427 |
struct recvbeginsyncarg *rbsa = arg2; |
|
428 |
dsl_pool_t *dp = ohds->ds_dir->dd_pool; |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
429 |
dsl_dataset_t *cds; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
430 |
uint64_t flags = DS_FLAG_INCONSISTENT | rbsa->dsflags; |
5367 | 431 |
uint64_t dsobj; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
432 |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
433 |
/* create and open the temporary clone */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
434 |
dsobj = dsl_dataset_create_sync(ohds->ds_dir, rbsa->clonelastname, |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
435 |
ohds->ds_prev, flags, cr, tx); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
436 |
VERIFY(0 == dsl_dataset_own_obj(dp, dsobj, B_TRUE, dmu_recv_tag, &cds)); |
5367 | 437 |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
438 |
/* |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
439 |
* If we actually created a non-clone, we need to create the |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
440 |
* objset in our new dataset. |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
441 |
*/ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
442 |
if (BP_IS_HOLE(dsl_dataset_get_blkptr(cds))) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
443 |
(void) dmu_objset_create_impl(dp->dp_spa, |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
444 |
cds, dsl_dataset_get_blkptr(cds), rbsa->type, tx); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
445 |
} |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
446 |
|
5378
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
447 |
/* copy the refquota from the target fs to the clone */ |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
448 |
if (ohds->ds_quota > 0) |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
449 |
dsl_dataset_set_quota_sync(cds, &ohds->ds_quota, cr, tx); |
111aa1baa84a
PSARC 2007/555 zfs fs-only quotas and reservations
ck153898
parents:
5367
diff
changeset
|
450 |
|
5367 | 451 |
rbsa->ds = cds; |
452 |
||
453 |
spa_history_internal_log(LOG_DS_REPLAY_INC_SYNC, |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
454 |
dp->dp_spa, tx, cr, "dataset = %lld", dsobj); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
455 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
456 |
|
5367 | 457 |
/* |
458 |
* NB: callers *MUST* call dmu_recv_stream() if dmu_recv_begin() |
|
459 |
* succeeds; otherwise we will leak the holds on the datasets. |
|
460 |
*/ |
|
461 |
int |
|
462 |
dmu_recv_begin(char *tofs, char *tosnap, struct drr_begin *drrb, |
|
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
463 |
boolean_t force, objset_t *origin, dmu_recv_cookie_t *drc) |
2743 | 464 |
{ |
5367 | 465 |
int err = 0; |
466 |
boolean_t byteswap; |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
467 |
struct recvbeginsyncarg rbsa = { 0 }; |
5367 | 468 |
uint64_t version; |
469 |
int flags; |
|
470 |
dsl_dataset_t *ds; |
|
471 |
||
472 |
if (drrb->drr_magic == DMU_BACKUP_MAGIC) |
|
473 |
byteswap = FALSE; |
|
474 |
else if (drrb->drr_magic == BSWAP_64(DMU_BACKUP_MAGIC)) |
|
475 |
byteswap = TRUE; |
|
476 |
else |
|
477 |
return (EINVAL); |
|
478 |
||
479 |
rbsa.tofs = tofs; |
|
480 |
rbsa.tosnap = tosnap; |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
481 |
rbsa.origin = origin ? origin->os_dsl_dataset : NULL; |
5367 | 482 |
rbsa.fromguid = drrb->drr_fromguid; |
483 |
rbsa.type = drrb->drr_type; |
|
484 |
rbsa.tag = FTAG; |
|
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6479
diff
changeset
|
485 |
rbsa.dsflags = 0; |
5367 | 486 |
version = drrb->drr_version; |
487 |
flags = drrb->drr_flags; |
|
488 |
||
489 |
if (byteswap) { |
|
490 |
rbsa.type = BSWAP_32(rbsa.type); |
|
491 |
rbsa.fromguid = BSWAP_64(rbsa.fromguid); |
|
492 |
version = BSWAP_64(version); |
|
493 |
flags = BSWAP_32(flags); |
|
494 |
} |
|
495 |
||
496 |
if (version != DMU_BACKUP_STREAM_VERSION || |
|
497 |
rbsa.type >= DMU_OST_NUMTYPES || |
|
498 |
((flags & DRR_FLAG_CLONE) && origin == NULL)) |
|
499 |
return (EINVAL); |
|
500 |
||
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6479
diff
changeset
|
501 |
if (flags & DRR_FLAG_CI_DATA) |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6479
diff
changeset
|
502 |
rbsa.dsflags = DS_FLAG_CI_DATASET; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6479
diff
changeset
|
503 |
|
5367 | 504 |
bzero(drc, sizeof (dmu_recv_cookie_t)); |
505 |
drc->drc_drrb = drrb; |
|
506 |
drc->drc_tosnap = tosnap; |
|
507 |
drc->drc_force = force; |
|
508 |
||
509 |
/* |
|
510 |
* Process the begin in syncing context. |
|
511 |
*/ |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
512 |
|
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
513 |
/* open the dataset we are logically receiving into */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
514 |
err = dsl_dataset_hold(tofs, dmu_recv_tag, &ds); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
515 |
if (err == 0) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
516 |
/* target fs already exists; recv into temp clone */ |
5367 | 517 |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
518 |
/* Can't recv a clone into an existing fs */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
519 |
if (flags & DRR_FLAG_CLONE) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
520 |
dsl_dataset_rele(ds, dmu_recv_tag); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
521 |
return (EINVAL); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
522 |
} |
2743 | 523 |
|
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
524 |
/* must not have an incremental recv already in progress */ |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
525 |
if (!mutex_tryenter(&ds->ds_recvlock)) { |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
526 |
dsl_dataset_rele(ds, dmu_recv_tag); |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
527 |
return (EBUSY); |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
528 |
} |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
529 |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
530 |
/* tmp clone name is: tofs/%tosnap" */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
531 |
(void) snprintf(rbsa.clonelastname, sizeof (rbsa.clonelastname), |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
532 |
"%%%s", tosnap); |
5367 | 533 |
rbsa.force = force; |
534 |
err = dsl_sync_task_do(ds->ds_dir->dd_pool, |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
535 |
recv_existing_check, recv_existing_sync, ds, &rbsa, 5); |
5367 | 536 |
if (err) { |
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
537 |
mutex_exit(&ds->ds_recvlock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
538 |
dsl_dataset_rele(ds, dmu_recv_tag); |
5367 | 539 |
return (err); |
540 |
} |
|
541 |
drc->drc_logical_ds = ds; |
|
542 |
drc->drc_real_ds = rbsa.ds; |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
543 |
} else if (err == ENOENT) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
544 |
/* target fs does not exist; must be a full backup or clone */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
545 |
char *cp; |
5367 | 546 |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
547 |
/* |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
548 |
* If it's a non-clone incremental, we are missing the |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
549 |
* target fs, so fail the recv. |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
550 |
*/ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
551 |
if (rbsa.fromguid && !(flags & DRR_FLAG_CLONE)) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
552 |
return (ENOENT); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
553 |
|
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
554 |
/* Open the parent of tofs */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
555 |
cp = strrchr(tofs, '/'); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
556 |
*cp = '\0'; |
10819
d41e0e73a69e
6891564 7410C - zfs panic in recv_new_check()
Chris Kirby <Chris.Kirby@sun.com>
parents:
10298
diff
changeset
|
557 |
err = dsl_dataset_hold(tofs, FTAG, &ds); |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
558 |
*cp = '/'; |
5367 | 559 |
if (err) |
560 |
return (err); |
|
561 |
||
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
562 |
err = dsl_sync_task_do(ds->ds_dir->dd_pool, |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
563 |
recv_new_check, recv_new_sync, ds->ds_dir, &rbsa, 5); |
10819
d41e0e73a69e
6891564 7410C - zfs panic in recv_new_check()
Chris Kirby <Chris.Kirby@sun.com>
parents:
10298
diff
changeset
|
564 |
dsl_dataset_rele(ds, FTAG); |
5367 | 565 |
if (err) |
566 |
return (err); |
|
567 |
drc->drc_logical_ds = drc->drc_real_ds = rbsa.ds; |
|
568 |
drc->drc_newfs = B_TRUE; |
|
569 |
} |
|
570 |
||
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
571 |
return (err); |
2743 | 572 |
} |
573 |
||
5367 | 574 |
struct restorearg { |
575 |
int err; |
|
576 |
int byteswap; |
|
577 |
vnode_t *vp; |
|
578 |
char *buf; |
|
579 |
uint64_t voff; |
|
580 |
int bufsize; /* amount of memory allocated for buf */ |
|
581 |
zio_cksum_t cksum; |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
582 |
}; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
583 |
|
2743 | 584 |
static void * |
585 |
restore_read(struct restorearg *ra, int len) |
|
586 |
{ |
|
587 |
void *rv; |
|
5367 | 588 |
int done = 0; |
2743 | 589 |
|
590 |
/* some things will require 8-byte alignment, so everything must */ |
|
591 |
ASSERT3U(len % 8, ==, 0); |
|
592 |
||
5367 | 593 |
while (done < len) { |
2743 | 594 |
ssize_t resid; |
595 |
||
596 |
ra->err = vn_rdwr(UIO_READ, ra->vp, |
|
5367 | 597 |
(caddr_t)ra->buf + done, len - done, |
2743 | 598 |
ra->voff, UIO_SYSSPACE, FAPPEND, |
599 |
RLIM64_INFINITY, CRED(), &resid); |
|
600 |
||
5367 | 601 |
if (resid == len - done) |
2743 | 602 |
ra->err = EINVAL; |
5367 | 603 |
ra->voff += len - done - resid; |
604 |
done = len - resid; |
|
2743 | 605 |
if (ra->err) |
606 |
return (NULL); |
|
607 |
} |
|
608 |
||
5367 | 609 |
ASSERT3U(done, ==, len); |
610 |
rv = ra->buf; |
|
2743 | 611 |
if (ra->byteswap) |
5367 | 612 |
fletcher_4_incremental_byteswap(rv, len, &ra->cksum); |
2743 | 613 |
else |
5367 | 614 |
fletcher_4_incremental_native(rv, len, &ra->cksum); |
2743 | 615 |
return (rv); |
616 |
} |
|
617 |
||
618 |
static void |
|
619 |
backup_byteswap(dmu_replay_record_t *drr) |
|
620 |
{ |
|
621 |
#define DO64(X) (drr->drr_u.X = BSWAP_64(drr->drr_u.X)) |
|
622 |
#define DO32(X) (drr->drr_u.X = BSWAP_32(drr->drr_u.X)) |
|
623 |
drr->drr_type = BSWAP_32(drr->drr_type); |
|
5367 | 624 |
drr->drr_payloadlen = BSWAP_32(drr->drr_payloadlen); |
2743 | 625 |
switch (drr->drr_type) { |
626 |
case DRR_BEGIN: |
|
627 |
DO64(drr_begin.drr_magic); |
|
628 |
DO64(drr_begin.drr_version); |
|
629 |
DO64(drr_begin.drr_creation_time); |
|
630 |
DO32(drr_begin.drr_type); |
|
5367 | 631 |
DO32(drr_begin.drr_flags); |
2743 | 632 |
DO64(drr_begin.drr_toguid); |
633 |
DO64(drr_begin.drr_fromguid); |
|
634 |
break; |
|
635 |
case DRR_OBJECT: |
|
636 |
DO64(drr_object.drr_object); |
|
637 |
/* DO64(drr_object.drr_allocation_txg); */ |
|
638 |
DO32(drr_object.drr_type); |
|
639 |
DO32(drr_object.drr_bonustype); |
|
640 |
DO32(drr_object.drr_blksz); |
|
641 |
DO32(drr_object.drr_bonuslen); |
|
642 |
break; |
|
643 |
case DRR_FREEOBJECTS: |
|
644 |
DO64(drr_freeobjects.drr_firstobj); |
|
645 |
DO64(drr_freeobjects.drr_numobjs); |
|
646 |
break; |
|
647 |
case DRR_WRITE: |
|
648 |
DO64(drr_write.drr_object); |
|
649 |
DO32(drr_write.drr_type); |
|
650 |
DO64(drr_write.drr_offset); |
|
651 |
DO64(drr_write.drr_length); |
|
652 |
break; |
|
653 |
case DRR_FREE: |
|
654 |
DO64(drr_free.drr_object); |
|
655 |
DO64(drr_free.drr_offset); |
|
656 |
DO64(drr_free.drr_length); |
|
657 |
break; |
|
658 |
case DRR_END: |
|
659 |
DO64(drr_end.drr_checksum.zc_word[0]); |
|
660 |
DO64(drr_end.drr_checksum.zc_word[1]); |
|
661 |
DO64(drr_end.drr_checksum.zc_word[2]); |
|
662 |
DO64(drr_end.drr_checksum.zc_word[3]); |
|
663 |
break; |
|
664 |
} |
|
665 |
#undef DO64 |
|
666 |
#undef DO32 |
|
667 |
} |
|
668 |
||
669 |
static int |
|
670 |
restore_object(struct restorearg *ra, objset_t *os, struct drr_object *drro) |
|
671 |
{ |
|
672 |
int err; |
|
673 |
dmu_tx_t *tx; |
|
7994
7a573dc88b73
6764159 restore_object() makes a call that can block while having a tx open but not yet committed
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
674 |
void *data = NULL; |
2743 | 675 |
|
676 |
if (drro->drr_type == DMU_OT_NONE || |
|
677 |
drro->drr_type >= DMU_OT_NUMTYPES || |
|
678 |
drro->drr_bonustype >= DMU_OT_NUMTYPES || |
|
679 |
drro->drr_checksum >= ZIO_CHECKSUM_FUNCTIONS || |
|
680 |
drro->drr_compress >= ZIO_COMPRESS_FUNCTIONS || |
|
681 |
P2PHASE(drro->drr_blksz, SPA_MINBLOCKSIZE) || |
|
682 |
drro->drr_blksz < SPA_MINBLOCKSIZE || |
|
683 |
drro->drr_blksz > SPA_MAXBLOCKSIZE || |
|
684 |
drro->drr_bonuslen > DN_MAX_BONUSLEN) { |
|
685 |
return (EINVAL); |
|
686 |
} |
|
687 |
||
8986
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
688 |
err = dmu_object_info(os, drro->drr_object, NULL); |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
689 |
|
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
690 |
if (err != 0 && err != ENOENT) |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
691 |
return (EINVAL); |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
692 |
|
7994
7a573dc88b73
6764159 restore_object() makes a call that can block while having a tx open but not yet committed
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
693 |
if (drro->drr_bonuslen) { |
7a573dc88b73
6764159 restore_object() makes a call that can block while having a tx open but not yet committed
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
694 |
data = restore_read(ra, P2ROUNDUP(drro->drr_bonuslen, 8)); |
7a573dc88b73
6764159 restore_object() makes a call that can block while having a tx open but not yet committed
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
695 |
if (ra->err) |
7a573dc88b73
6764159 restore_object() makes a call that can block while having a tx open but not yet committed
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
696 |
return (ra->err); |
7a573dc88b73
6764159 restore_object() makes a call that can block while having a tx open but not yet committed
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
697 |
} |
7a573dc88b73
6764159 restore_object() makes a call that can block while having a tx open but not yet committed
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
698 |
|
2743 | 699 |
if (err == ENOENT) { |
700 |
/* currently free, want to be allocated */ |
|
8986
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
701 |
tx = dmu_tx_create(os); |
2743 | 702 |
dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT); |
703 |
err = dmu_tx_assign(tx, TXG_WAIT); |
|
704 |
if (err) { |
|
705 |
dmu_tx_abort(tx); |
|
706 |
return (err); |
|
707 |
} |
|
708 |
err = dmu_object_claim(os, drro->drr_object, |
|
709 |
drro->drr_type, drro->drr_blksz, |
|
710 |
drro->drr_bonustype, drro->drr_bonuslen, tx); |
|
8986
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
711 |
dmu_tx_commit(tx); |
2743 | 712 |
} else { |
713 |
/* currently allocated, want to be allocated */ |
|
714 |
err = dmu_object_reclaim(os, drro->drr_object, |
|
715 |
drro->drr_type, drro->drr_blksz, |
|
8986
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
716 |
drro->drr_bonustype, drro->drr_bonuslen); |
2743 | 717 |
} |
8986
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
718 |
if (err) |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
719 |
return (EINVAL); |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
720 |
|
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
721 |
tx = dmu_tx_create(os); |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
722 |
dmu_tx_hold_bonus(tx, drro->drr_object); |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
723 |
err = dmu_tx_assign(tx, TXG_WAIT); |
2743 | 724 |
if (err) { |
8986
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
725 |
dmu_tx_abort(tx); |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
726 |
return (err); |
2743 | 727 |
} |
728 |
||
729 |
dmu_object_set_checksum(os, drro->drr_object, drro->drr_checksum, tx); |
|
730 |
dmu_object_set_compress(os, drro->drr_object, drro->drr_compress, tx); |
|
731 |
||
7994
7a573dc88b73
6764159 restore_object() makes a call that can block while having a tx open but not yet committed
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
732 |
if (data != NULL) { |
2743 | 733 |
dmu_buf_t *db; |
7994
7a573dc88b73
6764159 restore_object() makes a call that can block while having a tx open but not yet committed
Tim Haley <Tim.Haley@Sun.COM>
parents:
7837
diff
changeset
|
734 |
|
2743 | 735 |
VERIFY(0 == dmu_bonus_hold(os, drro->drr_object, FTAG, &db)); |
736 |
dmu_buf_will_dirty(db, tx); |
|
737 |
||
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4543
diff
changeset
|
738 |
ASSERT3U(db->db_size, >=, drro->drr_bonuslen); |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4543
diff
changeset
|
739 |
bcopy(data, db->db_data, drro->drr_bonuslen); |
2743 | 740 |
if (ra->byteswap) { |
741 |
dmu_ot[drro->drr_bonustype].ot_byteswap(db->db_data, |
|
742 |
drro->drr_bonuslen); |
|
743 |
} |
|
744 |
dmu_buf_rele(db, FTAG); |
|
745 |
} |
|
746 |
dmu_tx_commit(tx); |
|
747 |
return (0); |
|
748 |
} |
|
749 |
||
750 |
/* ARGSUSED */ |
|
751 |
static int |
|
752 |
restore_freeobjects(struct restorearg *ra, objset_t *os, |
|
753 |
struct drr_freeobjects *drrfo) |
|
754 |
{ |
|
755 |
uint64_t obj; |
|
756 |
||
757 |
if (drrfo->drr_firstobj + drrfo->drr_numobjs < drrfo->drr_firstobj) |
|
758 |
return (EINVAL); |
|
759 |
||
760 |
for (obj = drrfo->drr_firstobj; |
|
3087 | 761 |
obj < drrfo->drr_firstobj + drrfo->drr_numobjs; |
762 |
(void) dmu_object_next(os, &obj, FALSE, 0)) { |
|
2743 | 763 |
int err; |
764 |
||
765 |
if (dmu_object_info(os, obj, NULL) != 0) |
|
766 |
continue; |
|
767 |
||
6992 | 768 |
err = dmu_free_object(os, obj); |
769 |
if (err) |
|
2743 | 770 |
return (err); |
771 |
} |
|
772 |
return (0); |
|
773 |
} |
|
774 |
||
775 |
static int |
|
776 |
restore_write(struct restorearg *ra, objset_t *os, |
|
777 |
struct drr_write *drrw) |
|
778 |
{ |
|
779 |
dmu_tx_t *tx; |
|
780 |
void *data; |
|
781 |
int err; |
|
782 |
||
783 |
if (drrw->drr_offset + drrw->drr_length < drrw->drr_offset || |
|
784 |
drrw->drr_type >= DMU_OT_NUMTYPES) |
|
785 |
return (EINVAL); |
|
786 |
||
787 |
data = restore_read(ra, drrw->drr_length); |
|
788 |
if (data == NULL) |
|
789 |
return (ra->err); |
|
790 |
||
791 |
if (dmu_object_info(os, drrw->drr_object, NULL) != 0) |
|
792 |
return (EINVAL); |
|
793 |
||
794 |
tx = dmu_tx_create(os); |
|
795 |
||
796 |
dmu_tx_hold_write(tx, drrw->drr_object, |
|
797 |
drrw->drr_offset, drrw->drr_length); |
|
798 |
err = dmu_tx_assign(tx, TXG_WAIT); |
|
799 |
if (err) { |
|
800 |
dmu_tx_abort(tx); |
|
801 |
return (err); |
|
802 |
} |
|
803 |
if (ra->byteswap) |
|
804 |
dmu_ot[drrw->drr_type].ot_byteswap(data, drrw->drr_length); |
|
805 |
dmu_write(os, drrw->drr_object, |
|
806 |
drrw->drr_offset, drrw->drr_length, data, tx); |
|
807 |
dmu_tx_commit(tx); |
|
808 |
return (0); |
|
809 |
} |
|
810 |
||
811 |
/* ARGSUSED */ |
|
812 |
static int |
|
813 |
restore_free(struct restorearg *ra, objset_t *os, |
|
814 |
struct drr_free *drrf) |
|
815 |
{ |
|
816 |
int err; |
|
817 |
||
818 |
if (drrf->drr_length != -1ULL && |
|
819 |
drrf->drr_offset + drrf->drr_length < drrf->drr_offset) |
|
820 |
return (EINVAL); |
|
821 |
||
822 |
if (dmu_object_info(os, drrf->drr_object, NULL) != 0) |
|
823 |
return (EINVAL); |
|
824 |
||
6992 | 825 |
err = dmu_free_long_range(os, drrf->drr_object, |
2743 | 826 |
drrf->drr_offset, drrf->drr_length); |
827 |
return (err); |
|
828 |
} |
|
829 |
||
5367 | 830 |
/* |
831 |
* NB: callers *must* call dmu_recv_end() if this succeeds. |
|
832 |
*/ |
|
833 |
int |
|
834 |
dmu_recv_stream(dmu_recv_cookie_t *drc, vnode_t *vp, offset_t *voffp) |
|
835 |
{ |
|
836 |
struct restorearg ra = { 0 }; |
|
837 |
dmu_replay_record_t *drr; |
|
838 |
objset_t *os; |
|
839 |
zio_cksum_t pcksum; |
|
840 |
||
841 |
if (drc->drc_drrb->drr_magic == BSWAP_64(DMU_BACKUP_MAGIC)) |
|
842 |
ra.byteswap = TRUE; |
|
2743 | 843 |
|
5367 | 844 |
{ |
845 |
/* compute checksum of drr_begin record */ |
|
846 |
dmu_replay_record_t *drr; |
|
847 |
drr = kmem_zalloc(sizeof (dmu_replay_record_t), KM_SLEEP); |
|
848 |
||
849 |
drr->drr_type = DRR_BEGIN; |
|
850 |
drr->drr_u.drr_begin = *drc->drc_drrb; |
|
851 |
if (ra.byteswap) { |
|
852 |
fletcher_4_incremental_byteswap(drr, |
|
853 |
sizeof (dmu_replay_record_t), &ra.cksum); |
|
854 |
} else { |
|
855 |
fletcher_4_incremental_native(drr, |
|
856 |
sizeof (dmu_replay_record_t), &ra.cksum); |
|
857 |
} |
|
858 |
kmem_free(drr, sizeof (dmu_replay_record_t)); |
|
2743 | 859 |
} |
860 |
||
861 |
if (ra.byteswap) { |
|
5367 | 862 |
struct drr_begin *drrb = drc->drc_drrb; |
2743 | 863 |
drrb->drr_magic = BSWAP_64(drrb->drr_magic); |
864 |
drrb->drr_version = BSWAP_64(drrb->drr_version); |
|
865 |
drrb->drr_creation_time = BSWAP_64(drrb->drr_creation_time); |
|
866 |
drrb->drr_type = BSWAP_32(drrb->drr_type); |
|
867 |
drrb->drr_toguid = BSWAP_64(drrb->drr_toguid); |
|
868 |
drrb->drr_fromguid = BSWAP_64(drrb->drr_fromguid); |
|
869 |
} |
|
870 |
||
5367 | 871 |
ra.vp = vp; |
872 |
ra.voff = *voffp; |
|
873 |
ra.bufsize = 1<<20; |
|
874 |
ra.buf = kmem_alloc(ra.bufsize, KM_SLEEP); |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
875 |
|
5367 | 876 |
/* these were verified in dmu_recv_begin */ |
877 |
ASSERT(drc->drc_drrb->drr_version == DMU_BACKUP_STREAM_VERSION); |
|
878 |
ASSERT(drc->drc_drrb->drr_type < DMU_OST_NUMTYPES); |
|
2743 | 879 |
|
880 |
/* |
|
881 |
* Open the objset we are modifying. |
|
882 |
*/ |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
883 |
VERIFY(dmu_objset_from_ds(drc->drc_real_ds, &os) == 0); |
2743 | 884 |
|
5367 | 885 |
ASSERT(drc->drc_real_ds->ds_phys->ds_flags & DS_FLAG_INCONSISTENT); |
2743 | 886 |
|
887 |
/* |
|
888 |
* Read records and process them. |
|
889 |
*/ |
|
5367 | 890 |
pcksum = ra.cksum; |
2743 | 891 |
while (ra.err == 0 && |
892 |
NULL != (drr = restore_read(&ra, sizeof (*drr)))) { |
|
893 |
if (issig(JUSTLOOKING) && issig(FORREAL)) { |
|
894 |
ra.err = EINTR; |
|
895 |
goto out; |
|
896 |
} |
|
897 |
||
898 |
if (ra.byteswap) |
|
899 |
backup_byteswap(drr); |
|
900 |
||
901 |
switch (drr->drr_type) { |
|
902 |
case DRR_OBJECT: |
|
903 |
{ |
|
904 |
/* |
|
905 |
* We need to make a copy of the record header, |
|
906 |
* because restore_{object,write} may need to |
|
907 |
* restore_read(), which will invalidate drr. |
|
908 |
*/ |
|
909 |
struct drr_object drro = drr->drr_u.drr_object; |
|
910 |
ra.err = restore_object(&ra, os, &drro); |
|
911 |
break; |
|
912 |
} |
|
913 |
case DRR_FREEOBJECTS: |
|
914 |
{ |
|
915 |
struct drr_freeobjects drrfo = |
|
916 |
drr->drr_u.drr_freeobjects; |
|
917 |
ra.err = restore_freeobjects(&ra, os, &drrfo); |
|
918 |
break; |
|
919 |
} |
|
920 |
case DRR_WRITE: |
|
921 |
{ |
|
922 |
struct drr_write drrw = drr->drr_u.drr_write; |
|
923 |
ra.err = restore_write(&ra, os, &drrw); |
|
924 |
break; |
|
925 |
} |
|
926 |
case DRR_FREE: |
|
927 |
{ |
|
928 |
struct drr_free drrf = drr->drr_u.drr_free; |
|
929 |
ra.err = restore_free(&ra, os, &drrf); |
|
930 |
break; |
|
931 |
} |
|
932 |
case DRR_END: |
|
933 |
{ |
|
934 |
struct drr_end drre = drr->drr_u.drr_end; |
|
935 |
/* |
|
936 |
* We compare against the *previous* checksum |
|
937 |
* value, because the stored checksum is of |
|
938 |
* everything before the DRR_END record. |
|
939 |
*/ |
|
6479 | 940 |
if (!ZIO_CHECKSUM_EQUAL(drre.drr_checksum, pcksum)) |
2743 | 941 |
ra.err = ECKSUM; |
942 |
goto out; |
|
943 |
} |
|
944 |
default: |
|
945 |
ra.err = EINVAL; |
|
946 |
goto out; |
|
947 |
} |
|
5367 | 948 |
pcksum = ra.cksum; |
2743 | 949 |
} |
6479 | 950 |
ASSERT(ra.err != 0); |
2743 | 951 |
|
952 |
out: |
|
5367 | 953 |
if (ra.err != 0) { |
2743 | 954 |
/* |
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
955 |
* destroy what we created, so we don't leave it in the |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
956 |
* inconsistent restoring state. |
2743 | 957 |
*/ |
5367 | 958 |
txg_wait_synced(drc->drc_real_ds->ds_dir->dd_pool, 0); |
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
959 |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
960 |
(void) dsl_dataset_destroy(drc->drc_real_ds, dmu_recv_tag, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
961 |
B_FALSE); |
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
962 |
if (drc->drc_real_ds != drc->drc_logical_ds) { |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
963 |
mutex_exit(&drc->drc_logical_ds->ds_recvlock); |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
964 |
dsl_dataset_rele(drc->drc_logical_ds, dmu_recv_tag); |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
965 |
} |
2743 | 966 |
} |
967 |
||
968 |
kmem_free(ra.buf, ra.bufsize); |
|
5367 | 969 |
*voffp = ra.voff; |
2743 | 970 |
return (ra.err); |
971 |
} |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
972 |
|
5367 | 973 |
struct recvendsyncarg { |
974 |
char *tosnap; |
|
975 |
uint64_t creation_time; |
|
976 |
uint64_t toguid; |
|
977 |
}; |
|
978 |
||
979 |
static int |
|
980 |
recv_end_check(void *arg1, void *arg2, dmu_tx_t *tx) |
|
981 |
{ |
|
982 |
dsl_dataset_t *ds = arg1; |
|
983 |
struct recvendsyncarg *resa = arg2; |
|
984 |
||
985 |
return (dsl_dataset_snapshot_check(ds, resa->tosnap, tx)); |
|
986 |
} |
|
987 |
||
988 |
static void |
|
989 |
recv_end_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
990 |
{ |
5367 | 991 |
dsl_dataset_t *ds = arg1; |
992 |
struct recvendsyncarg *resa = arg2; |
|
993 |
||
994 |
dsl_dataset_snapshot_sync(ds, resa->tosnap, cr, tx); |
|
995 |
||
996 |
/* set snapshot's creation time and guid */ |
|
997 |
dmu_buf_will_dirty(ds->ds_prev->ds_dbuf, tx); |
|
998 |
ds->ds_prev->ds_phys->ds_creation_time = resa->creation_time; |
|
999 |
ds->ds_prev->ds_phys->ds_guid = resa->toguid; |
|
1000 |
ds->ds_prev->ds_phys->ds_flags &= ~DS_FLAG_INCONSISTENT; |
|
1001 |
||
1002 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
|
1003 |
ds->ds_phys->ds_flags &= ~DS_FLAG_INCONSISTENT; |
|
1004 |
} |
|
1005 |
||
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1006 |
static int |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1007 |
dmu_recv_existing_end(dmu_recv_cookie_t *drc) |
5367 | 1008 |
{ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1009 |
struct recvendsyncarg resa; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1010 |
dsl_dataset_t *ds = drc->drc_logical_ds; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1011 |
int err; |
5367 | 1012 |
|
1013 |
/* |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1014 |
* XXX hack; seems the ds is still dirty and dsl_pool_zil_clean() |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1015 |
* expects it to have a ds_user_ptr (and zil), but clone_swap() |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1016 |
* can close it. |
5367 | 1017 |
*/ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1018 |
txg_wait_synced(ds->ds_dir->dd_pool, 0); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
1019 |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1020 |
if (dsl_dataset_tryown(ds, FALSE, dmu_recv_tag)) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1021 |
err = dsl_dataset_clone_swap(drc->drc_real_ds, ds, |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1022 |
drc->drc_force); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1023 |
if (err) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1024 |
goto out; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1025 |
} else { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1026 |
mutex_exit(&ds->ds_recvlock); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1027 |
dsl_dataset_rele(ds, dmu_recv_tag); |
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1028 |
(void) dsl_dataset_destroy(drc->drc_real_ds, dmu_recv_tag, |
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1029 |
B_FALSE); |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1030 |
return (EBUSY); |
5367 | 1031 |
} |
1032 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1033 |
resa.creation_time = drc->drc_drrb->drr_creation_time; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1034 |
resa.toguid = drc->drc_drrb->drr_toguid; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1035 |
resa.tosnap = drc->drc_tosnap; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1036 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1037 |
err = dsl_sync_task_do(ds->ds_dir->dd_pool, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1038 |
recv_end_check, recv_end_sync, ds, &resa, 3); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1039 |
if (err) { |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1040 |
/* swap back */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1041 |
(void) dsl_dataset_clone_swap(drc->drc_real_ds, ds, B_TRUE); |
5367 | 1042 |
} |
1043 |
||
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1044 |
out: |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1045 |
mutex_exit(&ds->ds_recvlock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1046 |
dsl_dataset_disown(ds, dmu_recv_tag); |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1047 |
(void) dsl_dataset_destroy(drc->drc_real_ds, dmu_recv_tag, B_FALSE); |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
1048 |
return (err); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
1049 |
} |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1050 |
|
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1051 |
static int |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1052 |
dmu_recv_new_end(dmu_recv_cookie_t *drc) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1053 |
{ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1054 |
struct recvendsyncarg resa; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1055 |
dsl_dataset_t *ds = drc->drc_logical_ds; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1056 |
int err; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1057 |
|
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1058 |
/* |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1059 |
* XXX hack; seems the ds is still dirty and dsl_pool_zil_clean() |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1060 |
* expects it to have a ds_user_ptr (and zil), but clone_swap() |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1061 |
* can close it. |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1062 |
*/ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1063 |
txg_wait_synced(ds->ds_dir->dd_pool, 0); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1064 |
|
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1065 |
resa.creation_time = drc->drc_drrb->drr_creation_time; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1066 |
resa.toguid = drc->drc_drrb->drr_toguid; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1067 |
resa.tosnap = drc->drc_tosnap; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1068 |
|
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1069 |
err = dsl_sync_task_do(ds->ds_dir->dd_pool, |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1070 |
recv_end_check, recv_end_sync, ds, &resa, 3); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1071 |
if (err) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1072 |
/* clean up the fs we just recv'd into */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1073 |
(void) dsl_dataset_destroy(ds, dmu_recv_tag, B_FALSE); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1074 |
} else { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1075 |
/* release the hold from dmu_recv_begin */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1076 |
dsl_dataset_disown(ds, dmu_recv_tag); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1077 |
} |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1078 |
return (err); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1079 |
} |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1080 |
|
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1081 |
int |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1082 |
dmu_recv_end(dmu_recv_cookie_t *drc) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1083 |
{ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1084 |
if (drc->drc_logical_ds != drc->drc_real_ds) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1085 |
return (dmu_recv_existing_end(drc)); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1086 |
else |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1087 |
return (dmu_recv_new_end(drc)); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1088 |
} |