Deleted Added
full compact
dmu_traverse.c (208371) dmu_traverse.c (209962)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 50 unchanged lines hidden (view full) ---

59 blkptr_t *td_rootbp;
60 uint64_t td_min_txg;
61 int td_flags;
62 struct prefetch_data *td_pfd;
63 blkptr_cb_t *td_func;
64 void *td_arg;
65};
66
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 50 unchanged lines hidden (view full) ---

59 blkptr_t *td_rootbp;
60 uint64_t td_min_txg;
61 int td_flags;
62 struct prefetch_data *td_pfd;
63 blkptr_cb_t *td_func;
64 void *td_arg;
65};
66
67static int traverse_dnode(struct traverse_data *td, const dnode_phys_t *dnp,
68 arc_buf_t *buf, uint64_t objset, uint64_t object);
69
67/* ARGSUSED */
68static void
69traverse_zil_block(zilog_t *zilog, blkptr_t *bp, void *arg, uint64_t claim_txg)
70{
71 struct traverse_data *td = arg;
72 zbookmark_t zb;
73
74 if (bp->blk_birth == 0)

--- 39 unchanged lines hidden (view full) ---

114{
115 uint64_t claim_txg = zh->zh_claim_txg;
116 zilog_t *zilog;
117
118 /*
119 * We only want to visit blocks that have been claimed but not yet
120 * replayed (or, in read-only mode, blocks that *would* be claimed).
121 */
70/* ARGSUSED */
71static void
72traverse_zil_block(zilog_t *zilog, blkptr_t *bp, void *arg, uint64_t claim_txg)
73{
74 struct traverse_data *td = arg;
75 zbookmark_t zb;
76
77 if (bp->blk_birth == 0)

--- 39 unchanged lines hidden (view full) ---

117{
118 uint64_t claim_txg = zh->zh_claim_txg;
119 zilog_t *zilog;
120
121 /*
122 * We only want to visit blocks that have been claimed but not yet
123 * replayed (or, in read-only mode, blocks that *would* be claimed).
124 */
122 if (claim_txg == 0 && (spa_mode & FWRITE))
125 if (claim_txg == 0 && spa_writeable(td->td_spa))
123 return;
124
125 zilog = zil_alloc(spa_get_dsl(td->td_spa)->dp_meta_objset, zh);
126
127 (void) zil_parse(zilog, traverse_zil_block, traverse_zil_record, td,
128 claim_txg);
129
130 zil_free(zilog);

--- 53 unchanged lines hidden (view full) ---

184 zb->zb_level - 1,
185 zb->zb_blkid * epb + i);
186 err = traverse_visitbp(td, dnp, buf, cbp, &czb);
187 if (err)
188 break;
189 }
190 } else if (BP_GET_TYPE(bp) == DMU_OT_DNODE) {
191 uint32_t flags = ARC_WAIT;
126 return;
127
128 zilog = zil_alloc(spa_get_dsl(td->td_spa)->dp_meta_objset, zh);
129
130 (void) zil_parse(zilog, traverse_zil_block, traverse_zil_record, td,
131 claim_txg);
132
133 zil_free(zilog);

--- 53 unchanged lines hidden (view full) ---

187 zb->zb_level - 1,
188 zb->zb_blkid * epb + i);
189 err = traverse_visitbp(td, dnp, buf, cbp, &czb);
190 if (err)
191 break;
192 }
193 } else if (BP_GET_TYPE(bp) == DMU_OT_DNODE) {
194 uint32_t flags = ARC_WAIT;
192 int i, j;
195 int i;
193 int epb = BP_GET_LSIZE(bp) >> DNODE_SHIFT;
194
195 err = arc_read(NULL, td->td_spa, bp, pbuf,
196 arc_getbuf_func, &buf,
197 ZIO_PRIORITY_ASYNC_READ, ZIO_FLAG_CANFAIL, &flags, zb);
198 if (err)
199 return (err);
200
201 /* recursively visitbp() blocks below this */
202 dnp = buf->b_data;
203 for (i = 0; i < epb && err == 0; i++, dnp++) {
196 int epb = BP_GET_LSIZE(bp) >> DNODE_SHIFT;
197
198 err = arc_read(NULL, td->td_spa, bp, pbuf,
199 arc_getbuf_func, &buf,
200 ZIO_PRIORITY_ASYNC_READ, ZIO_FLAG_CANFAIL, &flags, zb);
201 if (err)
202 return (err);
203
204 /* recursively visitbp() blocks below this */
205 dnp = buf->b_data;
206 for (i = 0; i < epb && err == 0; i++, dnp++) {
204 for (j = 0; j < dnp->dn_nblkptr; j++) {
205 SET_BOOKMARK(&czb, zb->zb_objset,
206 zb->zb_blkid * epb + i,
207 dnp->dn_nlevels - 1, j);
208 err = traverse_visitbp(td, dnp, buf,
209 (blkptr_t *)&dnp->dn_blkptr[j], &czb);
210 if (err)
211 break;
212 }
207 err = traverse_dnode(td, dnp, buf, zb->zb_objset,
208 zb->zb_blkid * epb + i);
209 if (err)
210 break;
213 }
214 } else if (BP_GET_TYPE(bp) == DMU_OT_OBJSET) {
215 uint32_t flags = ARC_WAIT;
216 objset_phys_t *osp;
211 }
212 } else if (BP_GET_TYPE(bp) == DMU_OT_OBJSET) {
213 uint32_t flags = ARC_WAIT;
214 objset_phys_t *osp;
217 int j;
215 dnode_phys_t *dnp;
218
219 err = arc_read_nolock(NULL, td->td_spa, bp,
220 arc_getbuf_func, &buf,
221 ZIO_PRIORITY_ASYNC_READ, ZIO_FLAG_CANFAIL, &flags, zb);
222 if (err)
223 return (err);
224
225 osp = buf->b_data;
226 traverse_zil(td, &osp->os_zil_header);
227
216
217 err = arc_read_nolock(NULL, td->td_spa, bp,
218 arc_getbuf_func, &buf,
219 ZIO_PRIORITY_ASYNC_READ, ZIO_FLAG_CANFAIL, &flags, zb);
220 if (err)
221 return (err);
222
223 osp = buf->b_data;
224 traverse_zil(td, &osp->os_zil_header);
225
228 for (j = 0; j < osp->os_meta_dnode.dn_nblkptr; j++) {
229 SET_BOOKMARK(&czb, zb->zb_objset, 0,
230 osp->os_meta_dnode.dn_nlevels - 1, j);
231 err = traverse_visitbp(td, &osp->os_meta_dnode, buf,
232 (blkptr_t *)&osp->os_meta_dnode.dn_blkptr[j],
233 &czb);
234 if (err)
235 break;
226 dnp = &osp->os_meta_dnode;
227 err = traverse_dnode(td, dnp, buf, zb->zb_objset, 0);
228 if (err == 0 && arc_buf_size(buf) >= sizeof (objset_phys_t)) {
229 dnp = &osp->os_userused_dnode;
230 err = traverse_dnode(td, dnp, buf, zb->zb_objset,
231 DMU_USERUSED_OBJECT);
236 }
232 }
233 if (err == 0 && arc_buf_size(buf) >= sizeof (objset_phys_t)) {
234 dnp = &osp->os_groupused_dnode;
235 err = traverse_dnode(td, dnp, buf, zb->zb_objset,
236 DMU_GROUPUSED_OBJECT);
237 }
237 }
238
239 if (buf)
240 (void) arc_buf_remove_ref(buf, &buf);
241
242 if (err == 0 && (td->td_flags & TRAVERSE_POST))
243 err = td->td_func(td->td_spa, bp, zb, dnp, td->td_arg);
244
245 return (err);
246}
247
238 }
239
240 if (buf)
241 (void) arc_buf_remove_ref(buf, &buf);
242
243 if (err == 0 && (td->td_flags & TRAVERSE_POST))
244 err = td->td_func(td->td_spa, bp, zb, dnp, td->td_arg);
245
246 return (err);
247}
248
249static int
250traverse_dnode(struct traverse_data *td, const dnode_phys_t *dnp,
251 arc_buf_t *buf, uint64_t objset, uint64_t object)
252{
253 int j, err = 0;
254 zbookmark_t czb;
255
256 for (j = 0; j < dnp->dn_nblkptr; j++) {
257 SET_BOOKMARK(&czb, objset, object, dnp->dn_nlevels - 1, j);
258 err = traverse_visitbp(td, dnp, buf,
259 (blkptr_t *)&dnp->dn_blkptr[j], &czb);
260 if (err)
261 break;
262 }
263 return (err);
264}
265
248/* ARGSUSED */
249static int
250traverse_prefetcher(spa_t *spa, blkptr_t *bp, const zbookmark_t *zb,
251 const dnode_phys_t *dnp, void *arg)
252{
253 struct prefetch_data *pfd = arg;
254 uint32_t aflags = ARC_NOWAIT | ARC_PREFETCH;
255

--- 147 unchanged lines hidden ---
266/* ARGSUSED */
267static int
268traverse_prefetcher(spa_t *spa, blkptr_t *bp, const zbookmark_t *zb,
269 const dnode_phys_t *dnp, void *arg)
270{
271 struct prefetch_data *pfd = arg;
272 uint32_t aflags = ARC_NOWAIT | ARC_PREFETCH;
273

--- 147 unchanged lines hidden ---