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