author | Christopher Siden <chris.siden@delphix.com> |
Mon, 21 May 2012 12:11:39 -0700 | |
changeset 13700 | 2889e2596bd6 |
parent 13055 | 8c712bbb18ea |
child 13764 | 38b4aca480b3 |
permissions | -rw-r--r-- |
789 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
1544 | 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 |
/* |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
22 |
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
23 |
* Copyright (c) 2012 by Delphix. All rights reserved. |
789 | 24 |
*/ |
25 |
||
26 |
#include <sys/zfs_context.h> |
|
27 |
#include <sys/dmu_objset.h> |
|
28 |
#include <sys/dmu_traverse.h> |
|
29 |
#include <sys/dsl_dataset.h> |
|
30 |
#include <sys/dsl_dir.h> |
|
31 |
#include <sys/dsl_pool.h> |
|
32 |
#include <sys/dnode.h> |
|
33 |
#include <sys/spa.h> |
|
34 |
#include <sys/zio.h> |
|
35 |
#include <sys/dmu_impl.h> |
|
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11724
diff
changeset
|
36 |
#include <sys/sa.h> |
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11724
diff
changeset
|
37 |
#include <sys/sa_impl.h> |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
38 |
#include <sys/callb.h> |
789 | 39 |
|
12605
6790e683d5a5
6959846 DMU traverse prefetch size should be a global tunable
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
40 |
int zfs_pd_blks_max = 100; |
6790e683d5a5
6959846 DMU traverse prefetch size should be a global tunable
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
41 |
|
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
42 |
typedef struct prefetch_data { |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
43 |
kmutex_t pd_mtx; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
44 |
kcondvar_t pd_cv; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
45 |
int pd_blks_max; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
46 |
int pd_blks_fetched; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
47 |
int pd_flags; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
48 |
boolean_t pd_cancel; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
49 |
boolean_t pd_exited; |
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
50 |
} prefetch_data_t; |
789 | 51 |
|
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
52 |
typedef struct traverse_data { |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
53 |
spa_t *td_spa; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
54 |
uint64_t td_objset; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
55 |
blkptr_t *td_rootbp; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
56 |
uint64_t td_min_txg; |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
57 |
zbookmark_t *td_resume; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
58 |
int td_flags; |
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
59 |
prefetch_data_t *td_pfd; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
60 |
blkptr_cb_t *td_func; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
61 |
void *td_arg; |
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
62 |
} traverse_data_t; |
789 | 63 |
|
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
64 |
static int traverse_dnode(traverse_data_t *td, const dnode_phys_t *dnp, |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
65 |
arc_buf_t *buf, uint64_t objset, uint64_t object); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
66 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
67 |
static int |
1601
438b928f80c7
6397197 ADVANCE_ZIL should only visit claimed-but-not-yet-replayed logs
bonwick
parents:
1544
diff
changeset
|
68 |
traverse_zil_block(zilog_t *zilog, blkptr_t *bp, void *arg, uint64_t claim_txg) |
1544 | 69 |
{ |
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
70 |
traverse_data_t *td = arg; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
71 |
zbookmark_t zb; |
1544 | 72 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
73 |
if (bp->blk_birth == 0) |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
74 |
return (0); |
1601
438b928f80c7
6397197 ADVANCE_ZIL should only visit claimed-but-not-yet-replayed logs
bonwick
parents:
1544
diff
changeset
|
75 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
76 |
if (claim_txg == 0 && bp->blk_birth >= spa_first_txg(td->td_spa)) |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
77 |
return (0); |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
78 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
79 |
SET_BOOKMARK(&zb, td->td_objset, ZB_ZIL_OBJECT, ZB_ZIL_LEVEL, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
80 |
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
|
81 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
82 |
(void) td->td_func(td->td_spa, zilog, bp, NULL, &zb, NULL, td->td_arg); |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
83 |
|
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
84 |
return (0); |
1544 | 85 |
} |
86 |
||
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
87 |
static int |
1601
438b928f80c7
6397197 ADVANCE_ZIL should only visit claimed-but-not-yet-replayed logs
bonwick
parents:
1544
diff
changeset
|
88 |
traverse_zil_record(zilog_t *zilog, lr_t *lrc, void *arg, uint64_t claim_txg) |
1544 | 89 |
{ |
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
90 |
traverse_data_t *td = arg; |
1544 | 91 |
|
92 |
if (lrc->lrc_txtype == TX_WRITE) { |
|
93 |
lr_write_t *lr = (lr_write_t *)lrc; |
|
94 |
blkptr_t *bp = &lr->lr_blkptr; |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
95 |
zbookmark_t zb; |
1544 | 96 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
97 |
if (bp->blk_birth == 0) |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
98 |
return (0); |
1601
438b928f80c7
6397197 ADVANCE_ZIL should only visit claimed-but-not-yet-replayed logs
bonwick
parents:
1544
diff
changeset
|
99 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
100 |
if (claim_txg == 0 || bp->blk_birth < claim_txg) |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
101 |
return (0); |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
102 |
|
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
103 |
SET_BOOKMARK(&zb, td->td_objset, lr->lr_foid, |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
104 |
ZB_ZIL_LEVEL, lr->lr_offset / BP_GET_LSIZE(bp)); |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
105 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
106 |
(void) td->td_func(td->td_spa, zilog, bp, NULL, &zb, NULL, |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
107 |
td->td_arg); |
1544 | 108 |
} |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
109 |
return (0); |
1544 | 110 |
} |
111 |
||
112 |
static void |
|
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
113 |
traverse_zil(traverse_data_t *td, zil_header_t *zh) |
1544 | 114 |
{ |
1601
438b928f80c7
6397197 ADVANCE_ZIL should only visit claimed-but-not-yet-replayed logs
bonwick
parents:
1544
diff
changeset
|
115 |
uint64_t claim_txg = zh->zh_claim_txg; |
1544 | 116 |
zilog_t *zilog; |
117 |
||
1601
438b928f80c7
6397197 ADVANCE_ZIL should only visit claimed-but-not-yet-replayed logs
bonwick
parents:
1544
diff
changeset
|
118 |
/* |
438b928f80c7
6397197 ADVANCE_ZIL should only visit claimed-but-not-yet-replayed logs
bonwick
parents:
1544
diff
changeset
|
119 |
* We only want to visit blocks that have been claimed but not yet |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
120 |
* replayed; plus, in read-only mode, blocks that are already stable. |
1601
438b928f80c7
6397197 ADVANCE_ZIL should only visit claimed-but-not-yet-replayed logs
bonwick
parents:
1544
diff
changeset
|
121 |
*/ |
8241
5a60f16123ba
6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
8012
diff
changeset
|
122 |
if (claim_txg == 0 && spa_writeable(td->td_spa)) |
1601
438b928f80c7
6397197 ADVANCE_ZIL should only visit claimed-but-not-yet-replayed logs
bonwick
parents:
1544
diff
changeset
|
123 |
return; |
438b928f80c7
6397197 ADVANCE_ZIL should only visit claimed-but-not-yet-replayed logs
bonwick
parents:
1544
diff
changeset
|
124 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
125 |
zilog = zil_alloc(spa_get_dsl(td->td_spa)->dp_meta_objset, zh); |
1544 | 126 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
127 |
(void) zil_parse(zilog, traverse_zil_block, traverse_zil_record, td, |
1601
438b928f80c7
6397197 ADVANCE_ZIL should only visit claimed-but-not-yet-replayed logs
bonwick
parents:
1544
diff
changeset
|
128 |
claim_txg); |
1544 | 129 |
|
130 |
zil_free(zilog); |
|
131 |
} |
|
132 |
||
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
133 |
typedef enum resume_skip { |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
134 |
RESUME_SKIP_ALL, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
135 |
RESUME_SKIP_NONE, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
136 |
RESUME_SKIP_CHILDREN |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
137 |
} resume_skip_t; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
138 |
|
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
139 |
/* |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
140 |
* Returns RESUME_SKIP_ALL if td indicates that we are resuming a traversal and |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
141 |
* the block indicated by zb does not need to be visited at all. Returns |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
142 |
* RESUME_SKIP_CHILDREN if we are resuming a post traversal and we reach the |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
143 |
* resume point. This indicates that this block should be visited but not its |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
144 |
* children (since they must have been visited in a previous traversal). |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
145 |
* Otherwise returns RESUME_SKIP_NONE. |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
146 |
*/ |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
147 |
static resume_skip_t |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
148 |
resume_skip_check(traverse_data_t *td, const dnode_phys_t *dnp, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
149 |
const zbookmark_t *zb) |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
150 |
{ |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
151 |
if (td->td_resume != NULL && !ZB_IS_ZERO(td->td_resume)) { |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
152 |
/* |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
153 |
* If we already visited this bp & everything below, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
154 |
* don't bother doing it again. |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
155 |
*/ |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
156 |
if (zbookmark_is_before(dnp, zb, td->td_resume)) |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
157 |
return (RESUME_SKIP_ALL); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
158 |
|
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
159 |
/* |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
160 |
* If we found the block we're trying to resume from, zero |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
161 |
* the bookmark out to indicate that we have resumed. |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
162 |
*/ |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
163 |
ASSERT3U(zb->zb_object, <=, td->td_resume->zb_object); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
164 |
if (bcmp(zb, td->td_resume, sizeof (*zb)) == 0) { |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
165 |
bzero(td->td_resume, sizeof (*zb)); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
166 |
if (td->td_flags & TRAVERSE_POST) |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
167 |
return (RESUME_SKIP_CHILDREN); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
168 |
} |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
169 |
} |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
170 |
return (RESUME_SKIP_NONE); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
171 |
} |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
172 |
|
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
173 |
static void |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
174 |
traverse_pause(traverse_data_t *td, const zbookmark_t *zb) |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
175 |
{ |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
176 |
ASSERT(td->td_resume != NULL); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
177 |
ASSERT3U(zb->zb_level, ==, 0); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
178 |
bcopy(zb, td->td_resume, sizeof (*td->td_resume)); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
179 |
} |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
180 |
|
789 | 181 |
static int |
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
182 |
traverse_visitbp(traverse_data_t *td, const dnode_phys_t *dnp, |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
183 |
arc_buf_t *pbuf, blkptr_t *bp, const zbookmark_t *zb) |
789 | 184 |
{ |
8012
8ea30813950f
6765626 zfs send takes up too much stack space
Eric Taylor <Eric.Taylor@Sun.COM>
parents:
7837
diff
changeset
|
185 |
zbookmark_t czb; |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
186 |
int err = 0, lasterr = 0; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
187 |
arc_buf_t *buf = NULL; |
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
188 |
prefetch_data_t *pd = td->td_pfd; |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
189 |
boolean_t hard = td->td_flags & TRAVERSE_HARD; |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
190 |
boolean_t pause = B_FALSE; |
789 | 191 |
|
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
192 |
switch (resume_skip_check(td, dnp, zb)) { |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
193 |
case RESUME_SKIP_ALL: |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
194 |
return (0); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
195 |
case RESUME_SKIP_CHILDREN: |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
196 |
goto post; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
197 |
case RESUME_SKIP_NONE: |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
198 |
break; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
199 |
default: |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
200 |
ASSERT(0); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
201 |
} |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
202 |
|
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
203 |
if (BP_IS_HOLE(bp)) { |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
204 |
err = td->td_func(td->td_spa, NULL, NULL, pbuf, zb, dnp, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
205 |
td->td_arg); |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
206 |
return (err); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
207 |
} |
789 | 208 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
209 |
if (bp->blk_birth <= td->td_min_txg) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
210 |
return (0); |
789 | 211 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
212 |
if (pd && !pd->pd_exited && |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
213 |
((pd->pd_flags & TRAVERSE_PREFETCH_DATA) || |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
214 |
BP_GET_TYPE(bp) == DMU_OT_DNODE || BP_GET_LEVEL(bp) > 0)) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
215 |
mutex_enter(&pd->pd_mtx); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
216 |
ASSERT(pd->pd_blks_fetched >= 0); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
217 |
while (pd->pd_blks_fetched == 0 && !pd->pd_exited) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
218 |
cv_wait(&pd->pd_cv, &pd->pd_mtx); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
219 |
pd->pd_blks_fetched--; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
220 |
cv_broadcast(&pd->pd_cv); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
221 |
mutex_exit(&pd->pd_mtx); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
222 |
} |
789 | 223 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
224 |
if (td->td_flags & TRAVERSE_PRE) { |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
225 |
err = td->td_func(td->td_spa, NULL, bp, pbuf, zb, dnp, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
226 |
td->td_arg); |
13055 | 227 |
if (err == TRAVERSE_VISIT_NO_CHILDREN) |
228 |
return (0); |
|
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
229 |
if (err == ERESTART) |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
230 |
pause = B_TRUE; /* handle pausing at a common point */ |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
231 |
if (err != 0) |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
232 |
goto post; |
789 | 233 |
} |
234 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
235 |
if (BP_GET_LEVEL(bp) > 0) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
236 |
uint32_t flags = ARC_WAIT; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
237 |
int i; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
238 |
blkptr_t *cbp; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
239 |
int epb = BP_GET_LSIZE(bp) >> SPA_BLKPTRSHIFT; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
240 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
241 |
err = dsl_read(NULL, td->td_spa, bp, pbuf, |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
242 |
arc_getbuf_func, &buf, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
243 |
ZIO_PRIORITY_ASYNC_READ, ZIO_FLAG_CANFAIL, &flags, zb); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
244 |
if (err) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
245 |
return (err); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
246 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
247 |
/* recursively visitbp() blocks below this */ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
248 |
cbp = buf->b_data; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
249 |
for (i = 0; i < epb; i++, cbp++) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
250 |
SET_BOOKMARK(&czb, zb->zb_objset, zb->zb_object, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
251 |
zb->zb_level - 1, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
252 |
zb->zb_blkid * epb + i); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
253 |
err = traverse_visitbp(td, dnp, buf, cbp, &czb); |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
254 |
if (err) { |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
255 |
if (!hard) |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
256 |
break; |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
257 |
lasterr = err; |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
258 |
} |
789 | 259 |
} |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
260 |
} else if (BP_GET_TYPE(bp) == DMU_OT_DNODE) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
261 |
uint32_t flags = ARC_WAIT; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
262 |
int i; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
263 |
int epb = BP_GET_LSIZE(bp) >> DNODE_SHIFT; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
264 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
265 |
err = dsl_read(NULL, td->td_spa, bp, pbuf, |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
266 |
arc_getbuf_func, &buf, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
267 |
ZIO_PRIORITY_ASYNC_READ, ZIO_FLAG_CANFAIL, &flags, zb); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
268 |
if (err) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
269 |
return (err); |
789 | 270 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
271 |
/* recursively visitbp() blocks below this */ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
272 |
dnp = buf->b_data; |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
273 |
for (i = 0; i < epb; i++, dnp++) { |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
274 |
err = traverse_dnode(td, dnp, buf, zb->zb_objset, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
275 |
zb->zb_blkid * epb + i); |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
276 |
if (err) { |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
277 |
if (!hard) |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
278 |
break; |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
279 |
lasterr = err; |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
280 |
} |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
281 |
} |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
282 |
} else if (BP_GET_TYPE(bp) == DMU_OT_OBJSET) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
283 |
uint32_t flags = ARC_WAIT; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
284 |
objset_phys_t *osp; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
285 |
dnode_phys_t *dnp; |
789 | 286 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
287 |
err = dsl_read_nolock(NULL, td->td_spa, bp, |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
288 |
arc_getbuf_func, &buf, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
289 |
ZIO_PRIORITY_ASYNC_READ, ZIO_FLAG_CANFAIL, &flags, zb); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
290 |
if (err) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
291 |
return (err); |
789 | 292 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
293 |
osp = buf->b_data; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
294 |
dnp = &osp->os_meta_dnode; |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
295 |
err = traverse_dnode(td, dnp, buf, zb->zb_objset, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
296 |
DMU_META_DNODE_OBJECT); |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
297 |
if (err && hard) { |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
298 |
lasterr = err; |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
299 |
err = 0; |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
300 |
} |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
301 |
if (err == 0 && arc_buf_size(buf) >= sizeof (objset_phys_t)) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
302 |
dnp = &osp->os_userused_dnode; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
303 |
err = traverse_dnode(td, dnp, buf, zb->zb_objset, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
304 |
DMU_USERUSED_OBJECT); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
305 |
} |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
306 |
if (err && hard) { |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
307 |
lasterr = err; |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
308 |
err = 0; |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
309 |
} |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
310 |
if (err == 0 && arc_buf_size(buf) >= sizeof (objset_phys_t)) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
311 |
dnp = &osp->os_groupused_dnode; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
312 |
err = traverse_dnode(td, dnp, buf, zb->zb_objset, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
313 |
DMU_GROUPUSED_OBJECT); |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
314 |
} |
789 | 315 |
} |
316 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
317 |
if (buf) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
318 |
(void) arc_buf_remove_ref(buf, &buf); |
789 | 319 |
|
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
320 |
post: |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
321 |
if (err == 0 && lasterr == 0 && (td->td_flags & TRAVERSE_POST)) { |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
322 |
err = td->td_func(td->td_spa, NULL, bp, pbuf, zb, dnp, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
323 |
td->td_arg); |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
324 |
if (err == ERESTART) |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
325 |
pause = B_TRUE; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
326 |
} |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
327 |
|
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
328 |
if (pause && td->td_resume != NULL) { |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
329 |
ASSERT3U(err, ==, ERESTART); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
330 |
ASSERT(!hard); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
331 |
traverse_pause(td, zb); |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
332 |
} |
789 | 333 |
|
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
334 |
return (err != 0 ? err : lasterr); |
789 | 335 |
} |
336 |
||
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
337 |
static int |
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
338 |
traverse_dnode(traverse_data_t *td, const dnode_phys_t *dnp, |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
339 |
arc_buf_t *buf, uint64_t objset, uint64_t object) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
340 |
{ |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
341 |
int j, err = 0, lasterr = 0; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
342 |
zbookmark_t czb; |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
343 |
boolean_t hard = (td->td_flags & TRAVERSE_HARD); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
344 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
345 |
for (j = 0; j < dnp->dn_nblkptr; j++) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
346 |
SET_BOOKMARK(&czb, objset, object, dnp->dn_nlevels - 1, j); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
347 |
err = traverse_visitbp(td, dnp, buf, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
348 |
(blkptr_t *)&dnp->dn_blkptr[j], &czb); |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
349 |
if (err) { |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
350 |
if (!hard) |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
351 |
break; |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
352 |
lasterr = err; |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
353 |
} |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
354 |
} |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
355 |
|
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
356 |
if (dnp->dn_flags & DNODE_FLAG_SPILL_BLKPTR) { |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
357 |
SET_BOOKMARK(&czb, objset, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
358 |
object, 0, DMU_SPILL_BLKID); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
359 |
err = traverse_visitbp(td, dnp, buf, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
360 |
(blkptr_t *)&dnp->dn_spill, &czb); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
361 |
if (err) { |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
362 |
if (!hard) |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
363 |
return (err); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
364 |
lasterr = err; |
11935
538c866aaac6
6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents:
11724
diff
changeset
|
365 |
} |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
366 |
} |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
367 |
return (err != 0 ? err : lasterr); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
368 |
} |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8746
diff
changeset
|
369 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
370 |
/* ARGSUSED */ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
371 |
static int |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
372 |
traverse_prefetcher(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
373 |
arc_buf_t *pbuf, const zbookmark_t *zb, const dnode_phys_t *dnp, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
374 |
void *arg) |
6423 | 375 |
{ |
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
376 |
prefetch_data_t *pfd = arg; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
377 |
uint32_t aflags = ARC_NOWAIT | ARC_PREFETCH; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
378 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
379 |
ASSERT(pfd->pd_blks_fetched >= 0); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
380 |
if (pfd->pd_cancel) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
381 |
return (EINTR); |
6423 | 382 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
383 |
if (bp == NULL || !((pfd->pd_flags & TRAVERSE_PREFETCH_DATA) || |
11670
1d964fb5d948
6595532 ZIL is too talkative
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
11125
diff
changeset
|
384 |
BP_GET_TYPE(bp) == DMU_OT_DNODE || BP_GET_LEVEL(bp) > 0) || |
1d964fb5d948
6595532 ZIL is too talkative
Neil Perrin <Neil.Perrin@Sun.COM>
parents:
11125
diff
changeset
|
385 |
BP_GET_TYPE(bp) == DMU_OT_INTENT_LOG) |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
386 |
return (0); |
6423 | 387 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
388 |
mutex_enter(&pfd->pd_mtx); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
389 |
while (!pfd->pd_cancel && pfd->pd_blks_fetched >= pfd->pd_blks_max) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
390 |
cv_wait(&pfd->pd_cv, &pfd->pd_mtx); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
391 |
pfd->pd_blks_fetched++; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
392 |
cv_broadcast(&pfd->pd_cv); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
393 |
mutex_exit(&pfd->pd_mtx); |
6423 | 394 |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11935
diff
changeset
|
395 |
(void) dsl_read(NULL, spa, bp, pbuf, NULL, NULL, |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
396 |
ZIO_PRIORITY_ASYNC_READ, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
397 |
ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
398 |
&aflags, zb); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
399 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
400 |
return (0); |
6423 | 401 |
} |
402 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
403 |
static void |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
404 |
traverse_prefetch_thread(void *arg) |
789 | 405 |
{ |
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
406 |
traverse_data_t *td_main = arg; |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
407 |
traverse_data_t td = *td_main; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
408 |
zbookmark_t czb; |
789 | 409 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
410 |
td.td_func = traverse_prefetcher; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
411 |
td.td_arg = td_main->td_pfd; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
412 |
td.td_pfd = NULL; |
789 | 413 |
|
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
414 |
SET_BOOKMARK(&czb, td.td_objset, |
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
415 |
ZB_ROOT_OBJECT, ZB_ROOT_LEVEL, ZB_ROOT_BLKID); |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
416 |
(void) traverse_visitbp(&td, NULL, NULL, td.td_rootbp, &czb); |
789 | 417 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
418 |
mutex_enter(&td_main->td_pfd->pd_mtx); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
419 |
td_main->td_pfd->pd_exited = B_TRUE; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
420 |
cv_broadcast(&td_main->td_pfd->pd_cv); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
421 |
mutex_exit(&td_main->td_pfd->pd_mtx); |
789 | 422 |
} |
423 |
||
424 |
/* |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
425 |
* NB: dataset must not be changing on-disk (eg, is a snapshot or we are |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
426 |
* in syncing context). |
789 | 427 |
*/ |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
428 |
static int |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
429 |
traverse_impl(spa_t *spa, dsl_dataset_t *ds, uint64_t objset, blkptr_t *rootbp, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
430 |
uint64_t txg_start, zbookmark_t *resume, int flags, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
431 |
blkptr_cb_t func, void *arg) |
789 | 432 |
{ |
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
433 |
traverse_data_t td; |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
434 |
prefetch_data_t pd = { 0 }; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
435 |
zbookmark_t czb; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
436 |
int err; |
789 | 437 |
|
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
438 |
ASSERT(ds == NULL || objset == ds->ds_object); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
439 |
ASSERT(!(flags & TRAVERSE_PRE) || !(flags & TRAVERSE_POST)); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
440 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
441 |
td.td_spa = spa; |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
442 |
td.td_objset = objset; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
443 |
td.td_rootbp = rootbp; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
444 |
td.td_min_txg = txg_start; |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
445 |
td.td_resume = resume; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
446 |
td.td_func = func; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
447 |
td.td_arg = arg; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
448 |
td.td_pfd = &pd; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
449 |
td.td_flags = flags; |
789 | 450 |
|
12605
6790e683d5a5
6959846 DMU traverse prefetch size should be a global tunable
Chris Kirby <Chris.Kirby@oracle.com>
parents:
12296
diff
changeset
|
451 |
pd.pd_blks_max = zfs_pd_blks_max; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
452 |
pd.pd_flags = flags; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
453 |
mutex_init(&pd.pd_mtx, NULL, MUTEX_DEFAULT, NULL); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
454 |
cv_init(&pd.pd_cv, NULL, CV_DEFAULT, NULL); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
455 |
|
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
456 |
/* See comment on ZIL traversal in dsl_scan_visitds. */ |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
457 |
if (ds != NULL && !dsl_dataset_is_snapshot(ds)) { |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
458 |
objset_t *os; |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
459 |
|
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
460 |
err = dmu_objset_from_ds(ds, &os); |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
461 |
if (err) |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
462 |
return (err); |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
463 |
|
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
464 |
traverse_zil(&td, &os->os_zil_header); |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
465 |
} |
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
466 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
467 |
if (!(flags & TRAVERSE_PREFETCH) || |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
468 |
0 == taskq_dispatch(system_taskq, traverse_prefetch_thread, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
469 |
&td, TQ_NOQUEUE)) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
470 |
pd.pd_exited = B_TRUE; |
789 | 471 |
|
12839
1eab9192da8b
6844896 recursive snapshots take a long time
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
12605
diff
changeset
|
472 |
SET_BOOKMARK(&czb, td.td_objset, |
10922
e2081f502306
PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10921
diff
changeset
|
473 |
ZB_ROOT_OBJECT, ZB_ROOT_LEVEL, ZB_ROOT_BLKID); |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
474 |
err = traverse_visitbp(&td, NULL, NULL, rootbp, &czb); |
789 | 475 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
476 |
mutex_enter(&pd.pd_mtx); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
477 |
pd.pd_cancel = B_TRUE; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
478 |
cv_broadcast(&pd.pd_cv); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
479 |
while (!pd.pd_exited) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
480 |
cv_wait(&pd.pd_cv, &pd.pd_mtx); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
481 |
mutex_exit(&pd.pd_mtx); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
482 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
483 |
mutex_destroy(&pd.pd_mtx); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
484 |
cv_destroy(&pd.pd_cv); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
485 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
486 |
return (err); |
789 | 487 |
} |
488 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
489 |
/* |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
490 |
* NB: dataset must not be changing on-disk (eg, is a snapshot or we are |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
491 |
* in syncing context). |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
492 |
*/ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
493 |
int |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
494 |
traverse_dataset(dsl_dataset_t *ds, uint64_t txg_start, int flags, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
495 |
blkptr_cb_t func, void *arg) |
789 | 496 |
{ |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
497 |
return (traverse_impl(ds->ds_dir->dd_pool->dp_spa, ds, ds->ds_object, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
498 |
&ds->ds_phys->ds_bp, txg_start, NULL, flags, func, arg)); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
499 |
} |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
500 |
|
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
501 |
int |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
502 |
traverse_dataset_destroyed(spa_t *spa, blkptr_t *blkptr, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
503 |
uint64_t txg_start, zbookmark_t *resume, int flags, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
504 |
blkptr_cb_t func, void *arg) |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
505 |
{ |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
506 |
return (traverse_impl(spa, NULL, ZB_DESTROYED_OBJSET, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
507 |
blkptr, txg_start, resume, flags, func, arg)); |
789 | 508 |
} |
509 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
510 |
/* |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
511 |
* NB: pool must not be changing on-disk (eg, from zdb or sync context). |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
512 |
*/ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
513 |
int |
11125
fca3e6d28599
6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10922
diff
changeset
|
514 |
traverse_pool(spa_t *spa, uint64_t txg_start, int flags, |
fca3e6d28599
6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10922
diff
changeset
|
515 |
blkptr_cb_t func, void *arg) |
789 | 516 |
{ |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
517 |
int err, lasterr = 0; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
518 |
uint64_t obj; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
519 |
dsl_pool_t *dp = spa_get_dsl(spa); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
520 |
objset_t *mos = dp->dp_meta_objset; |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
521 |
boolean_t hard = (flags & TRAVERSE_HARD); |
789 | 522 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
523 |
/* visit the MOS */ |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
524 |
err = traverse_impl(spa, NULL, 0, spa_get_rootblkptr(spa), |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
13055
diff
changeset
|
525 |
txg_start, NULL, flags, func, arg); |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
526 |
if (err) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
527 |
return (err); |
789 | 528 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
529 |
/* visit each dataset */ |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
530 |
for (obj = 1; err == 0 || (err != ESRCH && hard); |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
531 |
err = dmu_object_next(mos, &obj, FALSE, txg_start)) { |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
532 |
dmu_object_info_t doi; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
533 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
534 |
err = dmu_object_info(mos, obj, &doi); |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
535 |
if (err) { |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
536 |
if (!hard) |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
537 |
return (err); |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
538 |
lasterr = err; |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
539 |
continue; |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
540 |
} |
789 | 541 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
542 |
if (doi.doi_type == DMU_OT_DSL_DATASET) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
543 |
dsl_dataset_t *ds; |
10921
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
9396
diff
changeset
|
544 |
uint64_t txg = txg_start; |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
9396
diff
changeset
|
545 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
546 |
rw_enter(&dp->dp_config_rwlock, RW_READER); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
547 |
err = dsl_dataset_hold_obj(dp, obj, FTAG, &ds); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
548 |
rw_exit(&dp->dp_config_rwlock); |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
549 |
if (err) { |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
550 |
if (!hard) |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
551 |
return (err); |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
552 |
lasterr = err; |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
553 |
continue; |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
554 |
} |
10921
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
9396
diff
changeset
|
555 |
if (ds->ds_phys->ds_prev_snap_txg > txg) |
8aac17999e4d
PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents:
9396
diff
changeset
|
556 |
txg = ds->ds_phys->ds_prev_snap_txg; |
11125
fca3e6d28599
6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
10922
diff
changeset
|
557 |
err = traverse_dataset(ds, txg, flags, func, arg); |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
558 |
dsl_dataset_rele(ds, FTAG); |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
559 |
if (err) { |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
560 |
if (!hard) |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
561 |
return (err); |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
562 |
lasterr = err; |
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
563 |
} |
789 | 564 |
} |
565 |
} |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
566 |
if (err == ESRCH) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7046
diff
changeset
|
567 |
err = 0; |
11724
a2728800460e
6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
11670
diff
changeset
|
568 |
return (err != 0 ? err : lasterr); |
789 | 569 |
} |