20
20
*/
21
21
/*
22
22
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23
- * Copyright (c) 2013 by Delphix. All rights reserved.
23
+ * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
24
24
*/
25
25
26
26
#include <sys/zfs_context.h>
@@ -197,6 +197,16 @@ traverse_prefetch_metadata(traverse_data_t *td,
197
197
ZIO_PRIORITY_ASYNC_READ , ZIO_FLAG_CANFAIL , & flags , zb );
198
198
}
199
199
200
+ static boolean_t
201
+ prefetch_needed (prefetch_data_t * pfd , const blkptr_t * bp )
202
+ {
203
+ ASSERT (pfd -> pd_flags & TRAVERSE_PREFETCH_DATA );
204
+ if (BP_IS_HOLE (bp ) || BP_IS_EMBEDDED (bp ) ||
205
+ BP_GET_TYPE (bp ) == DMU_OT_INTENT_LOG )
206
+ return (B_FALSE );
207
+ return (B_TRUE );
208
+ }
209
+
200
210
static int
201
211
traverse_visitbp (traverse_data_t * td , const dnode_phys_t * dnp ,
202
212
const blkptr_t * bp , const zbookmark_t * zb )
@@ -242,16 +252,7 @@ traverse_visitbp(traverse_data_t *td, const dnode_phys_t *dnp,
242
252
return (0 );
243
253
}
244
254
245
- if (BP_IS_HOLE (bp )) {
246
- err = td -> td_func (td -> td_spa , NULL , bp , zb , dnp , td -> td_arg );
247
- if (err != 0 )
248
- goto post ;
249
- return (0 );
250
- }
251
-
252
- if (pd && !pd -> pd_exited &&
253
- ((pd -> pd_flags & TRAVERSE_PREFETCH_DATA ) ||
254
- BP_GET_TYPE (bp ) == DMU_OT_DNODE || BP_GET_LEVEL (bp ) > 0 )) {
255
+ if (pd != NULL && !pd -> pd_exited && prefetch_needed (pd , bp )) {
255
256
mutex_enter (& pd -> pd_mtx );
256
257
ASSERT (pd -> pd_blks_fetched >= 0 );
257
258
while (pd -> pd_blks_fetched == 0 && !pd -> pd_exited )
@@ -261,6 +262,13 @@ traverse_visitbp(traverse_data_t *td, const dnode_phys_t *dnp,
261
262
mutex_exit (& pd -> pd_mtx );
262
263
}
263
264
265
+ if (BP_IS_HOLE (bp )) {
266
+ err = td -> td_func (td -> td_spa , NULL , bp , zb , dnp , td -> td_arg );
267
+ if (err != 0 )
268
+ goto post ;
269
+ return (0 );
270
+ }
271
+
264
272
if (td -> td_flags & TRAVERSE_PRE ) {
265
273
err = td -> td_func (td -> td_spa , NULL , bp , zb , dnp ,
266
274
td -> td_arg );
@@ -444,10 +452,7 @@ traverse_prefetcher(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
444
452
if (pfd -> pd_cancel )
445
453
return (SET_ERROR (EINTR ));
446
454
447
- if (BP_IS_HOLE (bp ) || BP_IS_EMBEDDED (bp ) ||
448
- !((pfd -> pd_flags & TRAVERSE_PREFETCH_DATA ) ||
449
- BP_GET_TYPE (bp ) == DMU_OT_DNODE || BP_GET_LEVEL (bp ) > 0 ) ||
450
- BP_GET_TYPE (bp ) == DMU_OT_INTENT_LOG )
455
+ if (!prefetch_needed (pfd , bp ))
451
456
return (0 );
452
457
453
458
mutex_enter (& pfd -> pd_mtx );
0 commit comments