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