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