author | Matthew Ahrens <Matthew.Ahrens@Sun.COM> |
Mon, 30 Nov 2009 11:36:36 -0800 | |
changeset 11209 | 462283cb4096 |
parent 11066 | cebb50cbe4f9 |
child 11670 | 1d964fb5d948 |
permissions | -rw-r--r-- |
789 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
1472 | 5 |
* Common Development and Distribution License (the "License"). |
6 |
* You may not use this file except in compliance with the License. |
|
789 | 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 |
/* |
|
8746
e1d96ca6808c
6796377 panic on rollback in space_map_add()
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8227
diff
changeset
|
22 |
* Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
789 | 23 |
* Use is subject to license terms. |
24 |
*/ |
|
25 |
||
26 |
#include <sys/zfs_context.h> |
|
27 |
#include <sys/spa.h> |
|
28 |
#include <sys/dmu.h> |
|
29 |
#include <sys/zap.h> |
|
30 |
#include <sys/arc.h> |
|
31 |
#include <sys/stat.h> |
|
32 |
#include <sys/resource.h> |
|
33 |
#include <sys/zil.h> |
|
34 |
#include <sys/zil_impl.h> |
|
35 |
#include <sys/dsl_dataset.h> |
|
36 |
#include <sys/vdev.h> |
|
3668 | 37 |
#include <sys/dmu_tx.h> |
789 | 38 |
|
39 |
/* |
|
40 |
* The zfs intent log (ZIL) saves transaction records of system calls |
|
41 |
* that change the file system in memory with enough information |
|
42 |
* to be able to replay them. These are stored in memory until |
|
43 |
* either the DMU transaction group (txg) commits them to the stable pool |
|
44 |
* and they can be discarded, or they are flushed to the stable log |
|
45 |
* (also in the pool) due to a fsync, O_DSYNC or other synchronous |
|
46 |
* requirement. In the event of a panic or power fail then those log |
|
47 |
* records (transactions) are replayed. |
|
48 |
* |
|
49 |
* There is one ZIL per file system. Its on-disk (pool) format consists |
|
50 |
* of 3 parts: |
|
51 |
* |
|
52 |
* - ZIL header |
|
53 |
* - ZIL blocks |
|
54 |
* - ZIL records |
|
55 |
* |
|
56 |
* A log record holds a system call transaction. Log blocks can |
|
57 |
* hold many log records and the blocks are chained together. |
|
58 |
* Each ZIL block contains a block pointer (blkptr_t) to the next |
|
59 |
* ZIL block in the chain. The ZIL header points to the first |
|
60 |
* block in the chain. Note there is not a fixed place in the pool |
|
61 |
* to hold blocks. They are dynamically allocated and freed as |
|
62 |
* needed from the blocks available. Figure X shows the ZIL structure: |
|
63 |
*/ |
|
64 |
||
65 |
/* |
|
2986 | 66 |
* This global ZIL switch affects all pools |
789 | 67 |
*/ |
68 |
int zil_disable = 0; /* disable intent logging */ |
|
2986 | 69 |
|
70 |
/* |
|
71 |
* Tunable parameter for debugging or performance analysis. Setting |
|
72 |
* zfs_nocacheflush will cause corruption on power loss if a volatile |
|
73 |
* out-of-order write cache is enabled. |
|
74 |
*/ |
|
75 |
boolean_t zfs_nocacheflush = B_FALSE; |
|
789 | 76 |
|
77 |
static kmem_cache_t *zil_lwb_cache; |
|
78 |
||
10685
931790026ac6
6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents:
10310
diff
changeset
|
79 |
static boolean_t zil_empty(zilog_t *zilog); |
931790026ac6
6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents:
10310
diff
changeset
|
80 |
|
789 | 81 |
static int |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
82 |
zil_bp_compare(const void *x1, const void *x2) |
789 | 83 |
{ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
84 |
const dva_t *dva1 = &((zil_bp_node_t *)x1)->zn_dva; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
85 |
const dva_t *dva2 = &((zil_bp_node_t *)x2)->zn_dva; |
789 | 86 |
|
87 |
if (DVA_GET_VDEV(dva1) < DVA_GET_VDEV(dva2)) |
|
88 |
return (-1); |
|
89 |
if (DVA_GET_VDEV(dva1) > DVA_GET_VDEV(dva2)) |
|
90 |
return (1); |
|
91 |
||
92 |
if (DVA_GET_OFFSET(dva1) < DVA_GET_OFFSET(dva2)) |
|
93 |
return (-1); |
|
94 |
if (DVA_GET_OFFSET(dva1) > DVA_GET_OFFSET(dva2)) |
|
95 |
return (1); |
|
96 |
||
97 |
return (0); |
|
98 |
} |
|
99 |
||
100 |
static void |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
101 |
zil_bp_tree_init(zilog_t *zilog) |
789 | 102 |
{ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
103 |
avl_create(&zilog->zl_bp_tree, zil_bp_compare, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
104 |
sizeof (zil_bp_node_t), offsetof(zil_bp_node_t, zn_node)); |
789 | 105 |
} |
106 |
||
107 |
static void |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
108 |
zil_bp_tree_fini(zilog_t *zilog) |
789 | 109 |
{ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
110 |
avl_tree_t *t = &zilog->zl_bp_tree; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
111 |
zil_bp_node_t *zn; |
789 | 112 |
void *cookie = NULL; |
113 |
||
114 |
while ((zn = avl_destroy_nodes(t, &cookie)) != NULL) |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
115 |
kmem_free(zn, sizeof (zil_bp_node_t)); |
789 | 116 |
|
117 |
avl_destroy(t); |
|
118 |
} |
|
119 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
120 |
int |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
121 |
zil_bp_tree_add(zilog_t *zilog, const blkptr_t *bp) |
789 | 122 |
{ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
123 |
avl_tree_t *t = &zilog->zl_bp_tree; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
124 |
const dva_t *dva = BP_IDENTITY(bp); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
125 |
zil_bp_node_t *zn; |
789 | 126 |
avl_index_t where; |
127 |
||
128 |
if (avl_find(t, dva, &where) != NULL) |
|
129 |
return (EEXIST); |
|
130 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
131 |
zn = kmem_alloc(sizeof (zil_bp_node_t), KM_SLEEP); |
789 | 132 |
zn->zn_dva = *dva; |
133 |
avl_insert(t, zn, where); |
|
134 |
||
135 |
return (0); |
|
136 |
} |
|
137 |
||
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
138 |
static zil_header_t * |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
139 |
zil_header_in_syncing_context(zilog_t *zilog) |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
140 |
{ |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
141 |
return ((zil_header_t *)zilog->zl_header); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
142 |
} |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
143 |
|
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
144 |
static void |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
145 |
zil_init_log_chain(zilog_t *zilog, blkptr_t *bp) |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
146 |
{ |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
147 |
zio_cksum_t *zc = &bp->blk_cksum; |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
148 |
|
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
149 |
zc->zc_word[ZIL_ZC_GUID_0] = spa_get_random(-1ULL); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
150 |
zc->zc_word[ZIL_ZC_GUID_1] = spa_get_random(-1ULL); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
151 |
zc->zc_word[ZIL_ZC_OBJSET] = dmu_objset_id(zilog->zl_os); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
152 |
zc->zc_word[ZIL_ZC_SEQ] = 1ULL; |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
153 |
} |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
154 |
|
789 | 155 |
/* |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
156 |
* Read a log block and make sure it's valid. |
789 | 157 |
*/ |
158 |
static int |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
159 |
zil_read_log_block(zilog_t *zilog, const blkptr_t *bp, blkptr_t *nbp, void *dst) |
789 | 160 |
{ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
161 |
enum zio_flag zio_flags = ZIO_FLAG_CANFAIL; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
162 |
uint32_t aflags = ARC_WAIT; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
163 |
arc_buf_t *abuf = NULL; |
1544 | 164 |
zbookmark_t zb; |
789 | 165 |
int error; |
166 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
167 |
if (zilog->zl_header->zh_claim_txg == 0) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
168 |
zio_flags |= ZIO_FLAG_SPECULATIVE | ZIO_FLAG_SCRUB; |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
169 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
170 |
if (!(zilog->zl_header->zh_flags & ZIL_CLAIM_LR_SEQ_VALID)) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
171 |
zio_flags |= ZIO_FLAG_SPECULATIVE; |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
172 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
173 |
SET_BOOKMARK(&zb, bp->blk_cksum.zc_word[ZIL_ZC_OBJSET], |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
174 |
ZB_ZIL_OBJECT, ZB_ZIL_LEVEL, bp->blk_cksum.zc_word[ZIL_ZC_SEQ]); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
175 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
176 |
error = arc_read_nolock(NULL, zilog->zl_spa, bp, arc_getbuf_func, &abuf, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
177 |
ZIO_PRIORITY_SYNC_READ, zio_flags, &aflags, &zb); |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
178 |
|
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
179 |
if (error == 0) { |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
180 |
char *data = abuf->b_data; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
181 |
uint64_t size = BP_GET_LSIZE(bp); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
182 |
zil_trailer_t *ztp = (zil_trailer_t *)(data + size) - 1; |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
183 |
zio_cksum_t cksum = bp->blk_cksum; |
1544 | 184 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
185 |
bcopy(data, dst, size); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
186 |
*nbp = ztp->zit_next_blk; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
187 |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
188 |
/* |
7522
555dd20e19cf
6744440 zloop/ztest fails: "zdb: can't open ztest: No such device or address"
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
7294
diff
changeset
|
189 |
* Validate the checksummed log block. |
555dd20e19cf
6744440 zloop/ztest fails: "zdb: can't open ztest: No such device or address"
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
7294
diff
changeset
|
190 |
* |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
191 |
* Sequence numbers should be... sequential. The checksum |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
192 |
* verifier for the next block should be bp's checksum plus 1. |
7522
555dd20e19cf
6744440 zloop/ztest fails: "zdb: can't open ztest: No such device or address"
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
7294
diff
changeset
|
193 |
* |
555dd20e19cf
6744440 zloop/ztest fails: "zdb: can't open ztest: No such device or address"
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
7294
diff
changeset
|
194 |
* Also check the log chain linkage and size used. |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
195 |
*/ |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
196 |
cksum.zc_word[ZIL_ZC_SEQ]++; |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
197 |
|
7522
555dd20e19cf
6744440 zloop/ztest fails: "zdb: can't open ztest: No such device or address"
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
7294
diff
changeset
|
198 |
if (bcmp(&cksum, &ztp->zit_next_blk.blk_cksum, |
555dd20e19cf
6744440 zloop/ztest fails: "zdb: can't open ztest: No such device or address"
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
7294
diff
changeset
|
199 |
sizeof (cksum)) || BP_IS_HOLE(&ztp->zit_next_blk) || |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
200 |
(ztp->zit_nused > (size - sizeof (zil_trailer_t)))) |
7522
555dd20e19cf
6744440 zloop/ztest fails: "zdb: can't open ztest: No such device or address"
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
7294
diff
changeset
|
201 |
error = ECKSUM; |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
202 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
203 |
VERIFY(arc_buf_remove_ref(abuf, &abuf) == 1); |
789 | 204 |
} |
205 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
206 |
return (error); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
207 |
} |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
208 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
209 |
/* |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
210 |
* Read a TX_WRITE log data block. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
211 |
*/ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
212 |
static int |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
213 |
zil_read_log_data(zilog_t *zilog, const lr_write_t *lr, void *wbuf) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
214 |
{ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
215 |
enum zio_flag zio_flags = ZIO_FLAG_CANFAIL; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
216 |
const blkptr_t *bp = &lr->lr_blkptr; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
217 |
uint32_t aflags = ARC_WAIT; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
218 |
arc_buf_t *abuf = NULL; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
219 |
zbookmark_t zb; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
220 |
int error; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
221 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
222 |
if (BP_IS_HOLE(bp)) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
223 |
if (wbuf != NULL) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
224 |
bzero(wbuf, MAX(BP_GET_LSIZE(bp), lr->lr_length)); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
225 |
return (0); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
226 |
} |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
227 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
228 |
if (zilog->zl_header->zh_claim_txg == 0) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
229 |
zio_flags |= ZIO_FLAG_SPECULATIVE | ZIO_FLAG_SCRUB; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
230 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
231 |
SET_BOOKMARK(&zb, dmu_objset_id(zilog->zl_os), lr->lr_foid, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
232 |
ZB_ZIL_LEVEL, lr->lr_offset / BP_GET_LSIZE(bp)); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
233 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
234 |
error = arc_read_nolock(NULL, zilog->zl_spa, bp, arc_getbuf_func, &abuf, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
235 |
ZIO_PRIORITY_SYNC_READ, zio_flags, &aflags, &zb); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
236 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
237 |
if (error == 0) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
238 |
if (wbuf != NULL) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
239 |
bcopy(abuf->b_data, wbuf, arc_buf_size(abuf)); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
240 |
(void) arc_buf_remove_ref(abuf, &abuf); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
241 |
} |
789 | 242 |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
243 |
return (error); |
789 | 244 |
} |
245 |
||
246 |
/* |
|
247 |
* Parse the intent log, and call parse_func for each valid record within. |
|
248 |
*/ |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
249 |
int |
789 | 250 |
zil_parse(zilog_t *zilog, zil_parse_blk_func_t *parse_blk_func, |
251 |
zil_parse_lr_func_t *parse_lr_func, void *arg, uint64_t txg) |
|
252 |
{ |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
253 |
const zil_header_t *zh = zilog->zl_header; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
254 |
boolean_t claimed = !!zh->zh_claim_txg; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
255 |
uint64_t claim_blk_seq = claimed ? zh->zh_claim_blk_seq : UINT64_MAX; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
256 |
uint64_t claim_lr_seq = claimed ? zh->zh_claim_lr_seq : UINT64_MAX; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
257 |
uint64_t max_blk_seq = 0; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
258 |
uint64_t max_lr_seq = 0; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
259 |
uint64_t blk_count = 0; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
260 |
uint64_t lr_count = 0; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
261 |
blkptr_t blk, next_blk; |
789 | 262 |
char *lrbuf, *lrp; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
263 |
int error = 0; |
789 | 264 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
265 |
/* |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
266 |
* Old logs didn't record the maximum zh_claim_lr_seq. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
267 |
*/ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
268 |
if (!(zh->zh_flags & ZIL_CLAIM_LR_SEQ_VALID)) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
269 |
claim_lr_seq = UINT64_MAX; |
789 | 270 |
|
271 |
/* |
|
272 |
* Starting at the block pointed to by zh_log we read the log chain. |
|
273 |
* For each block in the chain we strongly check that block to |
|
274 |
* ensure its validity. We stop when an invalid block is found. |
|
275 |
* For each block pointer in the chain we call parse_blk_func(). |
|
276 |
* For each record in each valid block we call parse_lr_func(). |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
277 |
* If the log has been claimed, stop if we encounter a sequence |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
278 |
* number greater than the highest claimed sequence number. |
789 | 279 |
*/ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
280 |
lrbuf = zio_buf_alloc(SPA_MAXBLOCKSIZE); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
281 |
zil_bp_tree_init(zilog); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
282 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
283 |
for (blk = zh->zh_log; !BP_IS_HOLE(&blk); blk = next_blk) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
284 |
zil_trailer_t *ztp = |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
285 |
(zil_trailer_t *)(lrbuf + BP_GET_LSIZE(&blk)) - 1; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
286 |
uint64_t blk_seq = blk.blk_cksum.zc_word[ZIL_ZC_SEQ]; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
287 |
int reclen; |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
288 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
289 |
if (blk_seq > claim_blk_seq) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
290 |
break; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
291 |
if ((error = parse_blk_func(zilog, &blk, arg, txg)) != 0) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
292 |
break; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
293 |
ASSERT(max_blk_seq < blk_seq); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
294 |
max_blk_seq = blk_seq; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
295 |
blk_count++; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
296 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
297 |
if (max_lr_seq == claim_lr_seq && max_blk_seq == claim_blk_seq) |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
298 |
break; |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
299 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
300 |
error = zil_read_log_block(zilog, &blk, &next_blk, lrbuf); |
789 | 301 |
if (error) |
302 |
break; |
|
303 |
||
304 |
for (lrp = lrbuf; lrp < lrbuf + ztp->zit_nused; lrp += reclen) { |
|
305 |
lr_t *lr = (lr_t *)lrp; |
|
306 |
reclen = lr->lrc_reclen; |
|
307 |
ASSERT3U(reclen, >=, sizeof (lr_t)); |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
308 |
if (lr->lrc_seq > claim_lr_seq) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
309 |
goto done; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
310 |
if ((error = parse_lr_func(zilog, lr, arg, txg)) != 0) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
311 |
goto done; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
312 |
ASSERT(max_lr_seq < lr->lrc_seq); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
313 |
max_lr_seq = lr->lrc_seq; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
314 |
lr_count++; |
789 | 315 |
} |
316 |
} |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
317 |
done: |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
318 |
zilog->zl_parse_error = error; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
319 |
zilog->zl_parse_blk_seq = max_blk_seq; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
320 |
zilog->zl_parse_lr_seq = max_lr_seq; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
321 |
zilog->zl_parse_blk_count = blk_count; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
322 |
zilog->zl_parse_lr_count = lr_count; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
323 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
324 |
ASSERT(!claimed || !(zh->zh_flags & ZIL_CLAIM_LR_SEQ_VALID) || |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
325 |
(max_blk_seq == claim_blk_seq && max_lr_seq == claim_lr_seq)); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
326 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
327 |
zil_bp_tree_fini(zilog); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
328 |
zio_buf_free(lrbuf, SPA_MAXBLOCKSIZE); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
329 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
330 |
return (error); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
331 |
} |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
332 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
333 |
static int |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
334 |
zil_claim_log_block(zilog_t *zilog, blkptr_t *bp, void *tx, uint64_t first_txg) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
335 |
{ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
336 |
/* |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
337 |
* Claim log block if not already committed and not already claimed. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
338 |
* If tx == NULL, just verify that the block is claimable. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
339 |
*/ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
340 |
if (bp->blk_birth < first_txg || zil_bp_tree_add(zilog, bp) != 0) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
341 |
return (0); |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
342 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
343 |
return (zio_wait(zio_claim(NULL, zilog->zl_spa, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
344 |
tx == NULL ? 0 : first_txg, bp, spa_claim_notify, NULL, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
345 |
ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE | ZIO_FLAG_SCRUB))); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
346 |
} |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
347 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
348 |
static int |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
349 |
zil_claim_log_record(zilog_t *zilog, lr_t *lrc, void *tx, uint64_t first_txg) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
350 |
{ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
351 |
lr_write_t *lr = (lr_write_t *)lrc; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
352 |
int error; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
353 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
354 |
if (lrc->lrc_txtype != TX_WRITE) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
355 |
return (0); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
356 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
357 |
/* |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
358 |
* If the block is not readable, don't claim it. This can happen |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
359 |
* in normal operation when a log block is written to disk before |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
360 |
* some of the dmu_sync() blocks it points to. In this case, the |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
361 |
* transaction cannot have been committed to anyone (we would have |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
362 |
* waited for all writes to be stable first), so it is semantically |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
363 |
* correct to declare this the end of the log. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
364 |
*/ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
365 |
if (lr->lr_blkptr.blk_birth >= first_txg && |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
366 |
(error = zil_read_log_data(zilog, lr, NULL)) != 0) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
367 |
return (error); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
368 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
369 |
return (zil_claim_log_block(zilog, &lr->lr_blkptr, tx, first_txg)); |
789 | 370 |
} |
371 |
||
372 |
/* ARGSUSED */ |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
373 |
static int |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
374 |
zil_free_log_block(zilog_t *zilog, blkptr_t *bp, void *tx, uint64_t claim_txg) |
789 | 375 |
{ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
376 |
zio_free_zil(zilog->zl_spa, dmu_tx_get_txg(tx), bp); |
789 | 377 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
378 |
return (0); |
789 | 379 |
} |
380 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
381 |
static int |
789 | 382 |
zil_free_log_record(zilog_t *zilog, lr_t *lrc, void *tx, uint64_t claim_txg) |
383 |
{ |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
384 |
lr_write_t *lr = (lr_write_t *)lrc; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
385 |
blkptr_t *bp = &lr->lr_blkptr; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
386 |
|
789 | 387 |
/* |
388 |
* If we previously claimed it, we need to free it. |
|
389 |
*/ |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
390 |
if (claim_txg != 0 && lrc->lrc_txtype == TX_WRITE && |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
391 |
bp->blk_birth >= claim_txg && zil_bp_tree_add(zilog, bp) == 0) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
392 |
zio_free(zilog->zl_spa, dmu_tx_get_txg(tx), bp); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
393 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
394 |
return (0); |
789 | 395 |
} |
396 |
||
397 |
/* |
|
398 |
* Create an on-disk intent log. |
|
399 |
*/ |
|
400 |
static void |
|
401 |
zil_create(zilog_t *zilog) |
|
402 |
{ |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
403 |
const zil_header_t *zh = zilog->zl_header; |
789 | 404 |
lwb_t *lwb; |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
405 |
uint64_t txg = 0; |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
406 |
dmu_tx_t *tx = NULL; |
789 | 407 |
blkptr_t blk; |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
408 |
int error = 0; |
789 | 409 |
|
410 |
/* |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
411 |
* Wait for any previous destroy to complete. |
789 | 412 |
*/ |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
413 |
txg_wait_synced(zilog->zl_dmu_pool, zilog->zl_destroy_txg); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
414 |
|
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
415 |
ASSERT(zh->zh_claim_txg == 0); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
416 |
ASSERT(zh->zh_replay_seq == 0); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
417 |
|
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
418 |
blk = zh->zh_log; |
789 | 419 |
|
420 |
/* |
|
8109
6147a1bdd359
6760048 assertion failed: !BP_SHOULD_BYTESWAP(bp)
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
7904
diff
changeset
|
421 |
* If we don't already have an initial log block or we have one |
6147a1bdd359
6760048 assertion failed: !BP_SHOULD_BYTESWAP(bp)
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
7904
diff
changeset
|
422 |
* but it's the wrong endianness then allocate one. |
789 | 423 |
*/ |
8109
6147a1bdd359
6760048 assertion failed: !BP_SHOULD_BYTESWAP(bp)
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
7904
diff
changeset
|
424 |
if (BP_IS_HOLE(&blk) || BP_SHOULD_BYTESWAP(&blk)) { |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
425 |
tx = dmu_tx_create(zilog->zl_os); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
426 |
VERIFY(dmu_tx_assign(tx, TXG_WAIT) == 0); |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
427 |
dsl_dataset_dirty(dmu_objset_ds(zilog->zl_os), tx); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
428 |
txg = dmu_tx_get_txg(tx); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
429 |
|
8109
6147a1bdd359
6760048 assertion failed: !BP_SHOULD_BYTESWAP(bp)
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
7904
diff
changeset
|
430 |
if (!BP_IS_HOLE(&blk)) { |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
431 |
zio_free_zil(zilog->zl_spa, txg, &blk); |
8109
6147a1bdd359
6760048 assertion failed: !BP_SHOULD_BYTESWAP(bp)
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
7904
diff
changeset
|
432 |
BP_ZERO(&blk); |
6147a1bdd359
6760048 assertion failed: !BP_SHOULD_BYTESWAP(bp)
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
7904
diff
changeset
|
433 |
} |
6147a1bdd359
6760048 assertion failed: !BP_SHOULD_BYTESWAP(bp)
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
7904
diff
changeset
|
434 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
435 |
error = zio_alloc_zil(zilog->zl_spa, txg, &blk, NULL, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
436 |
ZIL_MIN_BLKSZ, zilog->zl_logbias == ZFS_LOGBIAS_LATENCY); |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
437 |
|
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
438 |
if (error == 0) |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
439 |
zil_init_log_chain(zilog, &blk); |
1362
2b3ee2467364
6377670 zil_replay() does unnecessary txg_wait_synced(), slowing down mount
perrin
parents:
1141
diff
changeset
|
440 |
} |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
441 |
|
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
442 |
/* |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
443 |
* Allocate a log write buffer (lwb) for the first log block. |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
444 |
*/ |
789 | 445 |
if (error == 0) { |
446 |
lwb = kmem_cache_alloc(zil_lwb_cache, KM_SLEEP); |
|
447 |
lwb->lwb_zilog = zilog; |
|
448 |
lwb->lwb_blk = blk; |
|
449 |
lwb->lwb_nused = 0; |
|
450 |
lwb->lwb_sz = BP_GET_LSIZE(&lwb->lwb_blk); |
|
451 |
lwb->lwb_buf = zio_buf_alloc(lwb->lwb_sz); |
|
452 |
lwb->lwb_max_txg = txg; |
|
2237 | 453 |
lwb->lwb_zio = NULL; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
454 |
lwb->lwb_tx = NULL; |
2237 | 455 |
|
789 | 456 |
mutex_enter(&zilog->zl_lock); |
457 |
list_insert_tail(&zilog->zl_lwb_list, lwb); |
|
458 |
mutex_exit(&zilog->zl_lock); |
|
459 |
} |
|
460 |
||
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
461 |
/* |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
462 |
* If we just allocated the first log block, commit our transaction |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
463 |
* and wait for zil_sync() to stuff the block poiner into zh_log. |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
464 |
* (zh is part of the MOS, so we cannot modify it in open context.) |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
465 |
*/ |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
466 |
if (tx != NULL) { |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
467 |
dmu_tx_commit(tx); |
1362
2b3ee2467364
6377670 zil_replay() does unnecessary txg_wait_synced(), slowing down mount
perrin
parents:
1141
diff
changeset
|
468 |
txg_wait_synced(zilog->zl_dmu_pool, txg); |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
469 |
} |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
470 |
|
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
471 |
ASSERT(bcmp(&blk, &zh->zh_log, sizeof (blk)) == 0); |
789 | 472 |
} |
473 |
||
474 |
/* |
|
475 |
* In one tx, free all log blocks and clear the log header. |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
476 |
* If keep_first is set, then we're replaying a log with no content. |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
477 |
* We want to keep the first block, however, so that the first |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
478 |
* synchronous transaction doesn't require a txg_wait_synced() |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
479 |
* in zil_create(). We don't need to txg_wait_synced() here either |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
480 |
* when keep_first is set, because both zil_create() and zil_destroy() |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
481 |
* will wait for any in-progress destroys to complete. |
789 | 482 |
*/ |
483 |
void |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
484 |
zil_destroy(zilog_t *zilog, boolean_t keep_first) |
789 | 485 |
{ |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
486 |
const zil_header_t *zh = zilog->zl_header; |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
487 |
lwb_t *lwb; |
789 | 488 |
dmu_tx_t *tx; |
489 |
uint64_t txg; |
|
490 |
||
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
491 |
/* |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
492 |
* Wait for any previous destroy to complete. |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
493 |
*/ |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
494 |
txg_wait_synced(zilog->zl_dmu_pool, zilog->zl_destroy_txg); |
789 | 495 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
496 |
zilog->zl_old_header = *zh; /* debugging aid */ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
497 |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
498 |
if (BP_IS_HOLE(&zh->zh_log)) |
789 | 499 |
return; |
500 |
||
501 |
tx = dmu_tx_create(zilog->zl_os); |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
502 |
VERIFY(dmu_tx_assign(tx, TXG_WAIT) == 0); |
789 | 503 |
dsl_dataset_dirty(dmu_objset_ds(zilog->zl_os), tx); |
504 |
txg = dmu_tx_get_txg(tx); |
|
505 |
||
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
506 |
mutex_enter(&zilog->zl_lock); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
507 |
|
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
508 |
ASSERT3U(zilog->zl_destroy_txg, <, txg); |
789 | 509 |
zilog->zl_destroy_txg = txg; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
510 |
zilog->zl_keep_first = keep_first; |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
511 |
|
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
512 |
if (!list_is_empty(&zilog->zl_lwb_list)) { |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
513 |
ASSERT(zh->zh_claim_txg == 0); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
514 |
ASSERT(!keep_first); |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
515 |
while ((lwb = list_head(&zilog->zl_lwb_list)) != NULL) { |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
516 |
list_remove(&zilog->zl_lwb_list, lwb); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
517 |
if (lwb->lwb_buf != NULL) |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
518 |
zio_buf_free(lwb->lwb_buf, lwb->lwb_sz); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
519 |
zio_free_zil(zilog->zl_spa, txg, &lwb->lwb_blk); |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
520 |
kmem_cache_free(zil_lwb_cache, lwb); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
521 |
} |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
522 |
} else if (!keep_first) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
523 |
(void) zil_parse(zilog, zil_free_log_block, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
524 |
zil_free_log_record, tx, zh->zh_claim_txg); |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
525 |
} |
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
526 |
mutex_exit(&zilog->zl_lock); |
789 | 527 |
|
528 |
dmu_tx_commit(tx); |
|
529 |
} |
|
530 |
||
2199 | 531 |
int |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11066
diff
changeset
|
532 |
zil_claim(const char *osname, void *txarg) |
789 | 533 |
{ |
534 |
dmu_tx_t *tx = txarg; |
|
535 |
uint64_t first_txg = dmu_tx_get_txg(tx); |
|
536 |
zilog_t *zilog; |
|
537 |
zil_header_t *zh; |
|
538 |
objset_t *os; |
|
539 |
int error; |
|
540 |
||
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10209
diff
changeset
|
541 |
error = dmu_objset_hold(osname, FTAG, &os); |
789 | 542 |
if (error) { |
7294 | 543 |
cmn_err(CE_WARN, "can't open objset for %s", osname); |
2199 | 544 |
return (0); |
789 | 545 |
} |
546 |
||
547 |
zilog = dmu_objset_zil(os); |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
548 |
zh = zil_header_in_syncing_context(zilog); |
789 | 549 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
550 |
if (spa_get_log_state(zilog->zl_spa) == SPA_LOG_CLEAR) { |
9701
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
551 |
if (!BP_IS_HOLE(&zh->zh_log)) |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
552 |
zio_free_zil(zilog->zl_spa, first_txg, &zh->zh_log); |
9701
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
553 |
BP_ZERO(&zh->zh_log); |
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
554 |
dsl_dataset_dirty(dmu_objset_ds(os), tx); |
10921
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10879
diff
changeset
|
555 |
dmu_objset_rele(os, FTAG); |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
10879
diff
changeset
|
556 |
return (0); |
9701
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
557 |
} |
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
558 |
|
789 | 559 |
/* |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
560 |
* Claim all log blocks if we haven't already done so, and remember |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
561 |
* the highest claimed sequence number. This ensures that if we can |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
562 |
* read only part of the log now (e.g. due to a missing device), |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
563 |
* but we can read the entire log later, we will not try to replay |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
564 |
* or destroy beyond the last block we successfully claimed. |
789 | 565 |
*/ |
566 |
ASSERT3U(zh->zh_claim_txg, <=, first_txg); |
|
567 |
if (zh->zh_claim_txg == 0 && !BP_IS_HOLE(&zh->zh_log)) { |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
568 |
(void) zil_parse(zilog, zil_claim_log_block, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
569 |
zil_claim_log_record, tx, first_txg); |
789 | 570 |
zh->zh_claim_txg = first_txg; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
571 |
zh->zh_claim_blk_seq = zilog->zl_parse_blk_seq; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
572 |
zh->zh_claim_lr_seq = zilog->zl_parse_lr_seq; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
573 |
if (zilog->zl_parse_lr_count || zilog->zl_parse_blk_count > 1) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
574 |
zh->zh_flags |= ZIL_REPLAY_NEEDED; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
575 |
zh->zh_flags |= ZIL_CLAIM_LR_SEQ_VALID; |
789 | 576 |
dsl_dataset_dirty(dmu_objset_ds(os), tx); |
577 |
} |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
578 |
|
789 | 579 |
ASSERT3U(first_txg, ==, (spa_last_synced_txg(zilog->zl_spa) + 1)); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10209
diff
changeset
|
580 |
dmu_objset_rele(os, FTAG); |
2199 | 581 |
return (0); |
789 | 582 |
} |
583 |
||
7294 | 584 |
/* |
585 |
* Check the log by walking the log chain. |
|
586 |
* Checksum errors are ok as they indicate the end of the chain. |
|
587 |
* Any other error (no device or read failure) returns an error. |
|
588 |
*/ |
|
589 |
int |
|
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11066
diff
changeset
|
590 |
zil_check_log_chain(const char *osname, void *tx) |
7294 | 591 |
{ |
592 |
zilog_t *zilog; |
|
593 |
objset_t *os; |
|
594 |
int error; |
|
595 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
596 |
ASSERT(tx == NULL); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
597 |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10209
diff
changeset
|
598 |
error = dmu_objset_hold(osname, FTAG, &os); |
7294 | 599 |
if (error) { |
600 |
cmn_err(CE_WARN, "can't open objset for %s", osname); |
|
601 |
return (0); |
|
602 |
} |
|
603 |
||
604 |
zilog = dmu_objset_zil(os); |
|
605 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
606 |
/* |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
607 |
* Because tx == NULL, zil_claim_log_block() will not actually claim |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
608 |
* any blocks, but just determine whether it is possible to do so. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
609 |
* In addition to checking the log chain, zil_claim_log_block() |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
610 |
* will invoke zio_claim() with a done func of spa_claim_notify(), |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
611 |
* which will update spa_max_claim_txg. See spa_load() for details. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
612 |
*/ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
613 |
error = zil_parse(zilog, zil_claim_log_block, zil_claim_log_record, tx, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
614 |
zilog->zl_header->zh_claim_txg ? -1ULL : spa_first_txg(os->os_spa)); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
615 |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10209
diff
changeset
|
616 |
dmu_objset_rele(os, FTAG); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
617 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
618 |
return ((error == ECKSUM || error == ENOENT) ? 0 : error); |
7294 | 619 |
} |
620 |
||
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
621 |
static int |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
622 |
zil_vdev_compare(const void *x1, const void *x2) |
789 | 623 |
{ |
5875
599b7007a9cd
6653210 zil_vdev_compare() compares pointers instead of vdev ids
perrin
parents:
5809
diff
changeset
|
624 |
uint64_t v1 = ((zil_vdev_node_t *)x1)->zv_vdev; |
599b7007a9cd
6653210 zil_vdev_compare() compares pointers instead of vdev ids
perrin
parents:
5809
diff
changeset
|
625 |
uint64_t v2 = ((zil_vdev_node_t *)x2)->zv_vdev; |
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
626 |
|
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
627 |
if (v1 < v2) |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
628 |
return (-1); |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
629 |
if (v1 > v2) |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
630 |
return (1); |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
631 |
|
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
632 |
return (0); |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
633 |
} |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
634 |
|
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
635 |
void |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
636 |
zil_add_block(zilog_t *zilog, const blkptr_t *bp) |
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
637 |
{ |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
638 |
avl_tree_t *t = &zilog->zl_vdev_tree; |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
639 |
avl_index_t where; |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
640 |
zil_vdev_node_t *zv, zvsearch; |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
641 |
int ndvas = BP_GET_NDVAS(bp); |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
642 |
int i; |
789 | 643 |
|
2986 | 644 |
if (zfs_nocacheflush) |
789 | 645 |
return; |
646 |
||
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
647 |
ASSERT(zilog->zl_writer); |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
648 |
|
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
649 |
/* |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
650 |
* Even though we're zl_writer, we still need a lock because the |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
651 |
* zl_get_data() callbacks may have dmu_sync() done callbacks |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
652 |
* that will run concurrently. |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
653 |
*/ |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
654 |
mutex_enter(&zilog->zl_vdev_lock); |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
655 |
for (i = 0; i < ndvas; i++) { |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
656 |
zvsearch.zv_vdev = DVA_GET_VDEV(&bp->blk_dva[i]); |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
657 |
if (avl_find(t, &zvsearch, &where) == NULL) { |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
658 |
zv = kmem_alloc(sizeof (*zv), KM_SLEEP); |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
659 |
zv->zv_vdev = zvsearch.zv_vdev; |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
660 |
avl_insert(t, zv, where); |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
661 |
} |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
662 |
} |
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
663 |
mutex_exit(&zilog->zl_vdev_lock); |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
664 |
} |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
665 |
|
789 | 666 |
void |
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
667 |
zil_flush_vdevs(zilog_t *zilog) |
789 | 668 |
{ |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
669 |
spa_t *spa = zilog->zl_spa; |
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
670 |
avl_tree_t *t = &zilog->zl_vdev_tree; |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
671 |
void *cookie = NULL; |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
672 |
zil_vdev_node_t *zv; |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
673 |
zio_t *zio; |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
674 |
|
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
675 |
ASSERT(zilog->zl_writer); |
789 | 676 |
|
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
677 |
/* |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
678 |
* We don't need zl_vdev_lock here because we're the zl_writer, |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
679 |
* and all zl_get_data() callbacks are done. |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
680 |
*/ |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
681 |
if (avl_numnodes(t) == 0) |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
682 |
return; |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
683 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7638
diff
changeset
|
684 |
spa_config_enter(spa, SCL_STATE, FTAG, RW_READER); |
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
685 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7638
diff
changeset
|
686 |
zio = zio_root(spa, NULL, NULL, ZIO_FLAG_CANFAIL); |
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
687 |
|
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
688 |
while ((zv = avl_destroy_nodes(t, &cookie)) != NULL) { |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
689 |
vdev_t *vd = vdev_lookup_top(spa, zv->zv_vdev); |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
690 |
if (vd != NULL) |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
691 |
zio_flush(zio, vd); |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
692 |
kmem_free(zv, sizeof (*zv)); |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
693 |
} |
789 | 694 |
|
695 |
/* |
|
696 |
* Wait for all the flushes to complete. Not all devices actually |
|
697 |
* support the DKIOCFLUSHWRITECACHE ioctl, so it's OK if it fails. |
|
698 |
*/ |
|
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
699 |
(void) zio_wait(zio); |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
700 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7638
diff
changeset
|
701 |
spa_config_exit(spa, SCL_STATE, FTAG); |
789 | 702 |
} |
703 |
||
704 |
/* |
|
705 |
* Function called when a log block write completes |
|
706 |
*/ |
|
707 |
static void |
|
708 |
zil_lwb_write_done(zio_t *zio) |
|
709 |
{ |
|
710 |
lwb_t *lwb = zio->io_private; |
|
711 |
zilog_t *zilog = lwb->lwb_zilog; |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
712 |
dmu_tx_t *tx = lwb->lwb_tx; |
789 | 713 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7638
diff
changeset
|
714 |
ASSERT(BP_GET_COMPRESS(zio->io_bp) == ZIO_COMPRESS_OFF); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7638
diff
changeset
|
715 |
ASSERT(BP_GET_CHECKSUM(zio->io_bp) == ZIO_CHECKSUM_ZILOG); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7638
diff
changeset
|
716 |
ASSERT(BP_GET_TYPE(zio->io_bp) == DMU_OT_INTENT_LOG); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7638
diff
changeset
|
717 |
ASSERT(BP_GET_LEVEL(zio->io_bp) == 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7638
diff
changeset
|
718 |
ASSERT(BP_GET_BYTEORDER(zio->io_bp) == ZFS_HOST_BYTEORDER); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7638
diff
changeset
|
719 |
ASSERT(!BP_IS_GANG(zio->io_bp)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7638
diff
changeset
|
720 |
ASSERT(!BP_IS_HOLE(zio->io_bp)); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7638
diff
changeset
|
721 |
ASSERT(zio->io_bp->blk_fill == 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7638
diff
changeset
|
722 |
|
789 | 723 |
/* |
9493
9933d599bc93
6623978 lwb->lwb_buf != NULL, file ../../../uts/common/fs/zfs/zil.c, line 787, function zil_lwb_commit
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
9396
diff
changeset
|
724 |
* Ensure the lwb buffer pointer is cleared before releasing |
9933d599bc93
6623978 lwb->lwb_buf != NULL, file ../../../uts/common/fs/zfs/zil.c, line 787, function zil_lwb_commit
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
9396
diff
changeset
|
725 |
* the txg. If we have had an allocation failure and |
9933d599bc93
6623978 lwb->lwb_buf != NULL, file ../../../uts/common/fs/zfs/zil.c, line 787, function zil_lwb_commit
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
9396
diff
changeset
|
726 |
* the txg is waiting to sync then we want want zil_sync() |
9933d599bc93
6623978 lwb->lwb_buf != NULL, file ../../../uts/common/fs/zfs/zil.c, line 787, function zil_lwb_commit
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
9396
diff
changeset
|
727 |
* to remove the lwb so that it's not picked up as the next new |
9933d599bc93
6623978 lwb->lwb_buf != NULL, file ../../../uts/common/fs/zfs/zil.c, line 787, function zil_lwb_commit
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
9396
diff
changeset
|
728 |
* one in zil_commit_writer(). zil_sync() will only remove |
9933d599bc93
6623978 lwb->lwb_buf != NULL, file ../../../uts/common/fs/zfs/zil.c, line 787, function zil_lwb_commit
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
9396
diff
changeset
|
729 |
* the lwb if lwb_buf is null. |
789 | 730 |
*/ |
731 |
zio_buf_free(lwb->lwb_buf, lwb->lwb_sz); |
|
732 |
mutex_enter(&zilog->zl_lock); |
|
733 |
lwb->lwb_buf = NULL; |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
734 |
lwb->lwb_tx = NULL; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
735 |
mutex_exit(&zilog->zl_lock); |
9493
9933d599bc93
6623978 lwb->lwb_buf != NULL, file ../../../uts/common/fs/zfs/zil.c, line 787, function zil_lwb_commit
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
9396
diff
changeset
|
736 |
|
9933d599bc93
6623978 lwb->lwb_buf != NULL, file ../../../uts/common/fs/zfs/zil.c, line 787, function zil_lwb_commit
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
9396
diff
changeset
|
737 |
/* |
9933d599bc93
6623978 lwb->lwb_buf != NULL, file ../../../uts/common/fs/zfs/zil.c, line 787, function zil_lwb_commit
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
9396
diff
changeset
|
738 |
* Now that we've written this log block, we have a stable pointer |
9933d599bc93
6623978 lwb->lwb_buf != NULL, file ../../../uts/common/fs/zfs/zil.c, line 787, function zil_lwb_commit
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
9396
diff
changeset
|
739 |
* to the next block in the chain, so it's OK to let the txg in |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
740 |
* which we allocated the next block sync. |
9493
9933d599bc93
6623978 lwb->lwb_buf != NULL, file ../../../uts/common/fs/zfs/zil.c, line 787, function zil_lwb_commit
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
9396
diff
changeset
|
741 |
*/ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
742 |
dmu_tx_commit(tx); |
789 | 743 |
} |
744 |
||
745 |
/* |
|
2237 | 746 |
* Initialize the io for a log block. |
747 |
*/ |
|
748 |
static void |
|
749 |
zil_lwb_write_init(zilog_t *zilog, lwb_t *lwb) |
|
750 |
{ |
|
751 |
zbookmark_t zb; |
|
752 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
753 |
SET_BOOKMARK(&zb, lwb->lwb_blk.blk_cksum.zc_word[ZIL_ZC_OBJSET], |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
754 |
ZB_ZIL_OBJECT, ZB_ZIL_LEVEL, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
755 |
lwb->lwb_blk.blk_cksum.zc_word[ZIL_ZC_SEQ]); |
2237 | 756 |
|
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
757 |
if (zilog->zl_root_zio == NULL) { |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
758 |
zilog->zl_root_zio = zio_root(zilog->zl_spa, NULL, NULL, |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
759 |
ZIO_FLAG_CANFAIL); |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
760 |
} |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
761 |
if (lwb->lwb_zio == NULL) { |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
762 |
lwb->lwb_zio = zio_rewrite(zilog->zl_root_zio, zilog->zl_spa, |
9701
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
763 |
0, &lwb->lwb_blk, lwb->lwb_buf, lwb->lwb_sz, |
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
764 |
zil_lwb_write_done, lwb, ZIO_PRIORITY_LOG_WRITE, |
10685
931790026ac6
6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents:
10310
diff
changeset
|
765 |
ZIO_FLAG_CANFAIL | ZIO_FLAG_DONT_PROPAGATE, &zb); |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
766 |
} |
2237 | 767 |
} |
768 |
||
769 |
/* |
|
10879
420834d9266b
6849167 40% write regression with multiple shares
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10800
diff
changeset
|
770 |
* Use the slog as long as the logbias is 'latency' and the current commit size |
420834d9266b
6849167 40% write regression with multiple shares
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10800
diff
changeset
|
771 |
* is less than the limit or the total list size is less than 2X the limit. |
420834d9266b
6849167 40% write regression with multiple shares
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10800
diff
changeset
|
772 |
* Limit checking is disabled by setting zil_slog_limit to UINT64_MAX. |
420834d9266b
6849167 40% write regression with multiple shares
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10800
diff
changeset
|
773 |
*/ |
420834d9266b
6849167 40% write regression with multiple shares
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10800
diff
changeset
|
774 |
uint64_t zil_slog_limit = 1024 * 1024; |
420834d9266b
6849167 40% write regression with multiple shares
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10800
diff
changeset
|
775 |
#define USE_SLOG(zilog) (((zilog)->zl_logbias == ZFS_LOGBIAS_LATENCY) && \ |
420834d9266b
6849167 40% write regression with multiple shares
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10800
diff
changeset
|
776 |
(((zilog)->zl_cur_used < zil_slog_limit) || \ |
420834d9266b
6849167 40% write regression with multiple shares
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10800
diff
changeset
|
777 |
((zilog)->zl_itx_list_sz < (zil_slog_limit << 1)))) |
420834d9266b
6849167 40% write regression with multiple shares
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10800
diff
changeset
|
778 |
|
420834d9266b
6849167 40% write regression with multiple shares
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10800
diff
changeset
|
779 |
/* |
789 | 780 |
* Start a log block write and advance to the next log block. |
781 |
* Calls are serialized. |
|
782 |
*/ |
|
783 |
static lwb_t * |
|
784 |
zil_lwb_write_start(zilog_t *zilog, lwb_t *lwb) |
|
785 |
{ |
|
786 |
lwb_t *nlwb; |
|
787 |
zil_trailer_t *ztp = (zil_trailer_t *)(lwb->lwb_buf + lwb->lwb_sz) - 1; |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
788 |
spa_t *spa = zilog->zl_spa; |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
789 |
blkptr_t *bp = &ztp->zit_next_blk; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
790 |
dmu_tx_t *tx; |
789 | 791 |
uint64_t txg; |
792 |
uint64_t zil_blksz; |
|
793 |
int error; |
|
794 |
||
795 |
ASSERT(lwb->lwb_nused <= ZIL_BLK_DATA_SZ(lwb)); |
|
796 |
||
797 |
/* |
|
798 |
* Allocate the next block and save its address in this block |
|
799 |
* before writing it in order to establish the log chain. |
|
800 |
* Note that if the allocation of nlwb synced before we wrote |
|
801 |
* the block that points at it (lwb), we'd leak it if we crashed. |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
802 |
* Therefore, we don't do dmu_tx_commit() until zil_lwb_write_done(). |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
803 |
* We dirty the dataset to ensure that zil_sync() will be called |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
804 |
* to clean up in the event of allocation failure or I/O failure. |
789 | 805 |
*/ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
806 |
tx = dmu_tx_create(zilog->zl_os); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
807 |
VERIFY(dmu_tx_assign(tx, TXG_WAIT) == 0); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
808 |
dsl_dataset_dirty(dmu_objset_ds(zilog->zl_os), tx); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
809 |
txg = dmu_tx_get_txg(tx); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
810 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
811 |
lwb->lwb_tx = tx; |
789 | 812 |
|
813 |
/* |
|
1141 | 814 |
* Pick a ZIL blocksize. We request a size that is the |
815 |
* maximum of the previous used size, the current used size and |
|
816 |
* the amount waiting in the queue. |
|
789 | 817 |
*/ |
2237 | 818 |
zil_blksz = MAX(zilog->zl_prev_used, |
819 |
zilog->zl_cur_used + sizeof (*ztp)); |
|
1141 | 820 |
zil_blksz = MAX(zil_blksz, zilog->zl_itx_list_sz + sizeof (*ztp)); |
1842
1712a484fc9d
6413731 pathologically slower fsync on 32 bit systems
perrin
parents:
1807
diff
changeset
|
821 |
zil_blksz = P2ROUNDUP_TYPED(zil_blksz, ZIL_MIN_BLKSZ, uint64_t); |
1141 | 822 |
if (zil_blksz > ZIL_MAX_BLKSZ) |
823 |
zil_blksz = ZIL_MAX_BLKSZ; |
|
789 | 824 |
|
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
825 |
BP_ZERO(bp); |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
826 |
/* pass the old blkptr in order to spread log blocks across devs */ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
827 |
error = zio_alloc_zil(spa, txg, bp, &lwb->lwb_blk, zil_blksz, |
10879
420834d9266b
6849167 40% write regression with multiple shares
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10800
diff
changeset
|
828 |
USE_SLOG(zilog)); |
789 | 829 |
if (error) { |
1544 | 830 |
/* |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
831 |
* Since we've just experienced an allocation failure, |
3668 | 832 |
* terminate the current lwb and send it on its way. |
833 |
*/ |
|
834 |
ztp->zit_pad = 0; |
|
835 |
ztp->zit_nused = lwb->lwb_nused; |
|
836 |
ztp->zit_bt.zbt_cksum = lwb->lwb_blk.blk_cksum; |
|
837 |
zio_nowait(lwb->lwb_zio); |
|
838 |
||
839 |
/* |
|
1544 | 840 |
* By returning NULL the caller will call tx_wait_synced() |
841 |
*/ |
|
789 | 842 |
return (NULL); |
843 |
} |
|
844 |
||
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
845 |
ASSERT3U(bp->blk_birth, ==, txg); |
1544 | 846 |
ztp->zit_pad = 0; |
789 | 847 |
ztp->zit_nused = lwb->lwb_nused; |
848 |
ztp->zit_bt.zbt_cksum = lwb->lwb_blk.blk_cksum; |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
849 |
bp->blk_cksum = lwb->lwb_blk.blk_cksum; |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
850 |
bp->blk_cksum.zc_word[ZIL_ZC_SEQ]++; |
789 | 851 |
|
852 |
/* |
|
853 |
* Allocate a new log write buffer (lwb). |
|
854 |
*/ |
|
855 |
nlwb = kmem_cache_alloc(zil_lwb_cache, KM_SLEEP); |
|
856 |
nlwb->lwb_zilog = zilog; |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
857 |
nlwb->lwb_blk = *bp; |
789 | 858 |
nlwb->lwb_nused = 0; |
859 |
nlwb->lwb_sz = BP_GET_LSIZE(&nlwb->lwb_blk); |
|
860 |
nlwb->lwb_buf = zio_buf_alloc(nlwb->lwb_sz); |
|
861 |
nlwb->lwb_max_txg = txg; |
|
2237 | 862 |
nlwb->lwb_zio = NULL; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
863 |
nlwb->lwb_tx = NULL; |
789 | 864 |
|
865 |
/* |
|
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
866 |
* Put new lwb at the end of the log chain |
789 | 867 |
*/ |
868 |
mutex_enter(&zilog->zl_lock); |
|
869 |
list_insert_tail(&zilog->zl_lwb_list, nlwb); |
|
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
870 |
mutex_exit(&zilog->zl_lock); |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
871 |
|
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
872 |
/* Record the block for later vdev flushing */ |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
873 |
zil_add_block(zilog, &lwb->lwb_blk); |
789 | 874 |
|
875 |
/* |
|
2237 | 876 |
* kick off the write for the old log block |
789 | 877 |
*/ |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
878 |
ASSERT(lwb->lwb_zio); |
2237 | 879 |
zio_nowait(lwb->lwb_zio); |
789 | 880 |
|
881 |
return (nlwb); |
|
882 |
} |
|
883 |
||
884 |
static lwb_t * |
|
885 |
zil_lwb_commit(zilog_t *zilog, itx_t *itx, lwb_t *lwb) |
|
886 |
{ |
|
887 |
lr_t *lrc = &itx->itx_lr; /* common log record */ |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
888 |
lr_write_t *lrw = (lr_write_t *)lrc; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
889 |
char *lr_buf; |
789 | 890 |
uint64_t txg = lrc->lrc_txg; |
891 |
uint64_t reclen = lrc->lrc_reclen; |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
892 |
uint64_t dlen = 0; |
789 | 893 |
|
894 |
if (lwb == NULL) |
|
895 |
return (NULL); |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
896 |
|
789 | 897 |
ASSERT(lwb->lwb_buf != NULL); |
898 |
||
2237 | 899 |
if (lrc->lrc_txtype == TX_WRITE && itx->itx_wr_state == WR_NEED_COPY) |
900 |
dlen = P2ROUNDUP_TYPED( |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
901 |
lrw->lr_length, sizeof (uint64_t), uint64_t); |
1669 | 902 |
|
903 |
zilog->zl_cur_used += (reclen + dlen); |
|
904 |
||
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
905 |
zil_lwb_write_init(zilog, lwb); |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
906 |
|
1669 | 907 |
/* |
908 |
* If this record won't fit in the current log block, start a new one. |
|
909 |
*/ |
|
910 |
if (lwb->lwb_nused + reclen + dlen > ZIL_BLK_DATA_SZ(lwb)) { |
|
911 |
lwb = zil_lwb_write_start(zilog, lwb); |
|
2237 | 912 |
if (lwb == NULL) |
1669 | 913 |
return (NULL); |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
914 |
zil_lwb_write_init(zilog, lwb); |
1669 | 915 |
ASSERT(lwb->lwb_nused == 0); |
916 |
if (reclen + dlen > ZIL_BLK_DATA_SZ(lwb)) { |
|
917 |
txg_wait_synced(zilog->zl_dmu_pool, txg); |
|
789 | 918 |
return (lwb); |
919 |
} |
|
920 |
} |
|
921 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
922 |
lr_buf = lwb->lwb_buf + lwb->lwb_nused; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
923 |
bcopy(lrc, lr_buf, reclen); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
924 |
lrc = (lr_t *)lr_buf; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
925 |
lrw = (lr_write_t *)lrc; |
2237 | 926 |
|
927 |
/* |
|
928 |
* If it's a write, fetch the data or get its blkptr as appropriate. |
|
929 |
*/ |
|
930 |
if (lrc->lrc_txtype == TX_WRITE) { |
|
931 |
if (txg > spa_freeze_txg(zilog->zl_spa)) |
|
932 |
txg_wait_synced(zilog->zl_dmu_pool, txg); |
|
933 |
if (itx->itx_wr_state != WR_COPIED) { |
|
934 |
char *dbuf; |
|
935 |
int error; |
|
936 |
||
937 |
if (dlen) { |
|
938 |
ASSERT(itx->itx_wr_state == WR_NEED_COPY); |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
939 |
dbuf = lr_buf + reclen; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
940 |
lrw->lr_common.lrc_reclen += dlen; |
2237 | 941 |
} else { |
942 |
ASSERT(itx->itx_wr_state == WR_INDIRECT); |
|
943 |
dbuf = NULL; |
|
944 |
} |
|
945 |
error = zilog->zl_get_data( |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
946 |
itx->itx_private, lrw, dbuf, lwb->lwb_zio); |
10209
91f47f0e7728
6830541 zfs_get_data trips on a verify
Mark J Musante <Mark.Musante@Sun.COM>
parents:
9904
diff
changeset
|
947 |
if (error == EIO) { |
91f47f0e7728
6830541 zfs_get_data trips on a verify
Mark J Musante <Mark.Musante@Sun.COM>
parents:
9904
diff
changeset
|
948 |
txg_wait_synced(zilog->zl_dmu_pool, txg); |
91f47f0e7728
6830541 zfs_get_data trips on a verify
Mark J Musante <Mark.Musante@Sun.COM>
parents:
9904
diff
changeset
|
949 |
return (lwb); |
91f47f0e7728
6830541 zfs_get_data trips on a verify
Mark J Musante <Mark.Musante@Sun.COM>
parents:
9904
diff
changeset
|
950 |
} |
2237 | 951 |
if (error) { |
952 |
ASSERT(error == ENOENT || error == EEXIST || |
|
953 |
error == EALREADY); |
|
954 |
return (lwb); |
|
955 |
} |
|
956 |
} |
|
1669 | 957 |
} |
2237 | 958 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
959 |
/* |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
960 |
* We're actually making an entry, so update lrc_seq to be the |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
961 |
* log record sequence number. Note that this is generally not |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
962 |
* equal to the itx sequence number because not all transactions |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
963 |
* are synchronous, and sometimes spa_sync() gets there first. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
964 |
*/ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
965 |
lrc->lrc_seq = ++zilog->zl_lr_seq; /* we are single threaded */ |
2237 | 966 |
lwb->lwb_nused += reclen + dlen; |
789 | 967 |
lwb->lwb_max_txg = MAX(lwb->lwb_max_txg, txg); |
968 |
ASSERT3U(lwb->lwb_nused, <=, ZIL_BLK_DATA_SZ(lwb)); |
|
969 |
ASSERT3U(P2PHASE(lwb->lwb_nused, sizeof (uint64_t)), ==, 0); |
|
970 |
||
971 |
return (lwb); |
|
972 |
} |
|
973 |
||
974 |
itx_t * |
|
5331 | 975 |
zil_itx_create(uint64_t txtype, size_t lrsize) |
789 | 976 |
{ |
977 |
itx_t *itx; |
|
978 |
||
1842
1712a484fc9d
6413731 pathologically slower fsync on 32 bit systems
perrin
parents:
1807
diff
changeset
|
979 |
lrsize = P2ROUNDUP_TYPED(lrsize, sizeof (uint64_t), size_t); |
789 | 980 |
|
981 |
itx = kmem_alloc(offsetof(itx_t, itx_lr) + lrsize, KM_SLEEP); |
|
982 |
itx->itx_lr.lrc_txtype = txtype; |
|
983 |
itx->itx_lr.lrc_reclen = lrsize; |
|
6101
915df4cedbc9
6658511 zl_itx_list_sz incorrect for WR_NEED_COPY writes
perrin
parents:
5913
diff
changeset
|
984 |
itx->itx_sod = lrsize; /* if write & WR_NEED_COPY will be increased */ |
789 | 985 |
itx->itx_lr.lrc_seq = 0; /* defensive */ |
986 |
||
987 |
return (itx); |
|
988 |
} |
|
989 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
990 |
void |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
991 |
zil_itx_destroy(itx_t *itx) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
992 |
{ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
993 |
kmem_free(itx, offsetof(itx_t, itx_lr) + itx->itx_lr.lrc_reclen); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
994 |
} |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
995 |
|
789 | 996 |
uint64_t |
997 |
zil_itx_assign(zilog_t *zilog, itx_t *itx, dmu_tx_t *tx) |
|
998 |
{ |
|
999 |
uint64_t seq; |
|
1000 |
||
1001 |
ASSERT(itx->itx_lr.lrc_seq == 0); |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1002 |
ASSERT(!zilog->zl_replay); |
789 | 1003 |
|
1004 |
mutex_enter(&zilog->zl_lock); |
|
1005 |
list_insert_tail(&zilog->zl_itx_list, itx); |
|
6101
915df4cedbc9
6658511 zl_itx_list_sz incorrect for WR_NEED_COPY writes
perrin
parents:
5913
diff
changeset
|
1006 |
zilog->zl_itx_list_sz += itx->itx_sod; |
789 | 1007 |
itx->itx_lr.lrc_txg = dmu_tx_get_txg(tx); |
1008 |
itx->itx_lr.lrc_seq = seq = ++zilog->zl_itx_seq; |
|
1009 |
mutex_exit(&zilog->zl_lock); |
|
1010 |
||
1011 |
return (seq); |
|
1012 |
} |
|
1013 |
||
1014 |
/* |
|
1015 |
* Free up all in-memory intent log transactions that have now been synced. |
|
1016 |
*/ |
|
1017 |
static void |
|
1018 |
zil_itx_clean(zilog_t *zilog) |
|
1019 |
{ |
|
1020 |
uint64_t synced_txg = spa_last_synced_txg(zilog->zl_spa); |
|
1021 |
uint64_t freeze_txg = spa_freeze_txg(zilog->zl_spa); |
|
3778 | 1022 |
list_t clean_list; |
789 | 1023 |
itx_t *itx; |
1024 |
||
3778 | 1025 |
list_create(&clean_list, sizeof (itx_t), offsetof(itx_t, itx_node)); |
1026 |
||
789 | 1027 |
mutex_enter(&zilog->zl_lock); |
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1028 |
/* wait for a log writer to finish walking list */ |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1029 |
while (zilog->zl_writer) { |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1030 |
cv_wait(&zilog->zl_cv_writer, &zilog->zl_lock); |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1031 |
} |
3778 | 1032 |
|
1033 |
/* |
|
1034 |
* Move the sync'd log transactions to a separate list so we can call |
|
1035 |
* kmem_free without holding the zl_lock. |
|
1036 |
* |
|
1037 |
* There is no need to set zl_writer as we don't drop zl_lock here |
|
1038 |
*/ |
|
789 | 1039 |
while ((itx = list_head(&zilog->zl_itx_list)) != NULL && |
1040 |
itx->itx_lr.lrc_txg <= MIN(synced_txg, freeze_txg)) { |
|
1041 |
list_remove(&zilog->zl_itx_list, itx); |
|
6101
915df4cedbc9
6658511 zl_itx_list_sz incorrect for WR_NEED_COPY writes
perrin
parents:
5913
diff
changeset
|
1042 |
zilog->zl_itx_list_sz -= itx->itx_sod; |
3778 | 1043 |
list_insert_tail(&clean_list, itx); |
1044 |
} |
|
1045 |
cv_broadcast(&zilog->zl_cv_writer); |
|
1046 |
mutex_exit(&zilog->zl_lock); |
|
1047 |
||
1048 |
/* destroy sync'd log transactions */ |
|
1049 |
while ((itx = list_head(&clean_list)) != NULL) { |
|
1050 |
list_remove(&clean_list, itx); |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1051 |
zil_itx_destroy(itx); |
789 | 1052 |
} |
3778 | 1053 |
list_destroy(&clean_list); |
789 | 1054 |
} |
1055 |
||
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1056 |
/* |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1057 |
* If there are any in-memory intent log transactions which have now been |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1058 |
* synced then start up a taskq to free them. |
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1059 |
*/ |
789 | 1060 |
void |
1061 |
zil_clean(zilog_t *zilog) |
|
1062 |
{ |
|
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1063 |
itx_t *itx; |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1064 |
|
789 | 1065 |
mutex_enter(&zilog->zl_lock); |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1066 |
itx = list_head(&zilog->zl_itx_list); |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1067 |
if ((itx != NULL) && |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1068 |
(itx->itx_lr.lrc_txg <= spa_last_synced_txg(zilog->zl_spa))) { |
789 | 1069 |
(void) taskq_dispatch(zilog->zl_clean_taskq, |
10879
420834d9266b
6849167 40% write regression with multiple shares
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10800
diff
changeset
|
1070 |
(task_func_t *)zil_itx_clean, zilog, TQ_NOSLEEP); |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1071 |
} |
789 | 1072 |
mutex_exit(&zilog->zl_lock); |
1073 |
} |
|
1074 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7638
diff
changeset
|
1075 |
static void |
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1076 |
zil_commit_writer(zilog_t *zilog, uint64_t seq, uint64_t foid) |
789 | 1077 |
{ |
1078 |
uint64_t txg; |
|
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1079 |
uint64_t commit_seq = 0; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1080 |
itx_t *itx, *itx_next; |
789 | 1081 |
lwb_t *lwb; |
1082 |
spa_t *spa; |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1083 |
int error = 0; |
789 | 1084 |
|
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1085 |
zilog->zl_writer = B_TRUE; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7638
diff
changeset
|
1086 |
ASSERT(zilog->zl_root_zio == NULL); |
789 | 1087 |
spa = zilog->zl_spa; |
1088 |
||
1089 |
if (zilog->zl_suspend) { |
|
1090 |
lwb = NULL; |
|
1091 |
} else { |
|
1092 |
lwb = list_tail(&zilog->zl_lwb_list); |
|
1093 |
if (lwb == NULL) { |
|
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1094 |
/* |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1095 |
* Return if there's nothing to flush before we |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1096 |
* dirty the fs by calling zil_create() |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1097 |
*/ |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1098 |
if (list_is_empty(&zilog->zl_itx_list)) { |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1099 |
zilog->zl_writer = B_FALSE; |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1100 |
return; |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1101 |
} |
789 | 1102 |
mutex_exit(&zilog->zl_lock); |
1103 |
zil_create(zilog); |
|
1104 |
mutex_enter(&zilog->zl_lock); |
|
1105 |
lwb = list_tail(&zilog->zl_lwb_list); |
|
1106 |
} |
|
1107 |
} |
|
1108 |
||
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1109 |
/* Loop through in-memory log transactions filling log blocks. */ |
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1110 |
DTRACE_PROBE1(zil__cw1, zilog_t *, zilog); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1111 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1112 |
for (itx = list_head(&zilog->zl_itx_list); itx; itx = itx_next) { |
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1113 |
/* |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1114 |
* Save the next pointer. Even though we drop zl_lock below, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1115 |
* all threads that can remove itx list entries (other writers |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1116 |
* and zil_itx_clean()) can't do so until they have zl_writer. |
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1117 |
*/ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1118 |
itx_next = list_next(&zilog->zl_itx_list, itx); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1119 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1120 |
/* |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1121 |
* Determine whether to push this itx. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1122 |
* Push all transactions related to specified foid and |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1123 |
* all other transactions except those that can be logged |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1124 |
* out of order (TX_WRITE, TX_TRUNCATE, TX_SETATTR, TX_ACL) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1125 |
* for all other files. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1126 |
* |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1127 |
* If foid == 0 (meaning "push all foids") or |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1128 |
* itx->itx_sync is set (meaning O_[D]SYNC), push regardless. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1129 |
*/ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1130 |
if (foid != 0 && !itx->itx_sync && |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1131 |
TX_OOO(itx->itx_lr.lrc_txtype) && |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1132 |
((lr_ooo_t *)&itx->itx_lr)->lr_foid != foid) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1133 |
continue; /* skip this record */ |
789 | 1134 |
|
1135 |
if ((itx->itx_lr.lrc_seq > seq) && |
|
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1136 |
((lwb == NULL) || (lwb->lwb_nused == 0) || |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1137 |
(lwb->lwb_nused + itx->itx_sod > ZIL_BLK_DATA_SZ(lwb)))) |
789 | 1138 |
break; |
1139 |
||
1140 |
list_remove(&zilog->zl_itx_list, itx); |
|
6101
915df4cedbc9
6658511 zl_itx_list_sz incorrect for WR_NEED_COPY writes
perrin
parents:
5913
diff
changeset
|
1141 |
zilog->zl_itx_list_sz -= itx->itx_sod; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1142 |
|
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1143 |
mutex_exit(&zilog->zl_lock); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1144 |
|
789 | 1145 |
txg = itx->itx_lr.lrc_txg; |
1146 |
ASSERT(txg); |
|
1147 |
||
1148 |
if (txg > spa_last_synced_txg(spa) || |
|
1149 |
txg > spa_freeze_txg(spa)) |
|
1150 |
lwb = zil_lwb_commit(zilog, itx, lwb); |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1151 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1152 |
zil_itx_destroy(itx); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1153 |
|
789 | 1154 |
mutex_enter(&zilog->zl_lock); |
1155 |
} |
|
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1156 |
DTRACE_PROBE1(zil__cw2, zilog_t *, zilog); |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1157 |
/* determine commit sequence number */ |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1158 |
itx = list_head(&zilog->zl_itx_list); |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1159 |
if (itx) |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1160 |
commit_seq = itx->itx_lr.lrc_seq - 1; |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1161 |
else |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1162 |
commit_seq = zilog->zl_itx_seq; |
789 | 1163 |
mutex_exit(&zilog->zl_lock); |
1164 |
||
1165 |
/* write the last block out */ |
|
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1166 |
if (lwb != NULL && lwb->lwb_zio != NULL) |
789 | 1167 |
lwb = zil_lwb_write_start(zilog, lwb); |
1168 |
||
1141 | 1169 |
zilog->zl_prev_used = zilog->zl_cur_used; |
1170 |
zilog->zl_cur_used = 0; |
|
1171 |
||
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1172 |
/* |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1173 |
* Wait if necessary for the log blocks to be on stable storage. |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1174 |
*/ |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1175 |
if (zilog->zl_root_zio) { |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1176 |
DTRACE_PROBE1(zil__cw3, zilog_t *, zilog); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1177 |
error = zio_wait(zilog->zl_root_zio); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7638
diff
changeset
|
1178 |
zilog->zl_root_zio = NULL; |
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1179 |
DTRACE_PROBE1(zil__cw4, zilog_t *, zilog); |
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
1180 |
zil_flush_vdevs(zilog); |
789 | 1181 |
} |
1141 | 1182 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1183 |
if (error || lwb == NULL) |
789 | 1184 |
txg_wait_synced(zilog->zl_dmu_pool, 0); |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1185 |
|
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1186 |
mutex_enter(&zilog->zl_lock); |
1141 | 1187 |
zilog->zl_writer = B_FALSE; |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1188 |
|
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1189 |
ASSERT3U(commit_seq, >=, zilog->zl_commit_seq); |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1190 |
zilog->zl_commit_seq = commit_seq; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1191 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1192 |
/* |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1193 |
* Remember the highest committed log sequence number for ztest. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1194 |
* We only update this value when all the log writes succeeded, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1195 |
* because ztest wants to ASSERT that it got the whole log chain. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1196 |
*/ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1197 |
if (error == 0 && lwb != NULL) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1198 |
zilog->zl_commit_lr_seq = zilog->zl_lr_seq; |
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1199 |
} |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1200 |
|
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1201 |
/* |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1202 |
* Push zfs transactions to stable storage up to the supplied sequence number. |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1203 |
* If foid is 0 push out all transactions, otherwise push only those |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1204 |
* for that file or might have been used to create that file. |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1205 |
*/ |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1206 |
void |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1207 |
zil_commit(zilog_t *zilog, uint64_t seq, uint64_t foid) |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1208 |
{ |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1209 |
if (zilog == NULL || seq == 0) |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1210 |
return; |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1211 |
|
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1212 |
mutex_enter(&zilog->zl_lock); |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1213 |
|
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1214 |
seq = MIN(seq, zilog->zl_itx_seq); /* cap seq at largest itx seq */ |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1215 |
|
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1216 |
while (zilog->zl_writer) { |
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1217 |
cv_wait(&zilog->zl_cv_writer, &zilog->zl_lock); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1218 |
if (seq <= zilog->zl_commit_seq) { |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1219 |
mutex_exit(&zilog->zl_lock); |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1220 |
return; |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1221 |
} |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1222 |
} |
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1223 |
zil_commit_writer(zilog, seq, foid); /* drops zl_lock */ |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1224 |
/* wake up others waiting on the commit */ |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1225 |
cv_broadcast(&zilog->zl_cv_writer); |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1226 |
mutex_exit(&zilog->zl_lock); |
789 | 1227 |
} |
1228 |
||
1229 |
/* |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1230 |
* Report whether all transactions are committed. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1231 |
*/ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1232 |
static boolean_t |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1233 |
zil_is_committed(zilog_t *zilog) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1234 |
{ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1235 |
lwb_t *lwb; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1236 |
boolean_t committed; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1237 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1238 |
mutex_enter(&zilog->zl_lock); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1239 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1240 |
while (zilog->zl_writer) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1241 |
cv_wait(&zilog->zl_cv_writer, &zilog->zl_lock); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1242 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1243 |
if (!list_is_empty(&zilog->zl_itx_list)) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1244 |
committed = B_FALSE; /* unpushed transactions */ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1245 |
else if ((lwb = list_head(&zilog->zl_lwb_list)) == NULL) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1246 |
committed = B_TRUE; /* intent log never used */ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1247 |
else if (list_next(&zilog->zl_lwb_list, lwb) != NULL) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1248 |
committed = B_FALSE; /* zil_sync() not done yet */ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1249 |
else |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1250 |
committed = B_TRUE; /* everything synced */ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1251 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1252 |
mutex_exit(&zilog->zl_lock); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1253 |
return (committed); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1254 |
} |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1255 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1256 |
/* |
789 | 1257 |
* Called in syncing context to free committed log blocks and update log header. |
1258 |
*/ |
|
1259 |
void |
|
1260 |
zil_sync(zilog_t *zilog, dmu_tx_t *tx) |
|
1261 |
{ |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1262 |
zil_header_t *zh = zil_header_in_syncing_context(zilog); |
789 | 1263 |
uint64_t txg = dmu_tx_get_txg(tx); |
1264 |
spa_t *spa = zilog->zl_spa; |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1265 |
uint64_t *replayed_seq = &zilog->zl_replayed_seq[txg & TXG_MASK]; |
789 | 1266 |
lwb_t *lwb; |
1267 |
||
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9321
diff
changeset
|
1268 |
/* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9321
diff
changeset
|
1269 |
* We don't zero out zl_destroy_txg, so make sure we don't try |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9321
diff
changeset
|
1270 |
* to destroy it twice. |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9321
diff
changeset
|
1271 |
*/ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9321
diff
changeset
|
1272 |
if (spa_sync_pass(spa) != 1) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9321
diff
changeset
|
1273 |
return; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9321
diff
changeset
|
1274 |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1275 |
mutex_enter(&zilog->zl_lock); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1276 |
|
789 | 1277 |
ASSERT(zilog->zl_stop_sync == 0); |
1278 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1279 |
if (*replayed_seq != 0) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1280 |
ASSERT(zh->zh_replay_seq < *replayed_seq); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1281 |
zh->zh_replay_seq = *replayed_seq; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1282 |
*replayed_seq = 0; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1283 |
} |
789 | 1284 |
|
1285 |
if (zilog->zl_destroy_txg == txg) { |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1286 |
blkptr_t blk = zh->zh_log; |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1287 |
|
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1288 |
ASSERT(list_head(&zilog->zl_lwb_list) == NULL); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1289 |
|
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1290 |
bzero(zh, sizeof (zil_header_t)); |
8227 | 1291 |
bzero(zilog->zl_replayed_seq, sizeof (zilog->zl_replayed_seq)); |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1292 |
|
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1293 |
if (zilog->zl_keep_first) { |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1294 |
/* |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1295 |
* If this block was part of log chain that couldn't |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1296 |
* be claimed because a device was missing during |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1297 |
* zil_claim(), but that device later returns, |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1298 |
* then this block could erroneously appear valid. |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1299 |
* To guard against this, assign a new GUID to the new |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1300 |
* log chain so it doesn't matter what blk points to. |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1301 |
*/ |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1302 |
zil_init_log_chain(zilog, &blk); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1303 |
zh->zh_log = blk; |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1304 |
} |
789 | 1305 |
} |
1306 |
||
9701
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1307 |
while ((lwb = list_head(&zilog->zl_lwb_list)) != NULL) { |
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1308 |
zh->zh_log = lwb->lwb_blk; |
789 | 1309 |
if (lwb->lwb_buf != NULL || lwb->lwb_max_txg > txg) |
1310 |
break; |
|
1311 |
list_remove(&zilog->zl_lwb_list, lwb); |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1312 |
zio_free_zil(spa, txg, &lwb->lwb_blk); |
789 | 1313 |
kmem_cache_free(zil_lwb_cache, lwb); |
3668 | 1314 |
|
1315 |
/* |
|
1316 |
* If we don't have anything left in the lwb list then |
|
1317 |
* we've had an allocation failure and we need to zero |
|
1318 |
* out the zil_header blkptr so that we don't end |
|
1319 |
* up freeing the same block twice. |
|
1320 |
*/ |
|
1321 |
if (list_head(&zilog->zl_lwb_list) == NULL) |
|
1322 |
BP_ZERO(&zh->zh_log); |
|
789 | 1323 |
} |
1324 |
mutex_exit(&zilog->zl_lock); |
|
1325 |
} |
|
1326 |
||
1327 |
void |
|
1328 |
zil_init(void) |
|
1329 |
{ |
|
1330 |
zil_lwb_cache = kmem_cache_create("zil_lwb_cache", |
|
2856 | 1331 |
sizeof (struct lwb), 0, NULL, NULL, NULL, NULL, NULL, 0); |
789 | 1332 |
} |
1333 |
||
1334 |
void |
|
1335 |
zil_fini(void) |
|
1336 |
{ |
|
1337 |
kmem_cache_destroy(zil_lwb_cache); |
|
1338 |
} |
|
1339 |
||
10310
ba87b3315737
PSARC 2009/423 ZFS logbias property
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10298
diff
changeset
|
1340 |
void |
ba87b3315737
PSARC 2009/423 ZFS logbias property
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10298
diff
changeset
|
1341 |
zil_set_logbias(zilog_t *zilog, uint64_t logbias) |
ba87b3315737
PSARC 2009/423 ZFS logbias property
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10298
diff
changeset
|
1342 |
{ |
ba87b3315737
PSARC 2009/423 ZFS logbias property
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10298
diff
changeset
|
1343 |
zilog->zl_logbias = logbias; |
ba87b3315737
PSARC 2009/423 ZFS logbias property
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10298
diff
changeset
|
1344 |
} |
ba87b3315737
PSARC 2009/423 ZFS logbias property
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10298
diff
changeset
|
1345 |
|
789 | 1346 |
zilog_t * |
1347 |
zil_alloc(objset_t *os, zil_header_t *zh_phys) |
|
1348 |
{ |
|
1349 |
zilog_t *zilog; |
|
1350 |
||
1351 |
zilog = kmem_zalloc(sizeof (zilog_t), KM_SLEEP); |
|
1352 |
||
1353 |
zilog->zl_header = zh_phys; |
|
1354 |
zilog->zl_os = os; |
|
1355 |
zilog->zl_spa = dmu_objset_spa(os); |
|
1356 |
zilog->zl_dmu_pool = dmu_objset_pool(os); |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1357 |
zilog->zl_destroy_txg = TXG_INITIAL - 1; |
10310
ba87b3315737
PSARC 2009/423 ZFS logbias property
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
10298
diff
changeset
|
1358 |
zilog->zl_logbias = dmu_objset_logbias(os); |
789 | 1359 |
|
2856 | 1360 |
mutex_init(&zilog->zl_lock, NULL, MUTEX_DEFAULT, NULL); |
1361 |
||
789 | 1362 |
list_create(&zilog->zl_itx_list, sizeof (itx_t), |
1363 |
offsetof(itx_t, itx_node)); |
|
1364 |
||
1365 |
list_create(&zilog->zl_lwb_list, sizeof (lwb_t), |
|
1366 |
offsetof(lwb_t, lwb_node)); |
|
1367 |
||
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
1368 |
mutex_init(&zilog->zl_vdev_lock, NULL, MUTEX_DEFAULT, NULL); |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
1369 |
|
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
1370 |
avl_create(&zilog->zl_vdev_tree, zil_vdev_compare, |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
1371 |
sizeof (zil_vdev_node_t), offsetof(zil_vdev_node_t, zv_node)); |
789 | 1372 |
|
5913
a77f8ad2ce63
6575965 panic/thread=2a1016b5ca0: BAD TRAP: type=9 rp=1858500 addr=0 mmu_fsr=0, really, truly out of space
perrin
parents:
5886
diff
changeset
|
1373 |
cv_init(&zilog->zl_cv_writer, NULL, CV_DEFAULT, NULL); |
a77f8ad2ce63
6575965 panic/thread=2a1016b5ca0: BAD TRAP: type=9 rp=1858500 addr=0 mmu_fsr=0, really, truly out of space
perrin
parents:
5886
diff
changeset
|
1374 |
cv_init(&zilog->zl_cv_suspend, NULL, CV_DEFAULT, NULL); |
a77f8ad2ce63
6575965 panic/thread=2a1016b5ca0: BAD TRAP: type=9 rp=1858500 addr=0 mmu_fsr=0, really, truly out of space
perrin
parents:
5886
diff
changeset
|
1375 |
|
789 | 1376 |
return (zilog); |
1377 |
} |
|
1378 |
||
1379 |
void |
|
1380 |
zil_free(zilog_t *zilog) |
|
1381 |
{ |
|
1382 |
lwb_t *lwb; |
|
1383 |
||
1384 |
zilog->zl_stop_sync = 1; |
|
1385 |
||
1386 |
while ((lwb = list_head(&zilog->zl_lwb_list)) != NULL) { |
|
1387 |
list_remove(&zilog->zl_lwb_list, lwb); |
|
1388 |
if (lwb->lwb_buf != NULL) |
|
1389 |
zio_buf_free(lwb->lwb_buf, lwb->lwb_sz); |
|
1390 |
kmem_cache_free(zil_lwb_cache, lwb); |
|
1391 |
} |
|
1392 |
list_destroy(&zilog->zl_lwb_list); |
|
1393 |
||
5688
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
1394 |
avl_destroy(&zilog->zl_vdev_tree); |
c0b02c8fd2c0
6640580 spa_get_random() is insanely slow in userland
bonwick
parents:
5676
diff
changeset
|
1395 |
mutex_destroy(&zilog->zl_vdev_lock); |
789 | 1396 |
|
1397 |
ASSERT(list_head(&zilog->zl_itx_list) == NULL); |
|
1398 |
list_destroy(&zilog->zl_itx_list); |
|
2856 | 1399 |
mutex_destroy(&zilog->zl_lock); |
789 | 1400 |
|
5913
a77f8ad2ce63
6575965 panic/thread=2a1016b5ca0: BAD TRAP: type=9 rp=1858500 addr=0 mmu_fsr=0, really, truly out of space
perrin
parents:
5886
diff
changeset
|
1401 |
cv_destroy(&zilog->zl_cv_writer); |
a77f8ad2ce63
6575965 panic/thread=2a1016b5ca0: BAD TRAP: type=9 rp=1858500 addr=0 mmu_fsr=0, really, truly out of space
perrin
parents:
5886
diff
changeset
|
1402 |
cv_destroy(&zilog->zl_cv_suspend); |
a77f8ad2ce63
6575965 panic/thread=2a1016b5ca0: BAD TRAP: type=9 rp=1858500 addr=0 mmu_fsr=0, really, truly out of space
perrin
parents:
5886
diff
changeset
|
1403 |
|
789 | 1404 |
kmem_free(zilog, sizeof (zilog_t)); |
1405 |
} |
|
1406 |
||
1407 |
/* |
|
1408 |
* Open an intent log. |
|
1409 |
*/ |
|
1410 |
zilog_t * |
|
1411 |
zil_open(objset_t *os, zil_get_data_t *get_data) |
|
1412 |
{ |
|
1413 |
zilog_t *zilog = dmu_objset_zil(os); |
|
1414 |
||
1415 |
zilog->zl_get_data = get_data; |
|
1416 |
zilog->zl_clean_taskq = taskq_create("zil_clean", 1, minclsyspri, |
|
1417 |
2, 2, TASKQ_PREPOPULATE); |
|
1418 |
||
1419 |
return (zilog); |
|
1420 |
} |
|
1421 |
||
1422 |
/* |
|
1423 |
* Close an intent log. |
|
1424 |
*/ |
|
1425 |
void |
|
1426 |
zil_close(zilog_t *zilog) |
|
1427 |
{ |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1428 |
/* |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1429 |
* If the log isn't already committed, mark the objset dirty |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1430 |
* (so zil_sync() will be called) and wait for that txg to sync. |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1431 |
*/ |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1432 |
if (!zil_is_committed(zilog)) { |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1433 |
uint64_t txg; |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1434 |
dmu_tx_t *tx = dmu_tx_create(zilog->zl_os); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1435 |
VERIFY(dmu_tx_assign(tx, TXG_WAIT) == 0); |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1436 |
dsl_dataset_dirty(dmu_objset_ds(zilog->zl_os), tx); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1437 |
txg = dmu_tx_get_txg(tx); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1438 |
dmu_tx_commit(tx); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1439 |
txg_wait_synced(zilog->zl_dmu_pool, txg); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1440 |
} |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1441 |
|
789 | 1442 |
taskq_destroy(zilog->zl_clean_taskq); |
1443 |
zilog->zl_clean_taskq = NULL; |
|
1444 |
zilog->zl_get_data = NULL; |
|
1445 |
||
1446 |
zil_itx_clean(zilog); |
|
1447 |
ASSERT(list_head(&zilog->zl_itx_list) == NULL); |
|
1448 |
} |
|
1449 |
||
1450 |
/* |
|
1451 |
* Suspend an intent log. While in suspended mode, we still honor |
|
1452 |
* synchronous semantics, but we rely on txg_wait_synced() to do it. |
|
1453 |
* We suspend the log briefly when taking a snapshot so that the snapshot |
|
1454 |
* contains all the data it's supposed to, and has an empty intent log. |
|
1455 |
*/ |
|
1456 |
int |
|
1457 |
zil_suspend(zilog_t *zilog) |
|
1458 |
{ |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1459 |
const zil_header_t *zh = zilog->zl_header; |
789 | 1460 |
|
1461 |
mutex_enter(&zilog->zl_lock); |
|
8989
cfce31f4eebf
6462803 zfs snapshot -r failed because filesystem was busy
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
8746
diff
changeset
|
1462 |
if (zh->zh_flags & ZIL_REPLAY_NEEDED) { /* unplayed log */ |
789 | 1463 |
mutex_exit(&zilog->zl_lock); |
1464 |
return (EBUSY); |
|
1465 |
} |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1466 |
if (zilog->zl_suspend++ != 0) { |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1467 |
/* |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1468 |
* Someone else already began a suspend. |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1469 |
* Just wait for them to finish. |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1470 |
*/ |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1471 |
while (zilog->zl_suspending) |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1472 |
cv_wait(&zilog->zl_cv_suspend, &zilog->zl_lock); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1473 |
mutex_exit(&zilog->zl_lock); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1474 |
return (0); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1475 |
} |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1476 |
zilog->zl_suspending = B_TRUE; |
789 | 1477 |
mutex_exit(&zilog->zl_lock); |
1478 |
||
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1479 |
zil_commit(zilog, UINT64_MAX, 0); |
789 | 1480 |
|
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1481 |
/* |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1482 |
* Wait for any in-flight log writes to complete. |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1483 |
*/ |
789 | 1484 |
mutex_enter(&zilog->zl_lock); |
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1485 |
while (zilog->zl_writer) |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1486 |
cv_wait(&zilog->zl_cv_writer, &zilog->zl_lock); |
789 | 1487 |
mutex_exit(&zilog->zl_lock); |
1488 |
||
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1489 |
zil_destroy(zilog, B_FALSE); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1490 |
|
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1491 |
mutex_enter(&zilog->zl_lock); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1492 |
zilog->zl_suspending = B_FALSE; |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1493 |
cv_broadcast(&zilog->zl_cv_suspend); |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1494 |
mutex_exit(&zilog->zl_lock); |
789 | 1495 |
|
1496 |
return (0); |
|
1497 |
} |
|
1498 |
||
1499 |
void |
|
1500 |
zil_resume(zilog_t *zilog) |
|
1501 |
{ |
|
1502 |
mutex_enter(&zilog->zl_lock); |
|
1503 |
ASSERT(zilog->zl_suspend != 0); |
|
1504 |
zilog->zl_suspend--; |
|
1505 |
mutex_exit(&zilog->zl_lock); |
|
1506 |
} |
|
1507 |
||
1508 |
typedef struct zil_replay_arg { |
|
1509 |
zil_replay_func_t **zr_replay; |
|
1510 |
void *zr_arg; |
|
1511 |
boolean_t zr_byteswap; |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1512 |
char *zr_lr; |
789 | 1513 |
} zil_replay_arg_t; |
1514 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1515 |
static int |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1516 |
zil_replay_error(zilog_t *zilog, lr_t *lr, int error) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1517 |
{ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1518 |
char name[MAXNAMELEN]; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1519 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1520 |
zilog->zl_replaying_seq--; /* didn't actually replay this one */ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1521 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1522 |
dmu_objset_name(zilog->zl_os, name); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1523 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1524 |
cmn_err(CE_WARN, "ZFS replay transaction error %d, " |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1525 |
"dataset %s, seq 0x%llx, txtype %llu %s\n", error, name, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1526 |
(u_longlong_t)lr->lrc_seq, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1527 |
(u_longlong_t)(lr->lrc_txtype & ~TX_CI), |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1528 |
(lr->lrc_txtype & TX_CI) ? "CI" : ""); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1529 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1530 |
return (error); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1531 |
} |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1532 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1533 |
static int |
789 | 1534 |
zil_replay_log_record(zilog_t *zilog, lr_t *lr, void *zra, uint64_t claim_txg) |
1535 |
{ |
|
1536 |
zil_replay_arg_t *zr = zra; |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1537 |
const zil_header_t *zh = zilog->zl_header; |
789 | 1538 |
uint64_t reclen = lr->lrc_reclen; |
1539 |
uint64_t txtype = lr->lrc_txtype; |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1540 |
int error = 0; |
789 | 1541 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1542 |
zilog->zl_replaying_seq = lr->lrc_seq; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1543 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1544 |
if (lr->lrc_seq <= zh->zh_replay_seq) /* already replayed */ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1545 |
return (0); |
789 | 1546 |
|
1547 |
if (lr->lrc_txg < claim_txg) /* already committed */ |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1548 |
return (0); |
789 | 1549 |
|
5331 | 1550 |
/* Strip case-insensitive bit, still present in log record */ |
1551 |
txtype &= ~TX_CI; |
|
1552 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1553 |
if (txtype == 0 || txtype >= TX_MAX_TYPE) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1554 |
return (zil_replay_error(zilog, lr, EINVAL)); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1555 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1556 |
/* |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1557 |
* If this record type can be logged out of order, the object |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1558 |
* (lr_foid) may no longer exist. That's legitimate, not an error. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1559 |
*/ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1560 |
if (TX_OOO(txtype)) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1561 |
error = dmu_object_info(zilog->zl_os, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1562 |
((lr_ooo_t *)lr)->lr_foid, NULL); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1563 |
if (error == ENOENT || error == EEXIST) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1564 |
return (0); |
8227 | 1565 |
} |
1566 |
||
789 | 1567 |
/* |
1568 |
* Make a copy of the data so we can revise and extend it. |
|
1569 |
*/ |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1570 |
bcopy(lr, zr->zr_lr, reclen); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1571 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1572 |
/* |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1573 |
* If this is a TX_WRITE with a blkptr, suck in the data. |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1574 |
*/ |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1575 |
if (txtype == TX_WRITE && reclen == sizeof (lr_write_t)) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1576 |
error = zil_read_log_data(zilog, (lr_write_t *)lr, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1577 |
zr->zr_lr + reclen); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1578 |
if (error) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1579 |
return (zil_replay_error(zilog, lr, error)); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1580 |
} |
789 | 1581 |
|
1582 |
/* |
|
1583 |
* The log block containing this lr may have been byteswapped |
|
1584 |
* so that we can easily examine common fields like lrc_txtype. |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1585 |
* However, the log is a mix of different record types, and only the |
789 | 1586 |
* replay vectors know how to byteswap their records. Therefore, if |
1587 |
* the lr was byteswapped, undo it before invoking the replay vector. |
|
1588 |
*/ |
|
1589 |
if (zr->zr_byteswap) |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1590 |
byteswap_uint64_array(zr->zr_lr, reclen); |
789 | 1591 |
|
1592 |
/* |
|
1593 |
* We must now do two things atomically: replay this log record, |
|
8227 | 1594 |
* and update the log header sequence number to reflect the fact that |
1595 |
* we did so. At the end of each replay function the sequence number |
|
1596 |
* is updated if we are in replay mode. |
|
789 | 1597 |
*/ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1598 |
error = zr->zr_replay[txtype](zr->zr_arg, zr->zr_lr, zr->zr_byteswap); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1599 |
if (error) { |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1600 |
/* |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1601 |
* The DMU's dnode layer doesn't see removes until the txg |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1602 |
* commits, so a subsequent claim can spuriously fail with |
8227 | 1603 |
* EEXIST. So if we receive any error we try syncing out |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1604 |
* any removes then retry the transaction. Note that we |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1605 |
* specify B_FALSE for byteswap now, so we don't do it twice. |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1606 |
*/ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1607 |
txg_wait_synced(spa_get_dsl(zilog->zl_spa), 0); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1608 |
error = zr->zr_replay[txtype](zr->zr_arg, zr->zr_lr, B_FALSE); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1609 |
if (error) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1610 |
return (zil_replay_error(zilog, lr, error)); |
789 | 1611 |
} |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1612 |
return (0); |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1613 |
} |
789 | 1614 |
|
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1615 |
/* ARGSUSED */ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1616 |
static int |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1617 |
zil_incr_blks(zilog_t *zilog, blkptr_t *bp, void *arg, uint64_t claim_txg) |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1618 |
{ |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1619 |
zilog->zl_replay_blks++; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1620 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1621 |
return (0); |
789 | 1622 |
} |
1623 |
||
1624 |
/* |
|
1362
2b3ee2467364
6377670 zil_replay() does unnecessary txg_wait_synced(), slowing down mount
perrin
parents:
1141
diff
changeset
|
1625 |
* If this dataset has a non-empty intent log, replay it and destroy it. |
789 | 1626 |
*/ |
1627 |
void |
|
8227 | 1628 |
zil_replay(objset_t *os, void *arg, zil_replay_func_t *replay_func[TX_MAX_TYPE]) |
789 | 1629 |
{ |
1630 |
zilog_t *zilog = dmu_objset_zil(os); |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1631 |
const zil_header_t *zh = zilog->zl_header; |
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1632 |
zil_replay_arg_t zr; |
1362
2b3ee2467364
6377670 zil_replay() does unnecessary txg_wait_synced(), slowing down mount
perrin
parents:
1141
diff
changeset
|
1633 |
|
8989
cfce31f4eebf
6462803 zfs snapshot -r failed because filesystem was busy
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
8746
diff
changeset
|
1634 |
if ((zh->zh_flags & ZIL_REPLAY_NEEDED) == 0) { |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1635 |
zil_destroy(zilog, B_TRUE); |
1362
2b3ee2467364
6377670 zil_replay() does unnecessary txg_wait_synced(), slowing down mount
perrin
parents:
1141
diff
changeset
|
1636 |
return; |
2b3ee2467364
6377670 zil_replay() does unnecessary txg_wait_synced(), slowing down mount
perrin
parents:
1141
diff
changeset
|
1637 |
} |
789 | 1638 |
|
1639 |
zr.zr_replay = replay_func; |
|
1640 |
zr.zr_arg = arg; |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1641 |
zr.zr_byteswap = BP_SHOULD_BYTESWAP(&zh->zh_log); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1642 |
zr.zr_lr = kmem_alloc(2 * SPA_MAXBLOCKSIZE, KM_SLEEP); |
789 | 1643 |
|
1644 |
/* |
|
1645 |
* Wait for in-progress removes to sync before starting replay. |
|
1646 |
*/ |
|
1647 |
txg_wait_synced(zilog->zl_dmu_pool, 0); |
|
1648 |
||
8227 | 1649 |
zilog->zl_replay = B_TRUE; |
11066
cebb50cbe4f9
PSARC/2009/396 Tickless Kernel Architecture / lbolt decoupling
Rafael Vanoni <rafael.vanoni@sun.com>
parents:
10922
diff
changeset
|
1650 |
zilog->zl_replay_time = ddi_get_lbolt(); |
3063
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1651 |
ASSERT(zilog->zl_replay_blks == 0); |
b252896b372b
6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents:
2986
diff
changeset
|
1652 |
(void) zil_parse(zilog, zil_incr_blks, zil_replay_log_record, &zr, |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1653 |
zh->zh_claim_txg); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1654 |
kmem_free(zr.zr_lr, 2 * SPA_MAXBLOCKSIZE); |
789 | 1655 |
|
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1669
diff
changeset
|
1656 |
zil_destroy(zilog, B_FALSE); |
5712
81f1af42bafc
6628232 zfs snapshot -r is very slow, causes systemic slowdown
ahrens
parents:
5688
diff
changeset
|
1657 |
txg_wait_synced(zilog->zl_dmu_pool, zilog->zl_destroy_txg); |
8227 | 1658 |
zilog->zl_replay = B_FALSE; |
789 | 1659 |
} |
1646
b4e43ae19fff
6393443 Remove remaining txg_wait_synced() from zfs unmount path.
perrin
parents:
1544
diff
changeset
|
1660 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1661 |
boolean_t |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1662 |
zil_replaying(zilog_t *zilog, dmu_tx_t *tx) |
1646
b4e43ae19fff
6393443 Remove remaining txg_wait_synced() from zfs unmount path.
perrin
parents:
1544
diff
changeset
|
1663 |
{ |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1664 |
if (zilog == NULL) |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1665 |
return (B_TRUE); |
1646
b4e43ae19fff
6393443 Remove remaining txg_wait_synced() from zfs unmount path.
perrin
parents:
1544
diff
changeset
|
1666 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1667 |
if (zilog->zl_replay) { |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1668 |
dsl_dataset_dirty(dmu_objset_ds(zilog->zl_os), tx); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1669 |
zilog->zl_replayed_seq[dmu_tx_get_txg(tx) & TXG_MASK] = |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1670 |
zilog->zl_replaying_seq; |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1671 |
return (B_TRUE); |
2638
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1672 |
} |
4f583dfeae92
6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents:
2391
diff
changeset
|
1673 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
1674 |
return (B_FALSE); |
1646
b4e43ae19fff
6393443 Remove remaining txg_wait_synced() from zfs unmount path.
perrin
parents:
1544
diff
changeset
|
1675 |
} |
9701
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1676 |
|
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1677 |
/* ARGSUSED */ |
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1678 |
int |
11209
462283cb4096
6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
11066
diff
changeset
|
1679 |
zil_vdev_offline(const char *osname, void *arg) |
9701
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1680 |
{ |
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1681 |
objset_t *os; |
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1682 |
zilog_t *zilog; |
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1683 |
int error; |
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1684 |
|
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10209
diff
changeset
|
1685 |
error = dmu_objset_hold(osname, FTAG, &os); |
9701
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1686 |
if (error) |
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1687 |
return (error); |
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1688 |
|
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1689 |
zilog = dmu_objset_zil(os); |
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1690 |
if (zil_suspend(zilog) != 0) |
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1691 |
error = EEXIST; |
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1692 |
else |
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1693 |
zil_resume(zilog); |
10298
a0d52501437c
6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
10209
diff
changeset
|
1694 |
dmu_objset_rele(os, FTAG); |
9701
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1695 |
return (error); |
cc5b64682e64
6803605 should be able to offline log devices
George Wilson <George.Wilson@Sun.COM>
parents:
9493
diff
changeset
|
1696 |
} |