author | Mark Shellenbaum <Mark.Shellenbaum@Sun.COM> |
Tue, 16 Mar 2010 09:43:38 -0600 | |
changeset 11935 | 538c866aaac6 |
parent 11381 | c77e4d2b2e75 |
child 12070 | 01261b276236 |
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 |
/* |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
22 |
* Copyright 2010 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> |
|
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
36 |
#include <sys/dsl_prop.h> |
2743 | 37 |
#include <sys/dsl_pool.h> |
38 |
#include <sys/dsl_synctask.h> |
|
39 |
#include <sys/zfs_ioctl.h> |
|
40 |
#include <sys/zap.h> |
|
41 |
#include <sys/zio_checksum.h> |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
42 |
#include <sys/avl.h> |
11381
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
43 |
#include <sys/ddt.h> |
2743 | 44 |
|
5367 | 45 |
static char *dmu_recv_tag = "dmu_recv_tag"; |
46 |
||
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
47 |
/* |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
48 |
* The list of data whose inclusion in a send stream can be pending from |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
49 |
* one call to backup_cb to another. Multiple calls to dump_free() and |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
50 |
* dump_freeobjects() can be aggregated into a single DRR_FREE or |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
51 |
* DRR_FREEOBJECTS replay record. |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
52 |
*/ |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
53 |
typedef enum { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
54 |
PENDING_NONE, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
55 |
PENDING_FREE, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
56 |
PENDING_FREEOBJECTS |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
57 |
} pendop_t; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
58 |
|
2743 | 59 |
struct backuparg { |
60 |
dmu_replay_record_t *drr; |
|
61 |
vnode_t *vp; |
|
5367 | 62 |
offset_t *off; |
2743 | 63 |
objset_t *os; |
64 |
zio_cksum_t zc; |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
65 |
uint64_t toguid; |
2743 | 66 |
int err; |
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
67 |
pendop_t pending_op; |
2743 | 68 |
}; |
69 |
||
70 |
static int |
|
71 |
dump_bytes(struct backuparg *ba, void *buf, int len) |
|
72 |
{ |
|
73 |
ssize_t resid; /* have to get resid to get detailed errno */ |
|
74 |
ASSERT3U(len % 8, ==, 0); |
|
75 |
||
76 |
fletcher_4_incremental_native(buf, len, &ba->zc); |
|
77 |
ba->err = vn_rdwr(UIO_WRITE, ba->vp, |
|
78 |
(caddr_t)buf, len, |
|
79 |
0, UIO_SYSSPACE, FAPPEND, RLIM64_INFINITY, CRED(), &resid); |
|
5367 | 80 |
*ba->off += len; |
2743 | 81 |
return (ba->err); |
82 |
} |
|
83 |
||
84 |
static int |
|
85 |
dump_free(struct backuparg *ba, uint64_t object, uint64_t offset, |
|
86 |
uint64_t length) |
|
87 |
{ |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
88 |
struct drr_free *drrf = &(ba->drr->drr_u.drr_free); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
89 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
90 |
/* |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
91 |
* If there is a pending op, but it's not PENDING_FREE, push it out, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
92 |
* since free block aggregation can only be done for blocks of the |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
93 |
* same type (i.e., DRR_FREE records can only be aggregated with |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
94 |
* other DRR_FREE records. DRR_FREEOBJECTS records can only be |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
95 |
* aggregated with other DRR_FREEOBJECTS records. |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
96 |
*/ |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
97 |
if (ba->pending_op != PENDING_NONE && ba->pending_op != PENDING_FREE) { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
98 |
if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t)) != 0) |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
99 |
return (EINTR); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
100 |
ba->pending_op = PENDING_NONE; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
101 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
102 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
103 |
if (ba->pending_op == PENDING_FREE) { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
104 |
/* |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
105 |
* There should never be a PENDING_FREE if length is -1 |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
106 |
* (because dump_dnode is the only place where this |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
107 |
* function is called with a -1, and only after flushing |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
108 |
* any pending record). |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
109 |
*/ |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
110 |
ASSERT(length != -1ULL); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
111 |
/* |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
112 |
* Check to see whether this free block can be aggregated |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
113 |
* with pending one. |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
114 |
*/ |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
115 |
if (drrf->drr_object == object && drrf->drr_offset + |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
116 |
drrf->drr_length == offset) { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
117 |
drrf->drr_length += length; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
118 |
return (0); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
119 |
} else { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
120 |
/* not a continuation. Push out pending record */ |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
121 |
if (dump_bytes(ba, ba->drr, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
122 |
sizeof (dmu_replay_record_t)) != 0) |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
123 |
return (EINTR); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
124 |
ba->pending_op = PENDING_NONE; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
125 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
126 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
127 |
/* create a FREE record and make it pending */ |
2743 | 128 |
bzero(ba->drr, sizeof (dmu_replay_record_t)); |
129 |
ba->drr->drr_type = DRR_FREE; |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
130 |
drrf->drr_object = object; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
131 |
drrf->drr_offset = offset; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
132 |
drrf->drr_length = length; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
133 |
drrf->drr_toguid = ba->toguid; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
134 |
if (length == -1ULL) { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
135 |
if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t)) != 0) |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
136 |
return (EINTR); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
137 |
} else { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
138 |
ba->pending_op = PENDING_FREE; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
139 |
} |
2743 | 140 |
|
141 |
return (0); |
|
142 |
} |
|
143 |
||
144 |
static int |
|
145 |
dump_data(struct backuparg *ba, dmu_object_type_t type, |
|
11381
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
146 |
uint64_t object, uint64_t offset, int blksz, const blkptr_t *bp, void *data) |
2743 | 147 |
{ |
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
148 |
struct drr_write *drrw = &(ba->drr->drr_u.drr_write); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
149 |
|
11381
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
150 |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
151 |
/* |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
152 |
* If there is any kind of pending aggregation (currently either |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
153 |
* a grouping of free objects or free blocks), push it out to |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
154 |
* the stream, since aggregation can't be done across operations |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
155 |
* of different types. |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
156 |
*/ |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
157 |
if (ba->pending_op != PENDING_NONE) { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
158 |
if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t)) != 0) |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
159 |
return (EINTR); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
160 |
ba->pending_op = PENDING_NONE; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
161 |
} |
2743 | 162 |
/* write a DATA record */ |
163 |
bzero(ba->drr, sizeof (dmu_replay_record_t)); |
|
164 |
ba->drr->drr_type = DRR_WRITE; |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
165 |
drrw->drr_object = object; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
166 |
drrw->drr_type = type; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
167 |
drrw->drr_offset = offset; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
168 |
drrw->drr_length = blksz; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
169 |
drrw->drr_toguid = ba->toguid; |
11381
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
170 |
drrw->drr_checksumtype = BP_GET_CHECKSUM(bp); |
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
171 |
if (zio_checksum_table[drrw->drr_checksumtype].ci_dedup) |
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
172 |
drrw->drr_checksumflags |= DRR_CHECKSUM_DEDUP; |
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
173 |
DDK_SET_LSIZE(&drrw->drr_key, BP_GET_LSIZE(bp)); |
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
174 |
DDK_SET_PSIZE(&drrw->drr_key, BP_GET_PSIZE(bp)); |
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
175 |
DDK_SET_COMPRESS(&drrw->drr_key, BP_GET_COMPRESS(bp)); |
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
176 |
drrw->drr_key.ddk_cksum = bp->blk_cksum; |
2743 | 177 |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
178 |
if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t)) != 0) |
2743 | 179 |
return (EINTR); |
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
180 |
if (dump_bytes(ba, data, blksz) != 0) |
2743 | 181 |
return (EINTR); |
182 |
return (0); |
|
183 |
} |
|
184 |
||
185 |
static int |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
186 |
dump_spill(struct backuparg *ba, uint64_t object, int blksz, void *data) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
187 |
{ |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
188 |
struct drr_spill *drrs = &(ba->drr->drr_u.drr_spill); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
189 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
190 |
if (ba->pending_op != PENDING_NONE) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
191 |
if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t)) != 0) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
192 |
return (EINTR); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
193 |
ba->pending_op = PENDING_NONE; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
194 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
195 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
196 |
/* write a SPILL record */ |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
197 |
bzero(ba->drr, sizeof (dmu_replay_record_t)); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
198 |
ba->drr->drr_type = DRR_SPILL; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
199 |
drrs->drr_object = object; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
200 |
drrs->drr_length = blksz; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
201 |
drrs->drr_toguid = ba->toguid; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
202 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
203 |
if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t))) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
204 |
return (EINTR); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
205 |
if (dump_bytes(ba, data, blksz)) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
206 |
return (EINTR); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
207 |
return (0); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
208 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
209 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
210 |
static int |
2743 | 211 |
dump_freeobjects(struct backuparg *ba, uint64_t firstobj, uint64_t numobjs) |
212 |
{ |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
213 |
struct drr_freeobjects *drrfo = &(ba->drr->drr_u.drr_freeobjects); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
214 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
215 |
/* |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
216 |
* If there is a pending op, but it's not PENDING_FREEOBJECTS, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
217 |
* push it out, since free block aggregation can only be done for |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
218 |
* blocks of the same type (i.e., DRR_FREE records can only be |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
219 |
* aggregated with other DRR_FREE records. DRR_FREEOBJECTS records |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
220 |
* can only be aggregated with other DRR_FREEOBJECTS records. |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
221 |
*/ |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
222 |
if (ba->pending_op != PENDING_NONE && |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
223 |
ba->pending_op != PENDING_FREEOBJECTS) { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
224 |
if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t)) != 0) |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
225 |
return (EINTR); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
226 |
ba->pending_op = PENDING_NONE; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
227 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
228 |
if (ba->pending_op == PENDING_FREEOBJECTS) { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
229 |
/* |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
230 |
* See whether this free object array can be aggregated |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
231 |
* with pending one |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
232 |
*/ |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
233 |
if (drrfo->drr_firstobj + drrfo->drr_numobjs == firstobj) { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
234 |
drrfo->drr_numobjs += numobjs; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
235 |
return (0); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
236 |
} else { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
237 |
/* can't be aggregated. Push out pending record */ |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
238 |
if (dump_bytes(ba, ba->drr, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
239 |
sizeof (dmu_replay_record_t)) != 0) |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
240 |
return (EINTR); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
241 |
ba->pending_op = PENDING_NONE; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
242 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
243 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
244 |
|
2743 | 245 |
/* write a FREEOBJECTS record */ |
246 |
bzero(ba->drr, sizeof (dmu_replay_record_t)); |
|
247 |
ba->drr->drr_type = DRR_FREEOBJECTS; |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
248 |
drrfo->drr_firstobj = firstobj; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
249 |
drrfo->drr_numobjs = numobjs; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
250 |
drrfo->drr_toguid = ba->toguid; |
2743 | 251 |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
252 |
ba->pending_op = PENDING_FREEOBJECTS; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
253 |
|
2743 | 254 |
return (0); |
255 |
} |
|
256 |
||
257 |
static int |
|
258 |
dump_dnode(struct backuparg *ba, uint64_t object, dnode_phys_t *dnp) |
|
259 |
{ |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
260 |
struct drr_object *drro = &(ba->drr->drr_u.drr_object); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
261 |
|
2743 | 262 |
if (dnp == NULL || dnp->dn_type == DMU_OT_NONE) |
263 |
return (dump_freeobjects(ba, object, 1)); |
|
264 |
||
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
265 |
if (ba->pending_op != PENDING_NONE) { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
266 |
if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t)) != 0) |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
267 |
return (EINTR); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
268 |
ba->pending_op = PENDING_NONE; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
269 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
270 |
|
2743 | 271 |
/* write an OBJECT record */ |
272 |
bzero(ba->drr, sizeof (dmu_replay_record_t)); |
|
273 |
ba->drr->drr_type = DRR_OBJECT; |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
274 |
drro->drr_object = object; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
275 |
drro->drr_type = dnp->dn_type; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
276 |
drro->drr_bonustype = dnp->dn_bonustype; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
277 |
drro->drr_blksz = dnp->dn_datablkszsec << SPA_MINBLOCKSHIFT; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
278 |
drro->drr_bonuslen = dnp->dn_bonuslen; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
279 |
drro->drr_checksumtype = dnp->dn_checksum; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
280 |
drro->drr_compress = dnp->dn_compress; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
281 |
drro->drr_toguid = ba->toguid; |
2743 | 282 |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
283 |
if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t)) != 0) |
2743 | 284 |
return (EINTR); |
285 |
||
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
286 |
if (dump_bytes(ba, DN_BONUS(dnp), P2ROUNDUP(dnp->dn_bonuslen, 8)) != 0) |
2743 | 287 |
return (EINTR); |
288 |
||
289 |
/* free anything past the end of the file */ |
|
290 |
if (dump_free(ba, object, (dnp->dn_maxblkid + 1) * |
|
291 |
(dnp->dn_datablkszsec << SPA_MINBLOCKSHIFT), -1ULL)) |
|
292 |
return (EINTR); |
|
293 |
if (ba->err) |
|
294 |
return (EINTR); |
|
295 |
return (0); |
|
296 |
} |
|
297 |
||
298 |
#define BP_SPAN(dnp, level) \ |
|
299 |
(((uint64_t)dnp->dn_datablkszsec) << (SPA_MINBLOCKSHIFT + \ |
|
300 |
(level) * (dnp->dn_indblkshift - SPA_BLKPTRSHIFT))) |
|
301 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10819
diff
changeset
|
302 |
/* ARGSUSED */ |
2743 | 303 |
static int |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10819
diff
changeset
|
304 |
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
|
305 |
const zbookmark_t *zb, const dnode_phys_t *dnp, void *arg) |
2743 | 306 |
{ |
307 |
struct backuparg *ba = arg; |
|
308 |
dmu_object_type_t type = bp ? BP_GET_TYPE(bp) : DMU_OT_NONE; |
|
309 |
int err = 0; |
|
310 |
||
311 |
if (issig(JUSTLOOKING) && issig(FORREAL)) |
|
312 |
return (EINTR); |
|
313 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10819
diff
changeset
|
314 |
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
|
315 |
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
|
316 |
return (0); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10819
diff
changeset
|
317 |
} 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
|
318 |
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
|
319 |
uint64_t dnobj = (zb->zb_blkid * span) >> DNODE_SHIFT; |
2743 | 320 |
err = dump_freeobjects(ba, dnobj, span >> DNODE_SHIFT); |
321 |
} 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
|
322 |
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
|
323 |
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
|
324 |
} 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
|
325 |
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
|
326 |
} 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
|
327 |
dnode_phys_t *blk; |
2743 | 328 |
int i; |
329 |
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
|
330 |
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
|
331 |
arc_buf_t *abuf; |
2743 | 332 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
333 |
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
|
334 |
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
|
335 |
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
|
336 |
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
|
337 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
338 |
blk = abuf->b_data; |
2743 | 339 |
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
|
340 |
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
|
341 |
(DNODE_BLOCK_SHIFT - DNODE_SHIFT)) + i; |
2743 | 342 |
err = dump_dnode(ba, dnobj, blk+i); |
343 |
if (err) |
|
344 |
break; |
|
345 |
} |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
346 |
(void) arc_buf_remove_ref(abuf, &abuf); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
347 |
} else if (type == DMU_OT_SA) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
348 |
uint32_t aflags = ARC_WAIT; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
349 |
arc_buf_t *abuf; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
350 |
int blksz = BP_GET_LSIZE(bp); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
351 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
352 |
if (arc_read_nolock(NULL, spa, bp, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
353 |
arc_getbuf_func, &abuf, ZIO_PRIORITY_ASYNC_READ, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
354 |
ZIO_FLAG_CANFAIL, &aflags, zb) != 0) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
355 |
return (EIO); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
356 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
357 |
err = dump_spill(ba, zb->zb_object, blksz, abuf->b_data); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
358 |
(void) arc_buf_remove_ref(abuf, &abuf); |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
359 |
} 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
|
360 |
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
|
361 |
arc_buf_t *abuf; |
2743 | 362 |
int blksz = BP_GET_LSIZE(bp); |
363 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
364 |
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
|
365 |
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
|
366 |
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
|
367 |
return (EIO); |
2743 | 368 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
369 |
err = dump_data(ba, type, zb->zb_object, zb->zb_blkid * blksz, |
11381
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
370 |
blksz, bp, abuf->b_data); |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
371 |
(void) arc_buf_remove_ref(abuf, &abuf); |
2743 | 372 |
} |
373 |
||
374 |
ASSERT(err == 0 || err == EINTR); |
|
375 |
return (err); |
|
376 |
} |
|
377 |
||
378 |
int |
|
5367 | 379 |
dmu_sendbackup(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin, |
380 |
vnode_t *vp, offset_t *off) |
|
2743 | 381 |
{ |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
382 |
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
|
383 |
dsl_dataset_t *fromds = fromsnap ? fromsnap->os_dsl_dataset : NULL; |
2743 | 384 |
dmu_replay_record_t *drr; |
385 |
struct backuparg ba; |
|
386 |
int err; |
|
5367 | 387 |
uint64_t fromtxg = 0; |
2743 | 388 |
|
389 |
/* tosnap must be a snapshot */ |
|
390 |
if (ds->ds_phys->ds_next_snap_obj == 0) |
|
391 |
return (EINVAL); |
|
392 |
||
393 |
/* fromsnap must be an earlier snapshot from the same fs as tosnap */ |
|
394 |
if (fromds && (ds->ds_dir != fromds->ds_dir || |
|
5367 | 395 |
fromds->ds_phys->ds_creation_txg >= ds->ds_phys->ds_creation_txg)) |
2743 | 396 |
return (EXDEV); |
397 |
||
5367 | 398 |
if (fromorigin) { |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
399 |
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
|
400 |
|
5367 | 401 |
if (fromsnap) |
402 |
return (EINVAL); |
|
403 |
||
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
404 |
if (dsl_dir_is_clone(ds->ds_dir)) { |
5367 | 405 |
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
|
406 |
err = dsl_dataset_hold_obj(dp, |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
407 |
ds->ds_dir->dd_phys->dd_origin_obj, FTAG, &fromds); |
5367 | 408 |
rw_exit(&dp->dp_config_rwlock); |
409 |
if (err) |
|
410 |
return (err); |
|
411 |
} else { |
|
412 |
fromorigin = B_FALSE; |
|
413 |
} |
|
414 |
} |
|
415 |
||
416 |
||
2743 | 417 |
drr = kmem_zalloc(sizeof (dmu_replay_record_t), KM_SLEEP); |
418 |
drr->drr_type = DRR_BEGIN; |
|
419 |
drr->drr_u.drr_begin.drr_magic = DMU_BACKUP_MAGIC; |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
420 |
DMU_SET_STREAM_HDRTYPE(drr->drr_u.drr_begin.drr_versioninfo, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
421 |
DMU_SUBSTREAM); |
2743 | 422 |
drr->drr_u.drr_begin.drr_creation_time = |
423 |
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
|
424 |
drr->drr_u.drr_begin.drr_type = tosnap->os_phys->os_type; |
5367 | 425 |
if (fromorigin) |
426 |
drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_CLONE; |
|
2743 | 427 |
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
|
428 |
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
|
429 |
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
|
430 |
|
2743 | 431 |
if (fromds) |
432 |
drr->drr_u.drr_begin.drr_fromguid = fromds->ds_phys->ds_guid; |
|
433 |
dsl_dataset_name(ds, drr->drr_u.drr_begin.drr_toname); |
|
434 |
||
5367 | 435 |
if (fromds) |
436 |
fromtxg = fromds->ds_phys->ds_creation_txg; |
|
437 |
if (fromorigin) |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
438 |
dsl_dataset_rele(fromds, FTAG); |
5367 | 439 |
|
2743 | 440 |
ba.drr = drr; |
441 |
ba.vp = vp; |
|
442 |
ba.os = tosnap; |
|
5367 | 443 |
ba.off = off; |
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
444 |
ba.toguid = ds->ds_phys->ds_guid; |
2743 | 445 |
ZIO_SET_CHECKSUM(&ba.zc, 0, 0, 0, 0); |
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
446 |
ba.pending_op = PENDING_NONE; |
2743 | 447 |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
448 |
if (dump_bytes(&ba, drr, sizeof (dmu_replay_record_t)) != 0) { |
2743 | 449 |
kmem_free(drr, sizeof (dmu_replay_record_t)); |
450 |
return (ba.err); |
|
451 |
} |
|
452 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
453 |
err = traverse_dataset(ds, fromtxg, TRAVERSE_PRE | TRAVERSE_PREFETCH, |
2743 | 454 |
backup_cb, &ba); |
455 |
||
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
456 |
if (ba.pending_op != PENDING_NONE) |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
457 |
if (dump_bytes(&ba, drr, sizeof (dmu_replay_record_t)) != 0) |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
458 |
err = EINTR; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
459 |
|
2743 | 460 |
if (err) { |
461 |
if (err == EINTR && ba.err) |
|
462 |
err = ba.err; |
|
3655 | 463 |
kmem_free(drr, sizeof (dmu_replay_record_t)); |
2743 | 464 |
return (err); |
465 |
} |
|
466 |
||
467 |
bzero(drr, sizeof (dmu_replay_record_t)); |
|
468 |
drr->drr_type = DRR_END; |
|
469 |
drr->drr_u.drr_end.drr_checksum = ba.zc; |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
470 |
drr->drr_u.drr_end.drr_toguid = ba.toguid; |
2743 | 471 |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
472 |
if (dump_bytes(&ba, drr, sizeof (dmu_replay_record_t)) != 0) { |
3655 | 473 |
kmem_free(drr, sizeof (dmu_replay_record_t)); |
2743 | 474 |
return (ba.err); |
3655 | 475 |
} |
2743 | 476 |
|
477 |
kmem_free(drr, sizeof (dmu_replay_record_t)); |
|
478 |
||
479 |
return (0); |
|
480 |
} |
|
481 |
||
5367 | 482 |
struct recvbeginsyncarg { |
483 |
const char *tofs; |
|
484 |
const char *tosnap; |
|
485 |
dsl_dataset_t *origin; |
|
486 |
uint64_t fromguid; |
|
487 |
dmu_objset_type_t type; |
|
488 |
void *tag; |
|
489 |
boolean_t force; |
|
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6479
diff
changeset
|
490 |
uint64_t dsflags; |
5367 | 491 |
char clonelastname[MAXNAMELEN]; |
492 |
dsl_dataset_t *ds; /* the ds to recv into; returned from the syncfunc */ |
|
2743 | 493 |
}; |
494 |
||
5367 | 495 |
/* ARGSUSED */ |
2743 | 496 |
static int |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
497 |
recv_new_check(void *arg1, void *arg2, dmu_tx_t *tx) |
5367 | 498 |
{ |
499 |
dsl_dir_t *dd = arg1; |
|
500 |
struct recvbeginsyncarg *rbsa = arg2; |
|
501 |
objset_t *mos = dd->dd_pool->dp_meta_objset; |
|
502 |
uint64_t val; |
|
503 |
int err; |
|
504 |
||
505 |
err = zap_lookup(mos, dd->dd_phys->dd_child_dir_zapobj, |
|
506 |
strrchr(rbsa->tofs, '/') + 1, sizeof (uint64_t), 1, &val); |
|
507 |
||
508 |
if (err != ENOENT) |
|
509 |
return (err ? err : EEXIST); |
|
510 |
||
511 |
if (rbsa->origin) { |
|
512 |
/* make sure it's a snap in the same pool */ |
|
513 |
if (rbsa->origin->ds_dir->dd_pool != dd->dd_pool) |
|
514 |
return (EXDEV); |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
515 |
if (!dsl_dataset_is_snapshot(rbsa->origin)) |
5367 | 516 |
return (EINVAL); |
517 |
if (rbsa->origin->ds_phys->ds_guid != rbsa->fromguid) |
|
518 |
return (ENODEV); |
|
519 |
} |
|
520 |
||
521 |
return (0); |
|
522 |
} |
|
523 |
||
524 |
static void |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
525 |
recv_new_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) |
5367 | 526 |
{ |
527 |
dsl_dir_t *dd = arg1; |
|
528 |
struct recvbeginsyncarg *rbsa = arg2; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
529 |
uint64_t flags = DS_FLAG_INCONSISTENT | rbsa->dsflags; |
5367 | 530 |
uint64_t dsobj; |
531 |
||
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
532 |
/* Create and open new dataset. */ |
5367 | 533 |
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
|
534 |
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
|
535 |
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
|
536 |
B_TRUE, dmu_recv_tag, &rbsa->ds)); |
5367 | 537 |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
538 |
if (rbsa->origin == NULL) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
539 |
(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
|
540 |
rbsa->ds, &rbsa->ds->ds_phys->ds_bp, rbsa->type, tx); |
5367 | 541 |
} |
542 |
||
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
543 |
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
|
544 |
dd->dd_pool->dp_spa, tx, cr, "dataset = %lld", dsobj); |
5367 | 545 |
} |
546 |
||
547 |
/* ARGSUSED */ |
|
548 |
static int |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
549 |
recv_existing_check(void *arg1, void *arg2, dmu_tx_t *tx) |
5367 | 550 |
{ |
551 |
dsl_dataset_t *ds = arg1; |
|
552 |
struct recvbeginsyncarg *rbsa = arg2; |
|
2743 | 553 |
int err; |
554 |
uint64_t val; |
|
555 |
||
5367 | 556 |
/* must not have any changes since most recent snapshot */ |
557 |
if (!rbsa->force && dsl_dataset_modified_since_lastsnap(ds)) |
|
558 |
return (ETXTBSY); |
|
559 |
||
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
560 |
if (rbsa->fromguid) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
561 |
/* 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
|
562 |
if (ds->ds_prev == NULL) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
563 |
return (ENODEV); |
11022
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
564 |
|
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
565 |
/* |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
566 |
* most recent snapshot must match fromguid, or there are no |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
567 |
* changes since the fromguid one |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
568 |
*/ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
569 |
if (ds->ds_prev->ds_phys->ds_guid != rbsa->fromguid) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
570 |
uint64_t birth = ds->ds_prev->ds_phys->ds_bp.blk_birth; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
571 |
uint64_t obj = ds->ds_prev->ds_phys->ds_prev_snap_obj; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
572 |
while (obj != 0) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
573 |
dsl_dataset_t *snap; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
574 |
err = dsl_dataset_hold_obj(ds->ds_dir->dd_pool, |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
575 |
obj, FTAG, &snap); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
576 |
if (err) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
577 |
return (ENODEV); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
578 |
if (snap->ds_phys->ds_creation_txg < birth) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
579 |
dsl_dataset_rele(snap, FTAG); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
580 |
return (ENODEV); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
581 |
} |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
582 |
if (snap->ds_phys->ds_guid == rbsa->fromguid) { |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
583 |
dsl_dataset_rele(snap, FTAG); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
584 |
break; /* it's ok */ |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
585 |
} |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
586 |
obj = snap->ds_phys->ds_prev_snap_obj; |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
587 |
dsl_dataset_rele(snap, FTAG); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
588 |
} |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
589 |
if (obj == 0) |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
590 |
return (ENODEV); |
63ab26072e41
PSARC 2009/510 ZFS received properties
Tom Erickson <Tom.Erickson@Sun.COM>
parents:
11012
diff
changeset
|
591 |
} |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
592 |
} else { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
593 |
/* 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
|
594 |
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
|
595 |
return (ENODEV); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
596 |
} |
2743 | 597 |
|
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
|
598 |
/* 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
|
599 |
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
|
600 |
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
|
601 |
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
|
602 |
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
|
603 |
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
|
604 |
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
|
605 |
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
|
606 |
|
2743 | 607 |
/* new snapshot name must not exist */ |
5367 | 608 |
err = zap_lookup(ds->ds_dir->dd_pool->dp_meta_objset, |
609 |
ds->ds_phys->ds_snapnames_zapobj, rbsa->tosnap, 8, 1, &val); |
|
610 |
if (err == 0) |
|
2743 | 611 |
return (EEXIST); |
612 |
if (err != ENOENT) |
|
5367 | 613 |
return (err); |
2743 | 614 |
return (0); |
615 |
} |
|
616 |
||
617 |
/* ARGSUSED */ |
|
5367 | 618 |
static void |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
619 |
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
|
620 |
{ |
5367 | 621 |
dsl_dataset_t *ohds = arg1; |
622 |
struct recvbeginsyncarg *rbsa = arg2; |
|
623 |
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
|
624 |
dsl_dataset_t *cds; |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
625 |
uint64_t flags = DS_FLAG_INCONSISTENT | rbsa->dsflags; |
5367 | 626 |
uint64_t dsobj; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
627 |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
628 |
/* 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
|
629 |
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
|
630 |
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
|
631 |
VERIFY(0 == dsl_dataset_own_obj(dp, dsobj, B_TRUE, dmu_recv_tag, &cds)); |
5367 | 632 |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
633 |
/* |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
634 |
* 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
|
635 |
* objset in our new dataset. |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
636 |
*/ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
637 |
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
|
638 |
(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
|
639 |
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
|
640 |
} |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
641 |
|
5367 | 642 |
rbsa->ds = cds; |
643 |
||
644 |
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
|
645 |
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
|
646 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
647 |
|
5367 | 648 |
/* |
649 |
* NB: callers *MUST* call dmu_recv_stream() if dmu_recv_begin() |
|
650 |
* succeeds; otherwise we will leak the holds on the datasets. |
|
651 |
*/ |
|
652 |
int |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
653 |
dmu_recv_begin(char *tofs, char *tosnap, char *top_ds, struct drr_begin *drrb, |
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
654 |
boolean_t force, objset_t *origin, dmu_recv_cookie_t *drc) |
2743 | 655 |
{ |
5367 | 656 |
int err = 0; |
657 |
boolean_t byteswap; |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
658 |
struct recvbeginsyncarg rbsa = { 0 }; |
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
659 |
uint64_t versioninfo; |
5367 | 660 |
int flags; |
661 |
dsl_dataset_t *ds; |
|
662 |
||
663 |
if (drrb->drr_magic == DMU_BACKUP_MAGIC) |
|
664 |
byteswap = FALSE; |
|
665 |
else if (drrb->drr_magic == BSWAP_64(DMU_BACKUP_MAGIC)) |
|
666 |
byteswap = TRUE; |
|
667 |
else |
|
668 |
return (EINVAL); |
|
669 |
||
670 |
rbsa.tofs = tofs; |
|
671 |
rbsa.tosnap = tosnap; |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
672 |
rbsa.origin = origin ? origin->os_dsl_dataset : NULL; |
5367 | 673 |
rbsa.fromguid = drrb->drr_fromguid; |
674 |
rbsa.type = drrb->drr_type; |
|
675 |
rbsa.tag = FTAG; |
|
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6479
diff
changeset
|
676 |
rbsa.dsflags = 0; |
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
677 |
versioninfo = drrb->drr_versioninfo; |
5367 | 678 |
flags = drrb->drr_flags; |
679 |
||
680 |
if (byteswap) { |
|
681 |
rbsa.type = BSWAP_32(rbsa.type); |
|
682 |
rbsa.fromguid = BSWAP_64(rbsa.fromguid); |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
683 |
versioninfo = BSWAP_64(versioninfo); |
5367 | 684 |
flags = BSWAP_32(flags); |
685 |
} |
|
686 |
||
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
687 |
if (DMU_GET_STREAM_HDRTYPE(versioninfo) == DMU_COMPOUNDSTREAM || |
5367 | 688 |
rbsa.type >= DMU_OST_NUMTYPES || |
689 |
((flags & DRR_FLAG_CLONE) && origin == NULL)) |
|
690 |
return (EINVAL); |
|
691 |
||
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6479
diff
changeset
|
692 |
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
|
693 |
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
|
694 |
|
5367 | 695 |
bzero(drc, sizeof (dmu_recv_cookie_t)); |
696 |
drc->drc_drrb = drrb; |
|
697 |
drc->drc_tosnap = tosnap; |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
698 |
drc->drc_top_ds = top_ds; |
5367 | 699 |
drc->drc_force = force; |
700 |
||
701 |
/* |
|
702 |
* Process the begin in syncing context. |
|
703 |
*/ |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
704 |
|
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
705 |
/* 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
|
706 |
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
|
707 |
if (err == 0) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
708 |
/* target fs already exists; recv into temp clone */ |
5367 | 709 |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
710 |
/* 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
|
711 |
if (flags & DRR_FLAG_CLONE) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
712 |
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
|
713 |
return (EINVAL); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
714 |
} |
2743 | 715 |
|
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
716 |
/* 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
|
717 |
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
|
718 |
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
|
719 |
return (EBUSY); |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
720 |
} |
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
721 |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
722 |
/* 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
|
723 |
(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
|
724 |
"%%%s", tosnap); |
5367 | 725 |
rbsa.force = force; |
726 |
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
|
727 |
recv_existing_check, recv_existing_sync, ds, &rbsa, 5); |
5367 | 728 |
if (err) { |
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
729 |
mutex_exit(&ds->ds_recvlock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
730 |
dsl_dataset_rele(ds, dmu_recv_tag); |
5367 | 731 |
return (err); |
732 |
} |
|
733 |
drc->drc_logical_ds = ds; |
|
734 |
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
|
735 |
} else if (err == ENOENT) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
736 |
/* 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
|
737 |
char *cp; |
5367 | 738 |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
739 |
/* |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
740 |
* 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
|
741 |
* 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
|
742 |
*/ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
743 |
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
|
744 |
return (ENOENT); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
745 |
|
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
746 |
/* Open the parent of tofs */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
747 |
cp = strrchr(tofs, '/'); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
748 |
*cp = '\0'; |
10819
d41e0e73a69e
6891564 7410C - zfs panic in recv_new_check()
Chris Kirby <Chris.Kirby@sun.com>
parents:
10298
diff
changeset
|
749 |
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
|
750 |
*cp = '/'; |
5367 | 751 |
if (err) |
752 |
return (err); |
|
753 |
||
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
754 |
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
|
755 |
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
|
756 |
dsl_dataset_rele(ds, FTAG); |
5367 | 757 |
if (err) |
758 |
return (err); |
|
759 |
drc->drc_logical_ds = drc->drc_real_ds = rbsa.ds; |
|
760 |
drc->drc_newfs = B_TRUE; |
|
761 |
} |
|
762 |
||
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
763 |
return (err); |
2743 | 764 |
} |
765 |
||
5367 | 766 |
struct restorearg { |
767 |
int err; |
|
768 |
int byteswap; |
|
769 |
vnode_t *vp; |
|
770 |
char *buf; |
|
771 |
uint64_t voff; |
|
772 |
int bufsize; /* amount of memory allocated for buf */ |
|
773 |
zio_cksum_t cksum; |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
774 |
avl_tree_t guid_to_ds_map; |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
775 |
}; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
776 |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
777 |
typedef struct guid_map_entry { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
778 |
uint64_t guid; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
779 |
dsl_dataset_t *gme_ds; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
780 |
avl_node_t avlnode; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
781 |
} guid_map_entry_t; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
782 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
783 |
static int |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
784 |
guid_compare(const void *arg1, const void *arg2) |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
785 |
{ |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
786 |
const guid_map_entry_t *gmep1 = arg1; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
787 |
const guid_map_entry_t *gmep2 = arg2; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
788 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
789 |
if (gmep1->guid < gmep2->guid) |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
790 |
return (-1); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
791 |
else if (gmep1->guid > gmep2->guid) |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
792 |
return (1); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
793 |
return (0); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
794 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
795 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
796 |
/* |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
797 |
* This function is a callback used by dmu_objset_find() (which |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
798 |
* enumerates the object sets) to build an avl tree that maps guids |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
799 |
* to datasets. The resulting table is used when processing DRR_WRITE_BYREF |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
800 |
* send stream records. These records, which are used in dedup'ed |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
801 |
* streams, do not contain data themselves, but refer to a copy |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
802 |
* of the data block that has already been written because it was |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
803 |
* earlier in the stream. That previous copy is identified by the |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
804 |
* guid of the dataset with the referenced data. |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
805 |
*/ |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
806 |
int |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
807 |
find_ds_by_guid(const char *name, void *arg) |
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
808 |
{ |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
809 |
avl_tree_t *guid_map = arg; |
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
810 |
dsl_dataset_t *ds, *snapds; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
811 |
guid_map_entry_t *gmep; |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11022
diff
changeset
|
812 |
dsl_pool_t *dp; |
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
813 |
int err; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
814 |
uint64_t lastobj, firstobj; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
815 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
816 |
if (dsl_dataset_hold(name, FTAG, &ds) != 0) |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
817 |
return (0); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
818 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
819 |
dp = ds->ds_dir->dd_pool; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
820 |
rw_enter(&dp->dp_config_rwlock, RW_READER); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
821 |
firstobj = ds->ds_dir->dd_phys->dd_origin_obj; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
822 |
lastobj = ds->ds_phys->ds_prev_snap_obj; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
823 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
824 |
while (lastobj != firstobj) { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
825 |
err = dsl_dataset_hold_obj(dp, lastobj, guid_map, &snapds); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
826 |
if (err) { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
827 |
/* |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
828 |
* Skip this snapshot and move on. It's not |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
829 |
* clear why this would ever happen, but the |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
830 |
* remainder of the snapshot streadm can be |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
831 |
* processed. |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
832 |
*/ |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
833 |
rw_exit(&dp->dp_config_rwlock); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
834 |
dsl_dataset_rele(ds, FTAG); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
835 |
return (0); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
836 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
837 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
838 |
gmep = kmem_alloc(sizeof (guid_map_entry_t), KM_SLEEP); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
839 |
gmep->guid = snapds->ds_phys->ds_guid; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
840 |
gmep->gme_ds = snapds; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
841 |
avl_add(guid_map, gmep); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
842 |
lastobj = snapds->ds_phys->ds_prev_snap_obj; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
843 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
844 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
845 |
rw_exit(&dp->dp_config_rwlock); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
846 |
dsl_dataset_rele(ds, FTAG); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
847 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
848 |
return (0); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
849 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
850 |
|
2743 | 851 |
static void * |
852 |
restore_read(struct restorearg *ra, int len) |
|
853 |
{ |
|
854 |
void *rv; |
|
5367 | 855 |
int done = 0; |
2743 | 856 |
|
857 |
/* some things will require 8-byte alignment, so everything must */ |
|
858 |
ASSERT3U(len % 8, ==, 0); |
|
859 |
||
5367 | 860 |
while (done < len) { |
2743 | 861 |
ssize_t resid; |
862 |
||
863 |
ra->err = vn_rdwr(UIO_READ, ra->vp, |
|
5367 | 864 |
(caddr_t)ra->buf + done, len - done, |
2743 | 865 |
ra->voff, UIO_SYSSPACE, FAPPEND, |
866 |
RLIM64_INFINITY, CRED(), &resid); |
|
867 |
||
5367 | 868 |
if (resid == len - done) |
2743 | 869 |
ra->err = EINVAL; |
5367 | 870 |
ra->voff += len - done - resid; |
871 |
done = len - resid; |
|
2743 | 872 |
if (ra->err) |
873 |
return (NULL); |
|
874 |
} |
|
875 |
||
5367 | 876 |
ASSERT3U(done, ==, len); |
877 |
rv = ra->buf; |
|
2743 | 878 |
if (ra->byteswap) |
5367 | 879 |
fletcher_4_incremental_byteswap(rv, len, &ra->cksum); |
2743 | 880 |
else |
5367 | 881 |
fletcher_4_incremental_native(rv, len, &ra->cksum); |
2743 | 882 |
return (rv); |
883 |
} |
|
884 |
||
885 |
static void |
|
886 |
backup_byteswap(dmu_replay_record_t *drr) |
|
887 |
{ |
|
888 |
#define DO64(X) (drr->drr_u.X = BSWAP_64(drr->drr_u.X)) |
|
889 |
#define DO32(X) (drr->drr_u.X = BSWAP_32(drr->drr_u.X)) |
|
890 |
drr->drr_type = BSWAP_32(drr->drr_type); |
|
5367 | 891 |
drr->drr_payloadlen = BSWAP_32(drr->drr_payloadlen); |
2743 | 892 |
switch (drr->drr_type) { |
893 |
case DRR_BEGIN: |
|
894 |
DO64(drr_begin.drr_magic); |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
895 |
DO64(drr_begin.drr_versioninfo); |
2743 | 896 |
DO64(drr_begin.drr_creation_time); |
897 |
DO32(drr_begin.drr_type); |
|
5367 | 898 |
DO32(drr_begin.drr_flags); |
2743 | 899 |
DO64(drr_begin.drr_toguid); |
900 |
DO64(drr_begin.drr_fromguid); |
|
901 |
break; |
|
902 |
case DRR_OBJECT: |
|
903 |
DO64(drr_object.drr_object); |
|
904 |
/* DO64(drr_object.drr_allocation_txg); */ |
|
905 |
DO32(drr_object.drr_type); |
|
906 |
DO32(drr_object.drr_bonustype); |
|
907 |
DO32(drr_object.drr_blksz); |
|
908 |
DO32(drr_object.drr_bonuslen); |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
909 |
DO64(drr_object.drr_toguid); |
2743 | 910 |
break; |
911 |
case DRR_FREEOBJECTS: |
|
912 |
DO64(drr_freeobjects.drr_firstobj); |
|
913 |
DO64(drr_freeobjects.drr_numobjs); |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
914 |
DO64(drr_freeobjects.drr_toguid); |
2743 | 915 |
break; |
916 |
case DRR_WRITE: |
|
917 |
DO64(drr_write.drr_object); |
|
918 |
DO32(drr_write.drr_type); |
|
919 |
DO64(drr_write.drr_offset); |
|
920 |
DO64(drr_write.drr_length); |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
921 |
DO64(drr_write.drr_toguid); |
11381
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
922 |
DO64(drr_write.drr_key.ddk_cksum.zc_word[0]); |
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
923 |
DO64(drr_write.drr_key.ddk_cksum.zc_word[1]); |
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
924 |
DO64(drr_write.drr_key.ddk_cksum.zc_word[2]); |
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
925 |
DO64(drr_write.drr_key.ddk_cksum.zc_word[3]); |
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
926 |
DO64(drr_write.drr_key.ddk_prop); |
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
927 |
break; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
928 |
case DRR_WRITE_BYREF: |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
929 |
DO64(drr_write_byref.drr_object); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
930 |
DO64(drr_write_byref.drr_offset); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
931 |
DO64(drr_write_byref.drr_length); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
932 |
DO64(drr_write_byref.drr_toguid); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
933 |
DO64(drr_write_byref.drr_refguid); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
934 |
DO64(drr_write_byref.drr_refobject); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
935 |
DO64(drr_write_byref.drr_refoffset); |
11381
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
936 |
DO64(drr_write_byref.drr_key.ddk_cksum.zc_word[0]); |
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
937 |
DO64(drr_write_byref.drr_key.ddk_cksum.zc_word[1]); |
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
938 |
DO64(drr_write_byref.drr_key.ddk_cksum.zc_word[2]); |
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
939 |
DO64(drr_write_byref.drr_key.ddk_cksum.zc_word[3]); |
c77e4d2b2e75
6907006 zfs over-the-wire dedup recalculates checksums unnecessarily
Lori Alt <Lori.Alt@Sun.COM>
parents:
11209
diff
changeset
|
940 |
DO64(drr_write_byref.drr_key.ddk_prop); |
2743 | 941 |
break; |
942 |
case DRR_FREE: |
|
943 |
DO64(drr_free.drr_object); |
|
944 |
DO64(drr_free.drr_offset); |
|
945 |
DO64(drr_free.drr_length); |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
946 |
DO64(drr_free.drr_toguid); |
2743 | 947 |
break; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
948 |
case DRR_SPILL: |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
949 |
DO64(drr_spill.drr_object); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
950 |
DO64(drr_spill.drr_length); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
951 |
DO64(drr_spill.drr_toguid); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
952 |
break; |
2743 | 953 |
case DRR_END: |
954 |
DO64(drr_end.drr_checksum.zc_word[0]); |
|
955 |
DO64(drr_end.drr_checksum.zc_word[1]); |
|
956 |
DO64(drr_end.drr_checksum.zc_word[2]); |
|
957 |
DO64(drr_end.drr_checksum.zc_word[3]); |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
958 |
DO64(drr_end.drr_toguid); |
2743 | 959 |
break; |
960 |
} |
|
961 |
#undef DO64 |
|
962 |
#undef DO32 |
|
963 |
} |
|
964 |
||
965 |
static int |
|
966 |
restore_object(struct restorearg *ra, objset_t *os, struct drr_object *drro) |
|
967 |
{ |
|
968 |
int err; |
|
969 |
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
|
970 |
void *data = NULL; |
2743 | 971 |
|
972 |
if (drro->drr_type == DMU_OT_NONE || |
|
973 |
drro->drr_type >= DMU_OT_NUMTYPES || |
|
974 |
drro->drr_bonustype >= DMU_OT_NUMTYPES || |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
975 |
drro->drr_checksumtype >= ZIO_CHECKSUM_FUNCTIONS || |
2743 | 976 |
drro->drr_compress >= ZIO_COMPRESS_FUNCTIONS || |
977 |
P2PHASE(drro->drr_blksz, SPA_MINBLOCKSIZE) || |
|
978 |
drro->drr_blksz < SPA_MINBLOCKSIZE || |
|
979 |
drro->drr_blksz > SPA_MAXBLOCKSIZE || |
|
980 |
drro->drr_bonuslen > DN_MAX_BONUSLEN) { |
|
981 |
return (EINVAL); |
|
982 |
} |
|
983 |
||
8986
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
984 |
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
|
985 |
|
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
986 |
if (err != 0 && err != ENOENT) |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
987 |
return (EINVAL); |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
988 |
|
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
|
989 |
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
|
990 |
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
|
991 |
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
|
992 |
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
|
993 |
} |
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
|
994 |
|
2743 | 995 |
if (err == ENOENT) { |
996 |
/* 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
|
997 |
tx = dmu_tx_create(os); |
2743 | 998 |
dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT); |
999 |
err = dmu_tx_assign(tx, TXG_WAIT); |
|
1000 |
if (err) { |
|
1001 |
dmu_tx_abort(tx); |
|
1002 |
return (err); |
|
1003 |
} |
|
1004 |
err = dmu_object_claim(os, drro->drr_object, |
|
1005 |
drro->drr_type, drro->drr_blksz, |
|
1006 |
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
|
1007 |
dmu_tx_commit(tx); |
2743 | 1008 |
} else { |
1009 |
/* currently allocated, want to be allocated */ |
|
1010 |
err = dmu_object_reclaim(os, drro->drr_object, |
|
1011 |
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
|
1012 |
drro->drr_bonustype, drro->drr_bonuslen); |
2743 | 1013 |
} |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1014 |
if (err) { |
8986
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
1015 |
return (EINVAL); |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1016 |
} |
8986
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
1017 |
|
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
1018 |
tx = dmu_tx_create(os); |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
1019 |
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
|
1020 |
err = dmu_tx_assign(tx, TXG_WAIT); |
2743 | 1021 |
if (err) { |
8986
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
1022 |
dmu_tx_abort(tx); |
45c289aff7c9
6801979 zfs recv can fail with E2BIG
Mark Maybee <Mark.Maybee@Sun.COM>
parents:
8644
diff
changeset
|
1023 |
return (err); |
2743 | 1024 |
} |
1025 |
||
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1026 |
dmu_object_set_checksum(os, drro->drr_object, drro->drr_checksumtype, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1027 |
tx); |
2743 | 1028 |
dmu_object_set_compress(os, drro->drr_object, drro->drr_compress, tx); |
1029 |
||
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
|
1030 |
if (data != NULL) { |
2743 | 1031 |
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
|
1032 |
|
2743 | 1033 |
VERIFY(0 == dmu_bonus_hold(os, drro->drr_object, FTAG, &db)); |
1034 |
dmu_buf_will_dirty(db, tx); |
|
1035 |
||
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4543
diff
changeset
|
1036 |
ASSERT3U(db->db_size, >=, drro->drr_bonuslen); |
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4543
diff
changeset
|
1037 |
bcopy(data, db->db_data, drro->drr_bonuslen); |
2743 | 1038 |
if (ra->byteswap) { |
1039 |
dmu_ot[drro->drr_bonustype].ot_byteswap(db->db_data, |
|
1040 |
drro->drr_bonuslen); |
|
1041 |
} |
|
1042 |
dmu_buf_rele(db, FTAG); |
|
1043 |
} |
|
1044 |
dmu_tx_commit(tx); |
|
1045 |
return (0); |
|
1046 |
} |
|
1047 |
||
1048 |
/* ARGSUSED */ |
|
1049 |
static int |
|
1050 |
restore_freeobjects(struct restorearg *ra, objset_t *os, |
|
1051 |
struct drr_freeobjects *drrfo) |
|
1052 |
{ |
|
1053 |
uint64_t obj; |
|
1054 |
||
1055 |
if (drrfo->drr_firstobj + drrfo->drr_numobjs < drrfo->drr_firstobj) |
|
1056 |
return (EINVAL); |
|
1057 |
||
1058 |
for (obj = drrfo->drr_firstobj; |
|
3087 | 1059 |
obj < drrfo->drr_firstobj + drrfo->drr_numobjs; |
1060 |
(void) dmu_object_next(os, &obj, FALSE, 0)) { |
|
2743 | 1061 |
int err; |
1062 |
||
1063 |
if (dmu_object_info(os, obj, NULL) != 0) |
|
1064 |
continue; |
|
1065 |
||
6992 | 1066 |
err = dmu_free_object(os, obj); |
1067 |
if (err) |
|
2743 | 1068 |
return (err); |
1069 |
} |
|
1070 |
return (0); |
|
1071 |
} |
|
1072 |
||
1073 |
static int |
|
1074 |
restore_write(struct restorearg *ra, objset_t *os, |
|
1075 |
struct drr_write *drrw) |
|
1076 |
{ |
|
1077 |
dmu_tx_t *tx; |
|
1078 |
void *data; |
|
1079 |
int err; |
|
1080 |
||
1081 |
if (drrw->drr_offset + drrw->drr_length < drrw->drr_offset || |
|
1082 |
drrw->drr_type >= DMU_OT_NUMTYPES) |
|
1083 |
return (EINVAL); |
|
1084 |
||
1085 |
data = restore_read(ra, drrw->drr_length); |
|
1086 |
if (data == NULL) |
|
1087 |
return (ra->err); |
|
1088 |
||
1089 |
if (dmu_object_info(os, drrw->drr_object, NULL) != 0) |
|
1090 |
return (EINVAL); |
|
1091 |
||
1092 |
tx = dmu_tx_create(os); |
|
1093 |
||
1094 |
dmu_tx_hold_write(tx, drrw->drr_object, |
|
1095 |
drrw->drr_offset, drrw->drr_length); |
|
1096 |
err = dmu_tx_assign(tx, TXG_WAIT); |
|
1097 |
if (err) { |
|
1098 |
dmu_tx_abort(tx); |
|
1099 |
return (err); |
|
1100 |
} |
|
1101 |
if (ra->byteswap) |
|
1102 |
dmu_ot[drrw->drr_type].ot_byteswap(data, drrw->drr_length); |
|
1103 |
dmu_write(os, drrw->drr_object, |
|
1104 |
drrw->drr_offset, drrw->drr_length, data, tx); |
|
1105 |
dmu_tx_commit(tx); |
|
1106 |
return (0); |
|
1107 |
} |
|
1108 |
||
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1109 |
/* |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1110 |
* Handle a DRR_WRITE_BYREF record. This record is used in dedup'ed |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1111 |
* streams to refer to a copy of the data that is already on the |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1112 |
* system because it came in earlier in the stream. This function |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1113 |
* finds the earlier copy of the data, and uses that copy instead of |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1114 |
* data from the stream to fulfill this write. |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1115 |
*/ |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1116 |
static int |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1117 |
restore_write_byref(struct restorearg *ra, objset_t *os, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1118 |
struct drr_write_byref *drrwbr) |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1119 |
{ |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1120 |
dmu_tx_t *tx; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1121 |
int err; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1122 |
guid_map_entry_t gmesrch; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1123 |
guid_map_entry_t *gmep; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1124 |
avl_index_t where; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1125 |
objset_t *ref_os = NULL; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1126 |
dmu_buf_t *dbp; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1127 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1128 |
if (drrwbr->drr_offset + drrwbr->drr_length < drrwbr->drr_offset) |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1129 |
return (EINVAL); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1130 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1131 |
/* |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1132 |
* If the GUID of the referenced dataset is different from the |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1133 |
* GUID of the target dataset, find the referenced dataset. |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1134 |
*/ |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1135 |
if (drrwbr->drr_toguid != drrwbr->drr_refguid) { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1136 |
gmesrch.guid = drrwbr->drr_refguid; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1137 |
if ((gmep = avl_find(&ra->guid_to_ds_map, &gmesrch, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1138 |
&where)) == NULL) { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1139 |
return (EINVAL); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1140 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1141 |
if (dmu_objset_from_ds(gmep->gme_ds, &ref_os)) |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1142 |
return (EINVAL); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1143 |
} else { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1144 |
ref_os = os; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1145 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1146 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1147 |
if (err = dmu_buf_hold(ref_os, drrwbr->drr_refobject, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1148 |
drrwbr->drr_refoffset, FTAG, &dbp)) |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1149 |
return (err); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1150 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1151 |
tx = dmu_tx_create(os); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1152 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1153 |
dmu_tx_hold_write(tx, drrwbr->drr_object, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1154 |
drrwbr->drr_offset, drrwbr->drr_length); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1155 |
err = dmu_tx_assign(tx, TXG_WAIT); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1156 |
if (err) { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1157 |
dmu_tx_abort(tx); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1158 |
return (err); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1159 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1160 |
dmu_write(os, drrwbr->drr_object, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1161 |
drrwbr->drr_offset, drrwbr->drr_length, dbp->db_data, tx); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1162 |
dmu_buf_rele(dbp, FTAG); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1163 |
dmu_tx_commit(tx); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1164 |
return (0); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1165 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1166 |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1167 |
static int |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1168 |
restore_spill(struct restorearg *ra, objset_t *os, struct drr_spill *drrs) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1169 |
{ |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1170 |
dmu_tx_t *tx; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1171 |
void *data; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1172 |
dmu_buf_t *db, *db_spill; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1173 |
int err; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1174 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1175 |
if (drrs->drr_length < SPA_MINBLOCKSIZE || |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1176 |
drrs->drr_length > SPA_MAXBLOCKSIZE) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1177 |
return (EINVAL); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1178 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1179 |
data = restore_read(ra, drrs->drr_length); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1180 |
if (data == NULL) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1181 |
return (ra->err); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1182 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1183 |
if (dmu_object_info(os, drrs->drr_object, NULL) != 0) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1184 |
return (EINVAL); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1185 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1186 |
VERIFY(0 == dmu_bonus_hold(os, drrs->drr_object, FTAG, &db)); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1187 |
if ((err = dmu_spill_hold_by_bonus(db, FTAG, &db_spill)) != 0) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1188 |
dmu_buf_rele(db, FTAG); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1189 |
return (err); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1190 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1191 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1192 |
tx = dmu_tx_create(os); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1193 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1194 |
dmu_tx_hold_spill(tx, db->db_object); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1195 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1196 |
err = dmu_tx_assign(tx, TXG_WAIT); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1197 |
if (err) { |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1198 |
dmu_buf_rele(db, FTAG); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1199 |
dmu_buf_rele(db_spill, FTAG); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1200 |
dmu_tx_abort(tx); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1201 |
return (err); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1202 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1203 |
dmu_buf_will_dirty(db_spill, tx); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1204 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1205 |
if (db_spill->db_size < drrs->drr_length) |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1206 |
VERIFY(0 == dbuf_spill_set_blksz(db_spill, |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1207 |
drrs->drr_length, tx)); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1208 |
bcopy(data, db_spill->db_data, drrs->drr_length); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1209 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1210 |
dmu_buf_rele(db, FTAG); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1211 |
dmu_buf_rele(db_spill, FTAG); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1212 |
|
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1213 |
dmu_tx_commit(tx); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1214 |
return (0); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1215 |
} |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1216 |
|
2743 | 1217 |
/* ARGSUSED */ |
1218 |
static int |
|
1219 |
restore_free(struct restorearg *ra, objset_t *os, |
|
1220 |
struct drr_free *drrf) |
|
1221 |
{ |
|
1222 |
int err; |
|
1223 |
||
1224 |
if (drrf->drr_length != -1ULL && |
|
1225 |
drrf->drr_offset + drrf->drr_length < drrf->drr_offset) |
|
1226 |
return (EINVAL); |
|
1227 |
||
1228 |
if (dmu_object_info(os, drrf->drr_object, NULL) != 0) |
|
1229 |
return (EINVAL); |
|
1230 |
||
6992 | 1231 |
err = dmu_free_long_range(os, drrf->drr_object, |
2743 | 1232 |
drrf->drr_offset, drrf->drr_length); |
1233 |
return (err); |
|
1234 |
} |
|
1235 |
||
5367 | 1236 |
/* |
1237 |
* NB: callers *must* call dmu_recv_end() if this succeeds. |
|
1238 |
*/ |
|
1239 |
int |
|
1240 |
dmu_recv_stream(dmu_recv_cookie_t *drc, vnode_t *vp, offset_t *voffp) |
|
1241 |
{ |
|
1242 |
struct restorearg ra = { 0 }; |
|
1243 |
dmu_replay_record_t *drr; |
|
1244 |
objset_t *os; |
|
1245 |
zio_cksum_t pcksum; |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1246 |
guid_map_entry_t *gmep; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1247 |
int featureflags; |
5367 | 1248 |
|
1249 |
if (drc->drc_drrb->drr_magic == BSWAP_64(DMU_BACKUP_MAGIC)) |
|
1250 |
ra.byteswap = TRUE; |
|
2743 | 1251 |
|
5367 | 1252 |
{ |
1253 |
/* compute checksum of drr_begin record */ |
|
1254 |
dmu_replay_record_t *drr; |
|
1255 |
drr = kmem_zalloc(sizeof (dmu_replay_record_t), KM_SLEEP); |
|
1256 |
||
1257 |
drr->drr_type = DRR_BEGIN; |
|
1258 |
drr->drr_u.drr_begin = *drc->drc_drrb; |
|
1259 |
if (ra.byteswap) { |
|
1260 |
fletcher_4_incremental_byteswap(drr, |
|
1261 |
sizeof (dmu_replay_record_t), &ra.cksum); |
|
1262 |
} else { |
|
1263 |
fletcher_4_incremental_native(drr, |
|
1264 |
sizeof (dmu_replay_record_t), &ra.cksum); |
|
1265 |
} |
|
1266 |
kmem_free(drr, sizeof (dmu_replay_record_t)); |
|
2743 | 1267 |
} |
1268 |
||
1269 |
if (ra.byteswap) { |
|
5367 | 1270 |
struct drr_begin *drrb = drc->drc_drrb; |
2743 | 1271 |
drrb->drr_magic = BSWAP_64(drrb->drr_magic); |
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1272 |
drrb->drr_versioninfo = BSWAP_64(drrb->drr_versioninfo); |
2743 | 1273 |
drrb->drr_creation_time = BSWAP_64(drrb->drr_creation_time); |
1274 |
drrb->drr_type = BSWAP_32(drrb->drr_type); |
|
1275 |
drrb->drr_toguid = BSWAP_64(drrb->drr_toguid); |
|
1276 |
drrb->drr_fromguid = BSWAP_64(drrb->drr_fromguid); |
|
1277 |
} |
|
1278 |
||
5367 | 1279 |
ra.vp = vp; |
1280 |
ra.voff = *voffp; |
|
1281 |
ra.bufsize = 1<<20; |
|
1282 |
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
|
1283 |
|
5367 | 1284 |
/* these were verified in dmu_recv_begin */ |
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1285 |
ASSERT(DMU_GET_STREAM_HDRTYPE(drc->drc_drrb->drr_versioninfo) == |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1286 |
DMU_SUBSTREAM); |
5367 | 1287 |
ASSERT(drc->drc_drrb->drr_type < DMU_OST_NUMTYPES); |
2743 | 1288 |
|
1289 |
/* |
|
1290 |
* Open the objset we are modifying. |
|
1291 |
*/ |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10272
diff
changeset
|
1292 |
VERIFY(dmu_objset_from_ds(drc->drc_real_ds, &os) == 0); |
2743 | 1293 |
|
5367 | 1294 |
ASSERT(drc->drc_real_ds->ds_phys->ds_flags & DS_FLAG_INCONSISTENT); |
2743 | 1295 |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1296 |
featureflags = DMU_GET_FEATUREFLAGS(drc->drc_drrb->drr_versioninfo); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1297 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1298 |
/* if this stream is dedup'ed, set up the avl tree for guid mapping */ |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1299 |
if (featureflags & DMU_BACKUP_FEATURE_DEDUP) { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1300 |
avl_create(&ra.guid_to_ds_map, guid_compare, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1301 |
sizeof (guid_map_entry_t), |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1302 |
offsetof(guid_map_entry_t, avlnode)); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1303 |
(void) dmu_objset_find(drc->drc_top_ds, find_ds_by_guid, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1304 |
(void *)&ra.guid_to_ds_map, |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1305 |
DS_FIND_CHILDREN); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1306 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1307 |
|
2743 | 1308 |
/* |
1309 |
* Read records and process them. |
|
1310 |
*/ |
|
5367 | 1311 |
pcksum = ra.cksum; |
2743 | 1312 |
while (ra.err == 0 && |
1313 |
NULL != (drr = restore_read(&ra, sizeof (*drr)))) { |
|
1314 |
if (issig(JUSTLOOKING) && issig(FORREAL)) { |
|
1315 |
ra.err = EINTR; |
|
1316 |
goto out; |
|
1317 |
} |
|
1318 |
||
1319 |
if (ra.byteswap) |
|
1320 |
backup_byteswap(drr); |
|
1321 |
||
1322 |
switch (drr->drr_type) { |
|
1323 |
case DRR_OBJECT: |
|
1324 |
{ |
|
1325 |
/* |
|
1326 |
* We need to make a copy of the record header, |
|
1327 |
* because restore_{object,write} may need to |
|
1328 |
* restore_read(), which will invalidate drr. |
|
1329 |
*/ |
|
1330 |
struct drr_object drro = drr->drr_u.drr_object; |
|
1331 |
ra.err = restore_object(&ra, os, &drro); |
|
1332 |
break; |
|
1333 |
} |
|
1334 |
case DRR_FREEOBJECTS: |
|
1335 |
{ |
|
1336 |
struct drr_freeobjects drrfo = |
|
1337 |
drr->drr_u.drr_freeobjects; |
|
1338 |
ra.err = restore_freeobjects(&ra, os, &drrfo); |
|
1339 |
break; |
|
1340 |
} |
|
1341 |
case DRR_WRITE: |
|
1342 |
{ |
|
1343 |
struct drr_write drrw = drr->drr_u.drr_write; |
|
1344 |
ra.err = restore_write(&ra, os, &drrw); |
|
1345 |
break; |
|
1346 |
} |
|
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1347 |
case DRR_WRITE_BYREF: |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1348 |
{ |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1349 |
struct drr_write_byref drrwbr = |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1350 |
drr->drr_u.drr_write_byref; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1351 |
ra.err = restore_write_byref(&ra, os, &drrwbr); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1352 |
break; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1353 |
} |
2743 | 1354 |
case DRR_FREE: |
1355 |
{ |
|
1356 |
struct drr_free drrf = drr->drr_u.drr_free; |
|
1357 |
ra.err = restore_free(&ra, os, &drrf); |
|
1358 |
break; |
|
1359 |
} |
|
1360 |
case DRR_END: |
|
1361 |
{ |
|
1362 |
struct drr_end drre = drr->drr_u.drr_end; |
|
1363 |
/* |
|
1364 |
* We compare against the *previous* checksum |
|
1365 |
* value, because the stored checksum is of |
|
1366 |
* everything before the DRR_END record. |
|
1367 |
*/ |
|
6479 | 1368 |
if (!ZIO_CHECKSUM_EQUAL(drre.drr_checksum, pcksum)) |
2743 | 1369 |
ra.err = ECKSUM; |
1370 |
goto out; |
|
1371 |
} |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1372 |
case DRR_SPILL: |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1373 |
{ |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1374 |
struct drr_spill drrs = drr->drr_u.drr_spill; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1375 |
ra.err = restore_spill(&ra, os, &drrs); |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1376 |
break; |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11381
diff
changeset
|
1377 |
} |
2743 | 1378 |
default: |
1379 |
ra.err = EINVAL; |
|
1380 |
goto out; |
|
1381 |
} |
|
5367 | 1382 |
pcksum = ra.cksum; |
2743 | 1383 |
} |
6479 | 1384 |
ASSERT(ra.err != 0); |
2743 | 1385 |
|
1386 |
out: |
|
5367 | 1387 |
if (ra.err != 0) { |
2743 | 1388 |
/* |
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
1389 |
* 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
|
1390 |
* inconsistent restoring state. |
2743 | 1391 |
*/ |
5367 | 1392 |
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
|
1393 |
|
10242
c40d075fbca6
PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents:
10204
diff
changeset
|
1394 |
(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
|
1395 |
B_FALSE); |
10204
83c3a84aecef
6760420 zfs unmount -f causes recv to fail
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
1396 |
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
|
1397 |
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
|
1398 |
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
|
1399 |
} |
2743 | 1400 |
} |
1401 |
||
11007
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1402 |
if (featureflags & DMU_BACKUP_FEATURE_DEDUP) { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1403 |
void *cookie = NULL; |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1404 |
|
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1405 |
while (gmep = avl_destroy_nodes(&ra.guid_to_ds_map, &cookie)) { |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1406 |
dsl_dataset_rele(gmep->gme_ds, &ra.guid_to_ds_map); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1407 |
kmem_free(gmep, sizeof (guid_map_entry_t)); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1408 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1409 |
avl_destroy(&ra.guid_to_ds_map); |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1410 |
} |
216d8396182e
PSARC/2009/557 ZFS send dedup
Lori Alt <Lori.Alt@Sun.COM>
parents:
10922
diff
changeset
|
1411 |
|
2743 | 1412 |
kmem_free(ra.buf, ra.bufsize); |
5367 | 1413 |
*voffp = ra.voff; |
2743 | 1414 |
return (ra.err); |
1415 |
} |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
1416 |
|
5367 | 1417 |
struct recvendsyncarg { |
1418 |
char *tosnap; |
|
1419 |
uint64_t creation_time; |
|
1420 |
uint64_t toguid; |
|
1421 |
}; |
|
1422 |
||
1423 |
static int |
|
1424 |
recv_end_check(void *arg1, void *arg2, dmu_tx_t *tx) |
|
1425 |
{ |
|
1426 |
dsl_dataset_t *ds = arg1; |
|
1427 |
struct recvendsyncarg *resa = arg2; |
|
1428 |
||
1429 |
return (dsl_dataset_snapshot_check(ds, resa->tosnap, tx)); |
|
1430 |
} |
|
1431 |
||
1432 |
static void |
|
1433 |
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
|
1434 |
{ |
5367 | 1435 |
dsl_dataset_t *ds = arg1; |
1436 |
struct recvendsyncarg *resa = arg2; |
|
1437 |
||
1438 |
dsl_dataset_snapshot_sync(ds, resa->tosnap, cr, tx); |
|
1439 |
||
1440 |
/* set snapshot's creation time and guid */ |
|
1441 |
dmu_buf_will_dirty(ds->ds_prev->ds_dbuf, tx); |
|
1442 |
ds->ds_prev->ds_phys->ds_creation_time = resa->creation_time; |
|
1443 |
ds->ds_prev->ds_phys->ds_guid = resa->toguid; |
|
1444 |
ds->ds_prev->ds_phys->ds_flags &= ~DS_FLAG_INCONSISTENT; |
|
1445 |
||
1446 |
dmu_buf_will_dirty(ds->ds_dbuf, tx); |
|
1447 |
ds->ds_phys->ds_flags &= ~DS_FLAG_INCONSISTENT; |
|
1448 |
} |
|
1449 |
||
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1450 |
static int |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1451 |
dmu_recv_existing_end(dmu_recv_cookie_t *drc) |
5367 | 1452 |
{ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1453 |
struct recvendsyncarg resa; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1454 |
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
|
1455 |
int err; |
5367 | 1456 |
|
1457 |
/* |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1458 |
* 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
|
1459 |
* 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
|
1460 |
* can close it. |
5367 | 1461 |
*/ |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1462 |
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
|
1463 |
|
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1464 |
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
|
1465 |
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
|
1466 |
drc->drc_force); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1467 |
if (err) |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1468 |
goto out; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1469 |
} else { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1470 |
mutex_exit(&ds->ds_recvlock); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1471 |
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
|
1472 |
(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
|
1473 |
B_FALSE); |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1474 |
return (EBUSY); |
5367 | 1475 |
} |
1476 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1477 |
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
|
1478 |
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
|
1479 |
resa.tosnap = drc->drc_tosnap; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1480 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1481 |
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
|
1482 |
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
|
1483 |
if (err) { |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1484 |
/* swap back */ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1485 |
(void) dsl_dataset_clone_swap(drc->drc_real_ds, ds, B_TRUE); |
5367 | 1486 |
} |
1487 |
||
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1488 |
out: |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1489 |
mutex_exit(&ds->ds_recvlock); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
1490 |
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
|
1491 |
(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
|
1492 |
return (err); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
4944
diff
changeset
|
1493 |
} |
10272
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1494 |
|
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1495 |
static int |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1496 |
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
|
1497 |
{ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1498 |
struct recvendsyncarg resa; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1499 |
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
|
1500 |
int err; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1501 |
|
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1502 |
/* |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1503 |
* 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
|
1504 |
* 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
|
1505 |
* can close it. |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1506 |
*/ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1507 |
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
|
1508 |
|
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1509 |
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
|
1510 |
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
|
1511 |
resa.tosnap = drc->drc_tosnap; |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1512 |
|
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1513 |
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
|
1514 |
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
|
1515 |
if (err) { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1516 |
/* 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
|
1517 |
(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
|
1518 |
} else { |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1519 |
/* 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
|
1520 |
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
|
1521 |
} |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1522 |
return (err); |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1523 |
} |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1524 |
|
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1525 |
int |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1526 |
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
|
1527 |
{ |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1528 |
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
|
1529 |
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
|
1530 |
else |
a0669934e974
6861581 ZFS frees in synching context during rollback
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10242
diff
changeset
|
1531 |
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
|
1532 |
} |